Skip to content

Commit

Permalink
added ability to adjust the import view in the pre commit script (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariodavid authored Jun 28, 2018
1 parent 817e3b3 commit e8695d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class GenericDataImporterServiceBean implements GenericDataImporterService {

private void doImportSingleEntity(ImportEntityRequest importEntityRequest, EntityImportView importView, Collection<ImportEntityRequest> importedEntities, ImportConfiguration importConfiguration, ImportLog importLog) {

boolean entityShouldBeImported = executePreCommitScriptIfNecessary(importEntityRequest, importConfiguration)
boolean entityShouldBeImported = executePreCommitScriptIfNecessary(importEntityRequest, importConfiguration, importView)

if (entityShouldBeImported) {
if (importConfiguration.transactionStrategy == ImportTransactionStrategy.TRANSACTION_PER_ENTITY) {
Expand All @@ -146,18 +146,19 @@ class GenericDataImporterServiceBean implements GenericDataImporterService {
}
}

private Binding createPreCommitBinding(ImportEntityRequest importEntityRequest, ImportConfiguration importConfiguration) {
private Binding createPreCommitBinding(ImportEntityRequest importEntityRequest, ImportConfiguration importConfiguration, EntityImportView importView) {
new Binding(
entity: importEntityRequest.entity,
dataRow: importEntityRequest.dataRow,
dataManager: dataManager,
importConfiguration: importConfiguration,
importView: importView
)
}


private boolean executePreCommitScriptIfNecessary(ImportEntityRequest importEntityRequest, ImportConfiguration importConfiguration) {
Binding preCommitBinding = createPreCommitBinding(importEntityRequest, importConfiguration)
private boolean executePreCommitScriptIfNecessary(ImportEntityRequest importEntityRequest, ImportConfiguration importConfiguration, EntityImportView importView) {
Binding preCommitBinding = createPreCommitBinding(importEntityRequest, importConfiguration, importView)
def preCommitScript = importConfiguration.preCommitScript
try {
if (preCommitScript) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ preCommitScriptHelp=This script can be used to change the entity instance before
- entity: the entity instance \n\
- dataRow: the raw data from the input file \n\
- dataManager: dataManager instance \n\
- importConfiguration: the import configuration that is currently configured
- importConfiguration: the import configuration that is currently configured \n\
- importView: the import view (com.haulmont.cuba.core.app.importexport.EntityImportView) for advanced adjustments of the properties to import
transactionStrategyHelp=The transaction strategy defines how the system should behave in case one of the entries cannot be stored. The following options are available: \n\n\
- Single transaction: All entities will be imported in one transaction. If an error occurs in any of the entities, no entity will be imported \n\n\
- Transaction per Entity: Every entity will be imported in an own transaction. If an error occurs in any of the entities, all other entities will be imported
Expand Down

0 comments on commit e8695d6

Please sign in to comment.