-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update event status update * update * auto patch increment * Removing intermediate status in progress Co-authored-by: ras-rm-pr-bot <[email protected]>
- Loading branch information
1 parent
c022c21
commit 0b37d70
Showing
16 changed files
with
402 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...va/uk/gov/ons/ctp/response/collection/exercise/message/CaseActionEventStatusReceiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package uk.gov.ons.ctp.response.collection.exercise.message; | ||
|
||
import static net.logstash.logback.argument.StructuredArguments.kv; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.godaddy.logging.Logger; | ||
import com.godaddy.logging.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.cloud.gcp.pubsub.support.BasicAcknowledgeablePubsubMessage; | ||
import org.springframework.cloud.gcp.pubsub.support.GcpPubSubHeaders; | ||
import org.springframework.integration.annotation.ServiceActivator; | ||
import org.springframework.messaging.Message; | ||
import org.springframework.messaging.handler.annotation.Header; | ||
import org.springframework.stereotype.Component; | ||
import uk.gov.ons.ctp.response.collection.exercise.message.dto.CaseActionEventStatusDTO; | ||
import uk.gov.ons.ctp.response.collection.exercise.service.EventService; | ||
|
||
@Component | ||
public class CaseActionEventStatusReceiver { | ||
private static final Logger log = LoggerFactory.getLogger(CaseActionEventStatusReceiver.class); | ||
@Autowired private ObjectMapper objectMapper; | ||
@Autowired private EventService eventService; | ||
|
||
@ServiceActivator(inputChannel = "collectionExerciseEventStatusUpdateChannel") | ||
public void messageReceiver( | ||
Message message, | ||
@Header(GcpPubSubHeaders.ORIGINAL_MESSAGE) BasicAcknowledgeablePubsubMessage pubSubMsg) { | ||
log.info( | ||
"Receiving message ID from PubSub", | ||
kv("messageId", pubSubMsg.getPubsubMessage().getMessageId())); | ||
String payload = new String((byte[]) message.getPayload()); | ||
log.with("payload", payload).info("New request to update case action event status"); | ||
try { | ||
log.info("Mapping payload to CaseActionEventStatus object"); | ||
CaseActionEventStatusDTO eventStatus = | ||
objectMapper.readValue(payload, CaseActionEventStatusDTO.class); | ||
log.info("Mapping successful, accepting action case notification"); | ||
eventService.updateEventStatus(eventStatus); | ||
pubSubMsg.ack(); | ||
} catch (JsonProcessingException e) { | ||
log.with(e) | ||
.error( | ||
"Something went wrong while processing message received from PubSub for updating action event status", | ||
e); | ||
pubSubMsg.nack(); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...ava/uk/gov/ons/ctp/response/collection/exercise/message/dto/CaseActionEventStatusDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package uk.gov.ons.ctp.response.collection.exercise.message.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import java.util.UUID; | ||
import javax.validation.constraints.NotNull; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import uk.gov.ons.ctp.response.collection.exercise.representation.EventDTO; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PUBLIC) | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class CaseActionEventStatusDTO { | ||
public enum EventTag { | ||
mps, | ||
go_live, | ||
reminder, | ||
reminder2, | ||
reminder3, | ||
nudge_email_0, | ||
nudge_email_1, | ||
nudge_email_2, | ||
nudge_email_3, | ||
nudge_email_4 | ||
} | ||
|
||
@NotNull private UUID collectionExerciseID; | ||
@NotNull private EventTag tag; | ||
@NotNull private EventDTO.Status status; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.