@Component(value="blImportPersister") public class ImportPersisterImpl extends Object implements ImportPersister, LateIdResolver
Modifier and Type | Field and Description |
---|---|
protected org.broadleafcommerce.openadmin.server.service.AdminEntityService |
adminEntityService |
protected javax.persistence.EntityManager |
em |
protected DynamicEntityDaoProvider |
entityDaoProvider |
protected org.springframework.core.env.Environment |
environment |
protected ExecutorService |
exService |
protected org.broadleafcommerce.profile.core.extension.PostUpdateCustomerExtensionManager |
extensionManager |
protected ExternalIdUtil |
externalIdUtil |
protected HashMap<String,String> |
idCache |
protected List<RecordPersistencePostProcessor> |
postProcessors |
protected List<RecordPersistencePreProcessor> |
preProcessors |
protected com.broadleafcommerce.process.manager.ProcessStateManager |
processStateManager |
protected org.broadleafcommerce.common.site.service.SiteService |
siteService |
LATE_RESOLUTION_VALUE
Constructor and Description |
---|
ImportPersisterImpl() |
Modifier and Type | Method and Description |
---|---|
protected org.broadleafcommerce.openadmin.server.service.persistence.PersistenceResponse |
addRecordRequest(Long processId,
RecordParseResult record,
org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest request,
ImportContext context,
boolean transactional) |
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. |
protected List<org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest> |
filterSubRequests(org.broadleafcommerce.openadmin.dto.Entity mainRequest,
org.broadleafcommerce.openadmin.dto.ClassMetadata mainMetadata,
List<org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest> subRequests)
Some sub requests should not be imported based on the actual type that is being imported.
|
protected String |
getCatalogColumnName() |
protected org.broadleafcommerce.common.site.domain.Catalog |
getDefaultCatalog(ImportContext context) |
String |
getPrimaryKey(String key)
Attempts to retrieve the primary key from the cache.
|
protected String |
getPrimaryKeyValue(org.broadleafcommerce.openadmin.dto.Entity entity)
Obtains the primary key from the entity within the given entity.
|
protected void |
handleValidationError(org.broadleafcommerce.openadmin.server.service.persistence.PersistenceResponse response) |
protected String |
parseExternalId(String key) |
protected org.broadleafcommerce.openadmin.server.service.persistence.PersistenceResponse |
persistMapSubRequest(Long processId,
org.broadleafcommerce.openadmin.server.service.persistence.PersistenceResponse rootResponse,
org.broadleafcommerce.openadmin.dto.ClassMetadata mainMetadata,
RecordParseResult record,
org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest subRequest,
ImportContext context) |
List<org.broadleafcommerce.openadmin.server.service.persistence.PersistenceResponse> |
persistRecords(List<RecordParseResult> records,
ImportContext context,
Long processId)
Transactionally persists a batch of records into the database
If you are invoking this you need to handle validation problems that could occur within each
PersistenceResponse
result. |
protected void |
populateLateIds(org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest request) |
void |
populatePrimaryKey(String key,
String primaryKey)
Populates the cache with a primary key
|
protected org.broadleafcommerce.openadmin.server.service.persistence.PersistenceResponse |
processEntityAdd(org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest request,
boolean transactional,
org.broadleafcommerce.common.site.domain.Site site,
org.broadleafcommerce.common.site.domain.Catalog catalog)
This method is responsible for making a callout to the
AdminEntityService to process the add request. |
void |
setAdminEntityService(org.broadleafcommerce.openadmin.server.service.AdminEntityService adminEntityService) |
protected org.broadleafcommerce.openadmin.server.service.AdminEntityService adminEntityService
protected ExternalIdUtil externalIdUtil
protected com.broadleafcommerce.process.manager.ProcessStateManager processStateManager
protected DynamicEntityDaoProvider entityDaoProvider
protected org.springframework.core.env.Environment environment
protected org.broadleafcommerce.common.site.service.SiteService siteService
@Autowired(required=false) protected List<RecordPersistencePreProcessor> preProcessors
@Autowired(required=false) protected List<RecordPersistencePostProcessor> postProcessors
protected javax.persistence.EntityManager em
protected org.broadleafcommerce.profile.core.extension.PostUpdateCustomerExtensionManager extensionManager
protected ExecutorService exService
@Autowired public void setAdminEntityService(@Qualifier(value="blAdminEntityService") org.broadleafcommerce.openadmin.server.service.AdminEntityService adminEntityService)
@Transactional(value="blTransactionManager") public List<org.broadleafcommerce.openadmin.server.service.persistence.PersistenceResponse> persistRecords(List<RecordParseResult> records, ImportContext context, Long processId) throws org.broadleafcommerce.common.exception.ServiceException
PersistenceResponse
result.persistRecords
in interface ImportPersister
records
- the batch of records to transactionally persist into the databaseorg.broadleafcommerce.common.exception.ServiceException
- if there were any problems as a result of persisting the recordsprotected org.broadleafcommerce.openadmin.server.service.persistence.PersistenceResponse addRecordRequest(Long processId, RecordParseResult record, org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest request, ImportContext context, boolean transactional) throws org.broadleafcommerce.common.exception.ServiceException
org.broadleafcommerce.common.exception.ServiceException
protected org.broadleafcommerce.openadmin.server.service.persistence.PersistenceResponse processEntityAdd(org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest request, boolean transactional, org.broadleafcommerce.common.site.domain.Site site, org.broadleafcommerce.common.site.domain.Catalog catalog) throws org.broadleafcommerce.common.exception.ServiceException
AdminEntityService
to process the add request.request
- transactional
- site
- catalog
- org.broadleafcommerce.common.exception.ServiceException
protected List<org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest> filterSubRequests(org.broadleafcommerce.openadmin.dto.Entity mainRequest, org.broadleafcommerce.openadmin.dto.ClassMetadata mainMetadata, List<org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest> subRequests)
Some sub requests should not be imported based on the actual type that is being imported. While the importing class could still be something like Product, the
actual mainRequest.getType()
could be a Sku. Some of the foreign key references that might be hooked up when importing a product (like product
attributes) should not be done when importing a Sku.
This default behavior ensures that the mainRequest.getType()[0]
is assignable from each sub request's getForeignKey().getForeignKeyClass()
(if
it has one).
mainRequest
- the parent entity that has already been insertedsubRequests
- the sub requests right before they are persistedprotected void handleValidationError(org.broadleafcommerce.openadmin.server.service.persistence.PersistenceResponse response)
protected org.broadleafcommerce.openadmin.server.service.persistence.PersistenceResponse persistMapSubRequest(Long processId, org.broadleafcommerce.openadmin.server.service.persistence.PersistenceResponse rootResponse, org.broadleafcommerce.openadmin.dto.ClassMetadata mainMetadata, RecordParseResult record, org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest subRequest, ImportContext context) throws org.broadleafcommerce.common.exception.ServiceException, LateIdResolutionException
rootResponse
- the original parent responsemainMetadata
- the metadata for the parent requestsubRequest
- the sub request to persistorg.broadleafcommerce.common.exception.ServiceException
LateIdResolutionException
protected String getPrimaryKeyValue(org.broadleafcommerce.openadmin.dto.Entity entity)
entity
- an entity to obtain the primary key from. Entity.getType()[0]
must not be nullprotected void populateLateIds(org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest request) throws LateIdResolutionException
LateIdResolutionException
public void populatePrimaryKey(String key, String primaryKey)
LateIdResolver
populatePrimaryKey
in interface LateIdResolver
key
- a valid key built from LateIdResolver.buildLateResolutionKey(String, String)
primaryKey
- the primary key to put in the mappublic String getPrimaryKey(String key)
LateIdResolver
getPrimaryKey
in interface LateIdResolver
key
- a valid key built from LateIdResolver.buildLateResolutionKey(String, String)
LateIdResolver.populatePrimaryKey(String, String)
or null if none existspublic String buildLateResolutionKey(String ceilingClass, String externalId)
LateIdResolver
BroadleafCellProcessor
s that want to resolve an ID late in the game.
This will automatically build something that takes the ceilingClass, externalId and
LateIdResolver.LATE_RESOLUTION_VALUE
to build a placeholder keybuildLateResolutionKey
in interface LateIdResolver
ceilingClass
- the class that the primary key should come fromexternalId
- the external ID that should uniquely identify the given ceilingClassprotected String getCatalogColumnName()
protected org.broadleafcommerce.common.site.domain.Catalog getDefaultCatalog(ImportContext context)
Copyright © 2020. All rights reserved.