Search in sources :

Example 1 with EventLogCategory

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.EventLogCategory in project open-smart-grid-platform by OSGP.

the class FindEventsRequestDataFactory method fromParameterMap.

public static FindEventsRequestData fromParameterMap(final Map<String, String> requestParameters) {
    final EventLogCategory eventLogCategory = EventLogCategory.fromValue(getString(requestParameters, PlatformSmartmeteringKeys.EVENT_TYPE));
    final XMLGregorianCalendar beginDate = createXMLGregorianCalendar(requestParameters, PlatformSmartmeteringKeys.KEY_BEGIN_DATE);
    final XMLGregorianCalendar endDate = createXMLGregorianCalendar(requestParameters, PlatformSmartmeteringKeys.KEY_END_DATE);
    final FindEventsRequestData findEventsRequestData = new FindEventsRequestData();
    findEventsRequestData.setEventLogCategory(eventLogCategory);
    findEventsRequestData.setFrom(beginDate);
    findEventsRequestData.setUntil(endDate);
    return findEventsRequestData;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) FindEventsRequestData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.FindEventsRequestData) EventLogCategory(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.EventLogCategory)

Example 2 with EventLogCategory

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.EventLogCategory 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);
}
Also used : BidirectionalConverter(ma.glasnost.orika.converter.BidirectionalConverter) Logger(org.slf4j.Logger) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) Type(ma.glasnost.orika.metadata.Type) DateTime(org.joda.time.DateTime) LoggerFactory(org.slf4j.LoggerFactory) Event(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.Event) DatatypeFactory(javax.xml.datatype.DatatypeFactory) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Collectors(java.util.stream.Collectors) MappingContext(ma.glasnost.orika.MappingContext) List(java.util.List) EventLogCategory(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.EventLogCategory) EventType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.EventType) EventDetail(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventDetail) Event(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.Event) EventDetail(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventDetail) DateTime(org.joda.time.DateTime)

Aggregations

XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)2 EventLogCategory (org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.EventLogCategory)2 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)1 DatatypeFactory (javax.xml.datatype.DatatypeFactory)1 MappingContext (ma.glasnost.orika.MappingContext)1 BidirectionalConverter (ma.glasnost.orika.converter.BidirectionalConverter)1 Type (ma.glasnost.orika.metadata.Type)1 DateTime (org.joda.time.DateTime)1 EventType (org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.EventType)1 FindEventsRequestData (org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.FindEventsRequestData)1 Event (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.Event)1 EventDetail (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventDetail)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1