Skip to content

[NAE 1843] Import/Export services #296

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

Draft
wants to merge 10 commits into
base: release/7.0.0
Choose a base branch
from
Draft

Conversation

SamuelPalaj
Copy link
Contributor

@SamuelPalaj SamuelPalaj commented Mar 24, 2025

Description

  • added prototypes CaseImporter and CaseExporter
  • CaseImportExportService added
  • ZipArchiveService added
  • endpoints for case exporting and importing added in CaseImportExportController

Implements NAE-1843

Dependencies

No new dependencies were introduced

Third party dependencies

No new dependencies were introduced

Blocking Pull requests

There are no dependencies on other PR

How Has Been This Tested?

Manually, unit tests are WIP

Test Configuration

Name Tested on
OS windows 10
Runtime java 21
Dependency Manager Maven 3.9.9
Framework version Spring Boot 3.2.5
Run parameters
Other configuration

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes have been checked, personally or remotely, with @...
  • I have commented my code, particularly in hard-to-understand areas
  • I have resolved all conflicts with the target branch of the PR
  • I have updated and synced my code with the target branch
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes:
    • Lint test
    • Unit tests
    • Integration tests
  • I have checked my contribution with code analysis tools:
  • I have made corresponding changes to the documentation:
    • Developer documentation
    • User Guides
    • Migration Guides

- added CaseExporter class
- implementation of case export
- work in progress
- added CaseImporter
- added service CaseImportExportService and controller CaseImportExportController
- added schema location to properties
- functionality changes to CaseExporter
- added full xsd schema to petriflow_schema.xsd for testing purposes
- added new dependecy zip4j
- work in progress
- service name typo fix
- changes to case import and export functionality
- translations are now exported
- import and export of roles removed
- implementation of zip service added
- work in progress on tests
- removal of unused dependency
- CaseImportExportTest tests improved, added test net nae_1843.xml
- added nae.case.export.file-name property
- improved error handling
- multiple bug fixes and small optimizations
for (String fileName : field.right) {
String filePath = storageService.getPath(caseId, storageField.getStringId(), fileName);
InputStream fis = storageService.get(storageField, filePath);
String newFileName = caseId.concat(File.separator).concat(storageField.getStringId()).concat(File.separator).concat(fileName);
Copy link
Member

Choose a reason for hiding this comment

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

Better than concatenating strings with File.separator will be to use Paths.get() ...
Paths.get(caseId, storageField.toString(), filename)

import lombok.Data;

@Data
public class CaseExportProperties {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this a separate class? This class is used only in the properties bean.

@Slf4j
@Data
@Component
@ConfigurationProperties(prefix = "nae.case")
Copy link
Member

Choose a reason for hiding this comment

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

As this is the bean for properties specifically for case import and export, the prefix should be unique nae.case.export .

try {
marshallCase(xmlCases);
} catch (JAXBException e) {
throw new RuntimeException(e);
Copy link
Member

Choose a reason for hiding this comment

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

Please log the error even if it is rethrown right after. At least log.error(e.getMeesage(), e)

@RestController()
@RequestMapping("/api/case")
@AllArgsConstructor
public class CaseImportExportController {
Copy link
Member

Choose a reason for hiding this comment

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

For consistency reasons, shouldn't there be two controllers? One is for export endpoints, and the other is for import endpoints.

<xs:include schemaLocation="https://petriflow.com/petriflow.schema.xsd"/>

<!--todo use include after new schema is published-->
<xs:element name="cases">
Copy link
Member

Choose a reason for hiding this comment

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

This schema should be in Petriflow project, and only reference should be here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was meant as a temporary workaround for development purposes, schema will be referenced after updated version is released

- implemented changes requested by PR reviewers
- CaseImportExportController split into 2 separate controller CaseExportController and CaseImportController
- CaseExportFiles refactored to be more readable, added StorageFieldWithFileNames wrapper class
- CaseImportExportProperties renamed to CaseImportProperties and removed redundant nested object
@SamuelPalaj SamuelPalaj requested review from tuplle and Retoocs April 28, 2025 14:36
- refactor of importCasesWithFiles method to get rid of redundant database calls in saveFiles
@Retoocs
Copy link
Contributor

Retoocs commented Apr 30, 2025

For me, this draft PR looks good at the moment. I will come back once the tests and documentation are pushed

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.

3 participants