Skip to content

Commit

Permalink
Merge pull request #89 from usdot-jpo-ode/map-deduplicator-fix
Browse files Browse the repository at this point in the history
Updated Timestamps in ProcessedMaps
  • Loading branch information
John-Wiens authored May 22, 2024
2 parents 5289805 + 24b0559 commit 83d1afe
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.ObjectMapper;


import java.time.Duration;
import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Properties;
import java.util.Objects;

public class ProcessedMapDeduplicatorTopology {

Expand Down Expand Up @@ -70,8 +72,8 @@ public Topology buildTopology() {
return new ProcessedMapPair(newValue, true );
}

Instant newValueTime = newValue.getProperties().getTimeStamp().toInstant();
Instant oldValueTime = aggregate.getMessage().getProperties().getTimeStamp().toInstant();
Instant newValueTime = newValue.getProperties().getOdeReceivedAt().toInstant();
Instant oldValueTime = aggregate.getMessage().getProperties().getOdeReceivedAt().toInstant();

if(newValueTime.minus(Duration.ofHours(1)).isAfter(oldValueTime)){
return new ProcessedMapPair(newValue, true );
Expand All @@ -82,10 +84,12 @@ public Topology buildTopology() {
newValue.getProperties().setTimeStamp(aggregate.getMessage().getProperties().getTimeStamp());
newValue.getProperties().setOdeReceivedAt(aggregate.getMessage().getProperties().getOdeReceivedAt());

int oldHash = aggregate.getMessage().getProperties().hashCode();
int newhash = newValue.getProperties().hashCode();
// int oldHash = aggregate.getMessage().getProperties().hashCode();
// int newhash = newValue.getProperties().hashCode();
int oldHash = Objects.hash(aggregate.getMessage().toString());
int newHash = Objects.hash(newValue.toString());

if(oldHash != newhash){
if(oldHash != newHash){
newValue.getProperties().setTimeStamp(newValueTimestamp);
newValue.getProperties().setOdeReceivedAt(newValueOdeReceivedAt);
return new ProcessedMapPair(newValue, true);
Expand Down

0 comments on commit 83d1afe

Please sign in to comment.