diff options
author | vasraz <vasyl.razinkov@est.tech> | 2021-03-22 15:33:06 +0000 |
---|---|---|
committer | Christophe Closset <christophe.closset@intl.att.com> | 2021-03-24 06:59:47 +0000 |
commit | d378c37fbd1ecec7b43394926f1ca32a695e07de (patch) | |
tree | 5c8a085f8732f980d871d966ac49361644efa698 /openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java | |
parent | a6ae7294ecd336d7e88f915710b08e2658eaee00 (diff) |
Reformat openecomp-be
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Issue-ID: SDC-3449
Change-Id: I13e02322f8e00820cc5a1d85752caaeda9bf10d1
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.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/MapNotificationsToDto.java | 28 |
1 files changed, 12 insertions, 16 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/MapNotificationsToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java index 558453b7b6..a42f5f98da 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.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.apache.commons.collections4.CollectionUtils; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.sdc.notification.dao.types.NotificationEntity; @@ -28,30 +31,23 @@ 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 MapNotificationsToDto extends MappingBase<List<NotificationEntity>, 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(List<NotificationEntity> source, NotificationsStatusDto target) { List<NotificationEntityDto> entityDtos = new ArrayList<>(); - if(CollectionUtils.isNotEmpty(source)) { - source.forEach(notification -> entityDtos.add(new NotificationEntityDto(notification.isRead(), - notification.getEventId(), notification.getEventType(), JsonUtil.json2Object(notification.getEventAttributes(), Map.class), - extractDate(notification)))); + if (CollectionUtils.isNotEmpty(source)) { + source.forEach(notification -> entityDtos.add( + new NotificationEntityDto(notification.isRead(), notification.getEventId(), notification.getEventType(), + JsonUtil.json2Object(notification.getEventAttributes(), Map.class), extractDate(notification)))); target.setNotifications(entityDtos); target.setLastScanned(source.get(0).getEventId()); } } private String extractDate(NotificationEntity notification) { - return formatter.format(UUIDs.unixTimestamp - (notification - .getEventId())); + return formatter.format(UUIDs.unixTimestamp(notification.getEventId())); } } |