public abstract class AbstractWebCmsDataImporter<T,U> extends Object implements WebCmsDataImporter
WebCmsDataImporter that needs to support both map and
collection data, as well as the different WebCmsDataImportAction options.
Each entry to import is expected to represent a single object.
Dispatches to the WebCmsPropertyDataImportService for custom property handling.
If neither related property handlers have imported anything, nor values on the original
asset have been changed, the asset will not be updated.| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
LOG |
| Constructor and Description |
|---|
AbstractWebCmsDataImporter() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addForceUpdateProperty(Map<String,Object> dataValues)
Add force update property to a data values map.
|
protected boolean |
applyDataValues(Map<String,Object> values,
U dto)
Apply the data values to the dto object.
|
protected abstract U |
createDto(WebCmsDataEntry data,
T existing,
WebCmsDataAction action,
Map<String,Object> dataValues)
Create a DTO object for either a new instance or an existing instance.
|
protected abstract void |
deleteInstance(T instance,
WebCmsDataEntry data)
Perform the delete action on existing instance.
|
void |
importData(WebCmsDataEntry data)
Import a single data entry from the original data set.
|
protected U |
prepareForSaving(U itemToBeSaved,
WebCmsDataEntry data)
Override if you want to post process an item before saving.
|
protected WebCmsDataAction |
resolveAction(WebCmsDataImportAction requested,
T existing)
Resolve the import action into the actual action to perform depending if there's an
existing item we're dealing with or not.
|
protected WebCmsDomain |
retrieveDomainForDataEntry(WebCmsDataEntry item,
Class<?> entityType)
Retrieves the current domain for the specified data entry and class.
|
protected abstract T |
retrieveExistingInstance(WebCmsDataEntry data)
Get the existing object that this data represents.
|
protected abstract void |
saveDto(U dto,
WebCmsDataAction action,
WebCmsDataEntry data)
Save an updated or created instance.
|
void |
setPropertyDataImportService(WebCmsPropertyDataImportService propertyDataImportService) |
protected void |
validate(U itemToBeSaved,
org.springframework.validation.Errors errors)
Perform some custom validation on the item to be saved.
|
protected void |
validateForSaving(U itemToSave)
This performs validation by building an
Errors object, and dispatching to the #validate(T, Errors)
method. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsupportspublic final void importData(WebCmsDataEntry data)
WebCmsDomainBound object,
the domain will be prefilled with WebCmsMultiDomainService.getCurrentDomain()importData in interface WebCmsDataImporterdata - to importprotected WebCmsDomain retrieveDomainForDataEntry(WebCmsDataEntry item, Class<?> entityType)
WebCmsMultiDomainService.getCurrentDomainForType(Class)item - the data entryentityType - to check domain supportprotected boolean applyDataValues(Map<String,Object> values, U dto)
false no values have been applied to the DTO and actual updating
might get skipped.values - to apply (key/value pairs)dto - to set the values onprotected WebCmsDataAction resolveAction(WebCmsDataImportAction requested, T existing)
null the
processing of the data entry will be skipped.requested - import actionexisting - item or null if nonenull if noneprotected final void validateForSaving(U itemToSave)
Errors object, and dispatching to the #validate(T, Errors)
method. If actual validation errors are added, this will result in a validation exception.itemToSave - item to be savedprotected U prepareForSaving(U itemToBeSaved, WebCmsDataEntry data)
itemToBeSaved - original item to be saveddata - that was used to build the itemprotected void validate(U itemToBeSaved, org.springframework.validation.Errors errors)
itemToBeSaved - item to be savederrors - collection to add validation errors toprotected abstract T retrieveExistingInstance(WebCmsDataEntry data)
null..data - entrynullprotected abstract U createDto(WebCmsDataEntry data, T existing, WebCmsDataAction action, Map<String,Object> dataValues)
null a new instance should be created.
Note that the DTO should not apply the data entry values yet, but the data entry
can be used to determine the initial type of instance that needs to be created.
If the DTO is null, the import will be skipped but properties will still be called.data - entryexisting - instance or null if a new instance should be createdaction - purpose for which the DTO should be created (create, delete or replace)dataValues - modifiable collection of the data values that will be applied afterwardsprotected abstract void deleteInstance(T instance, WebCmsDataEntry data)
instance - to deletedata - entry that is being importedprotected abstract void saveDto(U dto, WebCmsDataAction action, WebCmsDataEntry data)
dto - that should be savedaction - type of save action (create, update or replace)data - entry that is being importedprotected final void addForceUpdateProperty(Map<String,Object> dataValues)
dataValues - map@Autowired public void setPropertyDataImportService(WebCmsPropertyDataImportService propertyDataImportService)
Copyright © 2020. All rights reserved.