use of ma.glasnost.orika.metadata.Type 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);
}
use of ma.glasnost.orika.metadata.Type in project open-smart-grid-platform by OSGP.
the class EventConverter method convertFrom.
@Override
public Event convertFrom(final org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.Event source, final Type<Event> destinationType, final MappingContext context) {
if (source == null) {
return null;
}
final DateTime timestamp = new DateTime(source.getTimestamp().toGregorianCalendar().getTime());
final org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventLogCategory eventLogCategory = org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventLogCategory.fromValue(source.getEventLogCategory().value());
final org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventType eventType = org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventType.fromValue(source.getEventType().value());
final List<EventDetail> eventDetails = source.getEventDetails().stream().map(sourceEventDetail -> new EventDetail(sourceEventDetail.getName(), sourceEventDetail.getValue())).collect(Collectors.toList());
return new Event(timestamp, eventType, source.getEventCounter(), eventLogCategory, eventDetails);
}
Aggregations