Search in sources :

Example 66 with ValidBetween

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);
}
Also used : ValidBetween(org.rutebanken.tiamat.model.ValidBetween)

Aggregations

ValidBetween (org.rutebanken.tiamat.model.ValidBetween)66 StopPlace (org.rutebanken.tiamat.model.StopPlace)57 Test (org.junit.Test)56 TiamatIntegrationTest (org.rutebanken.tiamat.TiamatIntegrationTest)56 EmbeddableMultilingualString (org.rutebanken.tiamat.model.EmbeddableMultilingualString)38 Instant (java.time.Instant)33 StopPlaceSearch (org.rutebanken.tiamat.exporter.params.StopPlaceSearch)17 SiteRefStructure (org.rutebanken.tiamat.model.SiteRefStructure)14 ChangedStopPlaceSearch (org.rutebanken.tiamat.repository.search.ChangedStopPlaceSearch)12 ExportParams (org.rutebanken.tiamat.exporter.params.ExportParams)11 Quay (org.rutebanken.tiamat.model.Quay)11 List (java.util.List)9 Coordinate (org.locationtech.jts.geom.Coordinate)9 TopographicPlace (org.rutebanken.tiamat.model.TopographicPlace)9 Pageable (org.springframework.data.domain.Pageable)9 Autowired (org.springframework.beans.factory.annotation.Autowired)8 Arrays (java.util.Arrays)7 Set (java.util.Set)7 IdMappingDto (org.rutebanken.tiamat.dtoassembling.dto.IdMappingDto)7 Value (org.rutebanken.tiamat.model.Value)7