diff options
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java')
-rw-r--r-- | openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java index 41376b040f..be98d809de 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java @@ -17,10 +17,13 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.notifications.rest.mapping; import com.datastax.driver.core.utils.UUIDs; +import java.text.DateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.sdc.notification.dao.types.NotificationEntity; import org.openecomp.sdc.notification.dtos.NotificationsStatus; @@ -28,37 +31,24 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.notifications.types.NotificationEntityDto; import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto; -import java.text.DateFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +public class MapNotificationsStatusToDto extends MappingBase<NotificationsStatus, NotificationsStatusDto> { -public class MapNotificationsStatusToDto - extends MappingBase<NotificationsStatus, NotificationsStatusDto> { - - private static final DateFormat formatter = - DateFormat.getDateTimeInstance(DateFormat.LONG, - DateFormat.SHORT); + private static final DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT); @Override public void doMapping(NotificationsStatus source, NotificationsStatusDto target) { - target.setLastScanned(source.getLastScanned()); target.setNewEntries(source.getNewEntries()); target.setEndOfPage(source.getEndOfPage()); target.setNumOfNotSeenNotifications(source.getNumOfNotSeenNotifications()); List<NotificationEntityDto> entityDtos = new ArrayList<>(); - source.getNotifications() - .forEach(notification -> entityDtos.add(new NotificationEntityDto(notification.isRead(), - notification.getEventId(), notification.getEventType(), - JsonUtil.json2Object(notification.getEventAttributes(), Map.class), - extractDate(notification)))); + source.getNotifications().forEach(notification -> entityDtos.add( + new NotificationEntityDto(notification.isRead(), notification.getEventId(), notification.getEventType(), + JsonUtil.json2Object(notification.getEventAttributes(), Map.class), extractDate(notification)))); target.setNotifications(entityDtos); } private String extractDate(NotificationEntity notification) { - return formatter.format(UUIDs.unixTimestamp - (notification - .getEventId())); + return formatter.format(UUIDs.unixTimestamp(notification.getEventId())); } } |