Search in sources :

Example 1 with EventType

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventType in project open-smart-grid-platform by OSGP.

the class EventsConverter method convertTo.

@Override
public Event convertTo(final EventDto source, final Type<Event> destinationType, final MappingContext context) {
    if (source == null) {
        return null;
    }
    final EventType eventType = EventType.valueOf(source.getEventTypeDto().name());
    final List<EventDetail> eventDetails = source.getEventDetails().stream().map(sourceDetail -> new EventDetail(sourceDetail.getName(), sourceDetail.getValue())).collect(Collectors.toList());
    return new Event(source.getTimestamp(), eventType, source.getEventCounter(), EventLogCategory.fromValue(source.getEventLogCategoryName()), eventDetails);
}
Also used : BidirectionalConverter(ma.glasnost.orika.converter.BidirectionalConverter) EventLogCategory(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventLogCategory) EventType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventType) List(java.util.List) EventDetailDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDetailDto) Type(ma.glasnost.orika.metadata.Type) EventDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDto) EventDetail(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventDetail) Event(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.Event) EventTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.EventTypeDto) Collectors(java.util.stream.Collectors) MappingContext(ma.glasnost.orika.MappingContext) EventType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventType) Event(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.Event) EventDetail(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventDetail)

Aggregations

List (java.util.List)1 Collectors (java.util.stream.Collectors)1 MappingContext (ma.glasnost.orika.MappingContext)1 BidirectionalConverter (ma.glasnost.orika.converter.BidirectionalConverter)1 Type (ma.glasnost.orika.metadata.Type)1 Event (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.Event)1 EventDetail (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventDetail)1 EventLogCategory (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventLogCategory)1 EventType (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventType)1 EventDetailDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDetailDto)1 EventDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDto)1 EventTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.EventTypeDto)1