Skip to content

Commit

Permalink
fix. oppdater status på alle prosesseringer før prosessering
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikv committed Dec 13, 2024
1 parent 9d313d7 commit 9b9353e
Showing 1 changed file with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import lombok.extern.slf4j.Slf4j;
import no.nav.tag.tiltaksgjennomforing.arena.models.migration.ArenaAgreementAggregate;
import no.nav.tag.tiltaksgjennomforing.arena.models.migration.ArenaAgreementMigration;
import no.nav.tag.tiltaksgjennomforing.arena.models.migration.ArenaAgreementMigrationStatus;
import no.nav.tag.tiltaksgjennomforing.arena.repository.ArenaAgreementMigrationRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
Expand All @@ -15,15 +19,31 @@ public class ArenaAgreementService {
private final ArenaAgreementMigrationRepository arenaAgreementMigrationRepository;

public ArenaAgreementService(
ArenaAgreementProcessingService arenaAgreementProcessingService,
ArenaAgreementMigrationRepository arenaAgreementMigrationRepository
ArenaAgreementProcessingService arenaAgreementProcessingService,
ArenaAgreementMigrationRepository arenaAgreementMigrationRepository
) {
this.arenaAgreementProcessingService = arenaAgreementProcessingService;
this.arenaAgreementMigrationRepository = arenaAgreementMigrationRepository;
}

@Transactional
public List<ArenaAgreementAggregate> getArenaAgreementsForProcessing() {
return arenaAgreementMigrationRepository.findMigrationAgreementAggregates();
List<ArenaAgreementAggregate> agreementAggregates = arenaAgreementMigrationRepository.findMigrationAgreementAggregates();

arenaAgreementMigrationRepository.saveAll(
agreementAggregates
.stream()
.map(aggregate ->
ArenaAgreementMigration.builder()
.tiltakgjennomforingId(aggregate.getTiltakgjennomforingId())
.status(ArenaAgreementMigrationStatus.PROCESSING)
.modified(LocalDateTime.now())
.build()
)
.toList()
);

return agreementAggregates;
}

public void processAgreements(List<ArenaAgreementAggregate> agreements) {
Expand Down

0 comments on commit 9b9353e

Please sign in to comment.