-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Optimised Internal methods for adding relationships for import, fixed circular dependency, generated changeEvents #25582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1060,23 +1060,39 @@ protected void createEntity(CSVPrinter printer, List<CSVRecord> csvRecords) thro | |
| .withDefaultRoles(getEntityReferences(printer, csvRecord, 7, ROLE)) | ||
| .withPolicies(getEntityReferences(printer, csvRecord, 8, POLICY)); | ||
|
|
||
| // Pre-track the entity so getParents can find it for circular dependency detection | ||
| if (processRecord) { | ||
| dryRunCreatedEntities.put(team.getName(), team); | ||
| } | ||
|
|
||
| // Field 5 - parent teams | ||
| getParents(printer, csvRecord, team); | ||
|
|
||
| // Validate during dry run to catch logical errors early | ||
| TeamRepository repository = (TeamRepository) Entity.getEntityRepository(TEAM); | ||
| if (processRecord && importResult.getDryRun()) { | ||
| if (processRecord) { | ||
| createEntity(printer, csvRecord, team); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| protected void createEntity(CSVPrinter resultsPrinter, CSVRecord csvRecord, Team entity) | ||
| throws IOException { | ||
|
|
||
| // Validate hierarchy now that entity is pre-tracked | ||
| if (processRecord) { | ||
| TeamRepository repository = (TeamRepository) Entity.getEntityRepository(TEAM); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DetailsIn the overridden @Override
protected void createEntity(CSVPrinter resultsPrinter, CSVRecord csvRecord, Team entity)
throws IOException {
// Validate hierarchy now that entity is pre-tracked
if (processRecord) { // This check is redundant/suspicious
TeamRepository repository = (TeamRepository) Entity.getEntityRepository(TEAM);The Consider removing the redundant check or documenting why it's necessary. Was this helpful? React with 👍 / 👎 |
||
| try { | ||
| repository.validateForDryRun(team, dryRunCreatedEntities); | ||
| repository.validateForDryRun(entity, dryRunCreatedEntities); | ||
| } catch (Exception ex) { | ||
| importFailure(printer, ex.getMessage(), csvRecord); | ||
| importFailure(resultsPrinter, ex.getMessage(), csvRecord); | ||
| processRecord = false; | ||
| // Remove from dryRunCreatedEntities since validation failed | ||
| dryRunCreatedEntities.remove(entity.getName()); | ||
| return; // Don't proceed with creation | ||
| } | ||
| } | ||
|
|
||
| if (processRecord) { | ||
| createEntity(printer, csvRecord, team); | ||
| } | ||
| // Now call the parent method for normal processing | ||
| super.createEntity(resultsPrinter, csvRecord, entity); | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Details
When an update operation has a null
originalEntity, the code logs a warning but doesn't actually handle the entity:The entity is silently dropped from processing - no exception is thrown, no fallback is executed, and no failure is recorded to the CSV import results. This could lead to data loss where users think their update succeeded (since no error is reported in the import results) but the entity was never actually updated.
Consider either:
Was this helpful? React with 👍 / 👎