Skip to content
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

(POC) Rethinking type_owners table #14

Merged
merged 14 commits into from
Oct 12, 2022
Merged

(POC) Rethinking type_owners table #14

merged 14 commits into from
Oct 12, 2022

Conversation

vbarduk
Copy link
Collaborator

@vbarduk vbarduk commented Oct 5, 2022

Create new table omni_type instead of type_owners
Add new endpoints:
-POST /queue/omni-type - Create omni type
-PUT /queue/omni-type/{id} - Update omni type
-DELETE /queue/omni-type/{id} - Delete omni type
-GET /queue/omni-types - Get all omni types

Add tests

Create new table omni_type instead of type_owners
Add new endpoints:
-POST /queue/omni-type - Create omni type
-PUT /queue/omni-type/{id} - Update omni type
-DELETE /queue/omni-type/{id} - Delete omni type
-GET /queue/omni-types - Get all omni types

Add tests
@vbarduk vbarduk changed the title fixing #13 (POC) Rethinking type_owners table Oct 5, 2022

public void deleteOmniTypeById(Long id) {
log.info("Delete omni type by data type [{}]", id);
omniTypeRepository.deleteById(id);
Copy link
Contributor

Choose a reason for hiding this comment

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

pls check if it's exist or throw notFoundException

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done


Long id;
String dataType;
String meta;
Copy link
Contributor

Choose a reason for hiding this comment

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

what format of data we will store in metadata? I thought it will be Map<String, Object> meta and json in db

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

let's start with String and once we need to implement specific logic, we can change it

- integrate OmniType with Omni in TestDataStorageService
- update migration
- update tests
- remove purgeAllData
Comment on lines 14 to 18
Long id;
String dataType;
String meta;
LocalDateTime created;
LocalDateTime updated;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Long id;
String dataType;
String meta;
LocalDateTime created;
LocalDateTime updated;
private Long id;
private String dataType;
private String meta;
private LocalDateTime created;
private LocalDateTime updated;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -14,14 +16,24 @@
@RequiredArgsConstructor
Copy link
Contributor

Choose a reason for hiding this comment

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

constructor not needed here since all methods are static
the class can be marked as @UtilityClass

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

var omniType = getOmniTypeIfExists(dataType);
var omni = Omni.builder()
.data(data)
.omniType(omniType)
.archived(false)
.created(LocalDateTime.now())
Copy link
Contributor

Choose a reason for hiding this comment

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

a point for future improvement - created can be set automatically by Jpa audit

var omnis = omniRepository.findAllByOmniTypeAndCreatedBefore(omniType, archiveOmniDTO.getCreatedBefore());
if (!omnis.isEmpty()) {
omnis.forEach(omni -> {
omni.setUpdated(LocalDateTime.now());
Copy link
Contributor

Choose a reason for hiding this comment

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

same - updated can be set by @ModifiedDate and JPA audit

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

#16 issue created

make EntityMapper annotated with UtilityClass
@@ -1,15 +1,12 @@
package com.auto1.testdatastorage.service;
Copy link
Contributor

Choose a reason for hiding this comment

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

there should be 2 separate service classes:

  • OmniQueueItemService
  • OmniTypeService

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok, will do separation

separate TestDataStorageController to OmniQueueController.java and OmniTypeController.java
@vbarduk vbarduk merged commit c7d129b into main Oct 12, 2022
@vbarduk vbarduk deleted the Rethinking_type_owners branch October 12, 2022 13:54
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.

4 participants