Skip to content

feat(contacts): add CSV import for APP-ADMIN and IT-ADMIN (#39)#41

Open
Ndacyayisenga-droid wants to merge 3 commits into
OpenElementsLabs:mainfrom
Ndacyayisenga-droid:importcontacts
Open

feat(contacts): add CSV import for APP-ADMIN and IT-ADMIN (#39)#41
Ndacyayisenga-droid wants to merge 3 commits into
OpenElementsLabs:mainfrom
Ndacyayisenga-droid:importcontacts

Conversation

@Ndacyayisenga-droid

@Ndacyayisenga-droid Ndacyayisenga-droid commented Jun 25, 2026

Copy link
Copy Markdown

@hendrikebbers hendrikebbers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some minor comments

/**
* Response from the CSV import preview endpoint.
*/
public record ContactImportPreviewResponse(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add minimal javadoc for each attribute pls

/**
* Request body for CSV import preview and commit endpoints.
*/
public record ContactImportRequest(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add minimal javadoc for each attribute pls

this.contactService = Objects.requireNonNull(contactService, "contactService must not be null");
}

@Transactional(propagation = Propagation.REQUIRES_NEW)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why propagation is set to a specific value here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commits a single imported contact in its own transaction for partial-success imports.

Got it, makes sense :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: do you understand it? That is an interesting part of the code and something that is more special than the rest

static final int MAX_ROWS = 5_000;
static final long MAX_FILE_SIZE_BYTES = 20L * 1024L * 1024L;

private static final Set<String> SUPPORTED_ENCODINGS = Set.of("UTF-8", "WINDOWS-1252");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: can we use java.nio.charset.StandardCharsets instead of custom constants?

this.rowSaver = Objects.requireNonNull(rowSaver, "rowSaver must not be null");
}

public ContactImportPreviewResponse preview(final MultipartFile file, final ContactImportRequest request) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assume this method in the controller since MultipartFile file is HTTP / Rest specific.

}

public ImportResult commit(final MultipartFile file, final ContactImportRequest request) {
final ParsedCsv parsed = parseFile(file, request);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I beliefe the methods here should have ParsedCsv as param instead of MultipartFile. MultipartFile is more controller / rest specific

chooseFile: "Datei wählen",
noFileChosen: "Keine Datei ausgewählt",
encoding: "Zeichenkodierung",
encodingUtf8: "UTF-8",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 2 encodings are fixed values and do not need a translation fro m my point of view

forbidden: "Sie haben keine Berechtigung, Kontakte zu importieren.",
generic: "Import fehlgeschlagen. Bitte erneut versuchen.",
},
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your German is really excellent :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants