diff options
Diffstat (limited to 'cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsCreator.java')
-rw-r--r-- | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsCreator.java | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsCreator.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsCreator.java index 783b29951..085494aef 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsCreator.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsCreator.java @@ -20,14 +20,11 @@ package org.onap.cps.ncmp.api.impl.event.lcm; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.util.List; import java.util.UUID; import lombok.extern.slf4j.Slf4j; -import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle; -import org.onap.ncmp.cmhandle.lcm.event.Event; -import org.onap.ncmp.cmhandle.lcm.event.NcmpEvent; +import org.onap.cps.ncmp.api.impl.utils.EventDateTimeFormatter; +import org.onap.ncmp.cmhandle.event.lcm.Event; +import org.onap.ncmp.cmhandle.event.lcm.LcmEvent; import org.springframework.stereotype.Component; @@ -38,42 +35,38 @@ import org.springframework.stereotype.Component; @Component public class LcmEventsCreator { - /** - * Populate NcmpEvent. + * Populate LcmEvent. * - * @param cmHandleId Cm Handle Identifier - * @param ncmpServiceCmHandle Ncmp CmHandle Data - * @return Populated NcmpEvent + * @param cmHandleId Cm Handle Identifier + * @return Populated Lcm Event */ - public NcmpEvent populateLcmEvent(final String cmHandleId, final NcmpServiceCmHandle ncmpServiceCmHandle) { - return createLcmEvent(cmHandleId, ncmpServiceCmHandle); + public LcmEvent populateLcmEvent(final String cmHandleId) { + return createLcmEvent(cmHandleId); } - private NcmpEvent createLcmEvent(final String cmHandleId, final NcmpServiceCmHandle ncmpServiceCmHandle) { - final NcmpEvent ncmpEvent = lcmEventHeader(cmHandleId); - ncmpEvent.setEvent(lcmEventPayload(cmHandleId, ncmpServiceCmHandle)); - return ncmpEvent; + private LcmEvent createLcmEvent(final String cmHandleId) { + final LcmEvent lcmEvent = lcmEventHeader(cmHandleId); + lcmEvent.setEvent(lcmEventPayload(cmHandleId)); + return lcmEvent; } - private Event lcmEventPayload(final String eventCorrelationId, final NcmpServiceCmHandle ncmpServiceCmHandle) { + private Event lcmEventPayload(final String eventCorrelationId) { final Event event = new Event(); event.setCmHandleId(eventCorrelationId); - event.setCmhandleState( - Event.CmhandleState.fromValue(ncmpServiceCmHandle.getCompositeState().getCmHandleState().toString())); - event.setCmhandleProperties(List.of(ncmpServiceCmHandle.getPublicProperties())); return event; } - private NcmpEvent lcmEventHeader(final String eventCorrelationId) { - final NcmpEvent ncmpEvent = new NcmpEvent(); - ncmpEvent.setEventId(UUID.randomUUID().toString()); - ncmpEvent.setEventCorrelationId(eventCorrelationId); - ncmpEvent.setEventTime(ZonedDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ"))); - ncmpEvent.setEventSource("org.onap.ncmp"); - ncmpEvent.setEventType("org.onap.ncmp.cmhandle-lcm-event"); - ncmpEvent.setEventSchema("org.onap.ncmp:cmhandle-lcm-event:v1"); - return ncmpEvent; + private LcmEvent lcmEventHeader(final String eventCorrelationId) { + final LcmEvent lcmEvent = new LcmEvent(); + lcmEvent.setEventId(UUID.randomUUID().toString()); + lcmEvent.setEventCorrelationId(eventCorrelationId); + lcmEvent.setEventTime(EventDateTimeFormatter.getCurrentDateTime()); + lcmEvent.setEventSource("org.onap.ncmp"); + lcmEvent.setEventType("org.onap.ncmp.cmhandle-lcm-event"); + lcmEvent.setEventSchema("org.onap.ncmp:cmhandle-lcm-event"); + lcmEvent.setEventSchemaVersion("v1"); + return lcmEvent; } } |