diff --git a/src/main/java/org/nrg/containers/model/container/auto/Container.java b/src/main/java/org/nrg/containers/model/container/auto/Container.java index 34b69afc7..b12ad82d7 100644 --- a/src/main/java/org/nrg/containers/model/container/auto/Container.java +++ b/src/main/java/org/nrg/containers/model/container/auto/Container.java @@ -802,7 +802,7 @@ public static ContainerHistory fromSystem(final String status, .entityType("system") .entityId(null) .timeRecorded(new Date()) - .externalTimestamp(Long.toString(System.nanoTime())) + .externalTimestamp(null) .build(); } @@ -812,7 +812,7 @@ public static ContainerHistory fromUserAction(final String status, final String .entityType("user") .entityId(username) .timeRecorded(new Date()) - .externalTimestamp(Long.toString(System.nanoTime())) + .externalTimestamp(null) .message(null) .build(); } diff --git a/src/main/java/org/nrg/containers/model/container/entity/ContainerEntity.java b/src/main/java/org/nrg/containers/model/container/entity/ContainerEntity.java index e4fd4ab57..50083cb03 100644 --- a/src/main/java/org/nrg/containers/model/container/entity/ContainerEntity.java +++ b/src/main/java/org/nrg/containers/model/container/entity/ContainerEntity.java @@ -529,26 +529,8 @@ public boolean isItemInHistory(final ContainerEntityHistory historyItem) { historyItem.setContainerEntity(this); - boolean match=false; - Collections.sort(history); - for (ContainerEntityHistory hist : history) { - log.debug("isItemInHistory items {} {} {}",hist.getContainerEntity().getId(),hist.getStatus(),hist.getTimeRecorded()); - } - if(history.size()>0){ - ContainerEntityHistory latest=history.get(0); - match= StringUtils.equals(latest.getStatus(),historyItem.getStatus()); - if(log.isDebugEnabled()){ - log.debug("isItemInHistory skip {} {} {} {} {} {} {}", - match, - historyItem.getContainerEntity().getId(), - latest.getContainerEntity().getId(), - historyItem.getStatus(), - latest.getStatus(), - historyItem.getTimeRecorded(), - latest.getTimeRecorded()); - } - } - return match; + return this.history.contains(historyItem); + } diff --git a/src/main/java/org/nrg/containers/model/container/entity/ContainerEntityHistory.java b/src/main/java/org/nrg/containers/model/container/entity/ContainerEntityHistory.java index c0bcb5521..cf8e87b20 100644 --- a/src/main/java/org/nrg/containers/model/container/entity/ContainerEntityHistory.java +++ b/src/main/java/org/nrg/containers/model/container/entity/ContainerEntityHistory.java @@ -21,7 +21,7 @@ @Slf4j @Entity @Audited -public class ContainerEntityHistory implements Comparable{ +public class ContainerEntityHistory { private long id; @JsonIgnore private ContainerEntity containerEntity; private String status; @@ -192,9 +192,4 @@ public String toString() { .add("exitCode", exitCode) .toString(); } - - @Override - public int compareTo(ContainerEntityHistory o) { - return o.timeRecorded.compareTo(this.timeRecorded); - } }