use of org.rutebanken.tiamat.model.ValidBetween in project tiamat by entur.
the class ValidityUpdater method terminateVersion.
/**
* Terminate valid between for entity. Typically the old version, or when the entity should be terminated for "good".
*
* @param versionToTerminate the old version of entity to terminate
* @param terminateAt the instant when this version should be terminated
* @param <T> Versioned entity type
* @return the updated entity
*/
public <T extends EntityInVersionStructure> void terminateVersion(T versionToTerminate, Instant terminateAt) {
if (versionToTerminate == null) {
throw new IllegalArgumentException("Cannot terminate version for null object");
}
if (versionToTerminate.getValidBetween() == null) {
logger.warn("Entity {} does not have valid between. Setting toDate.", versionToTerminate.getNetexId());
versionToTerminate.setValidBetween(new ValidBetween(null, terminateAt));
} else if (versionToTerminate.getValidBetween().getToDate() == null) {
// Only terminate if to date not already set.
versionToTerminate.getValidBetween().setToDate(terminateAt);
}
logger.info("Version {} of {} will be invalid at {}", versionToTerminate.getVersion(), versionToTerminate.getNetexId(), terminateAt);
}
Aggregations