-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #3221: Use separate entity classes for user notifications
- Loading branch information
Showing
16 changed files
with
168 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
api/src/main/java/com/epam/pipeline/mapper/notification/UserNotificationMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.epam.pipeline.mapper.notification; | ||
|
||
import com.epam.pipeline.dto.notification.UserNotification; | ||
import com.epam.pipeline.dto.notification.UserNotificationResource; | ||
import com.epam.pipeline.entity.notification.UserNotificationEntity; | ||
import com.epam.pipeline.entity.notification.UserNotificationResourceEntity; | ||
import org.apache.commons.collections4.ListUtils; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
@Mapper(componentModel = "spring") | ||
public interface UserNotificationMapper { | ||
|
||
UserNotificationEntity toEntity(UserNotification dto); | ||
|
||
@Mapping(target = "notification", ignore = true) | ||
UserNotificationResourceEntity toEntity(UserNotificationResource dto); | ||
|
||
default UserNotification toDto(UserNotificationEntity entity) { | ||
return new UserNotification(entity.getId(), entity.getType(), entity.getUserId(), entity.getSubject(), | ||
entity.getText(), entity.getCreatedDate(), entity.getIsRead(), entity.getReadDate(), | ||
ListUtils.emptyIfNull(entity.getResources()).stream() | ||
.map(this::toDto) | ||
.collect(Collectors.toList())); | ||
} | ||
|
||
default UserNotificationResource toDto(UserNotificationResourceEntity entity) { | ||
return new UserNotificationResource(entity.getId(), entity.getEntityClass(), entity.getEntityId(), | ||
entity.getStoragePath(), entity.getStorageRuleId()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.