-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OY-798 Migroidaan laskentakaavat jsonb:ksi inkrementaalisesti
- Loading branch information
Showing
15 changed files
with
187 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...et-domain/src/main/java/fi/vm/sade/service/valintaperusteet/model/EntityManagerUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package fi.vm.sade.service.valintaperusteet.model; | ||
|
||
import jakarta.persistence.EntityManager; | ||
|
||
public class EntityManagerUtils { | ||
|
||
private static EntityManager em; | ||
|
||
public static void setEntityManager(EntityManager em) { | ||
EntityManagerUtils.em = em; | ||
} | ||
|
||
public static EntityManager getEntityManager() { | ||
return em; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
.../src/main/java/fi/vm/sade/service/valintaperusteet/config/EntityManagerConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package fi.vm.sade.service.valintaperusteet.config; | ||
|
||
import fi.vm.sade.service.valintaperusteet.model.EntityManagerUtils; | ||
import jakarta.persistence.EntityManager; | ||
import org.springframework.beans.factory.InitializingBean; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class EntityManagerConfiguration implements InitializingBean { | ||
|
||
@Autowired private EntityManager entityManager; | ||
|
||
public void afterPropertiesSet() throws Exception { | ||
EntityManagerUtils.setEntityManager(this.entityManager); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...fi/vm/sade/service/valintaperusteet/service/background/LaskentaKaavaMigrationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package fi.vm.sade.service.valintaperusteet.service.background; | ||
|
||
import fi.vm.sade.service.valintaperusteet.dao.LaskentakaavaDAO; | ||
import fi.vm.sade.service.valintaperusteet.dto.mapping.ValintaperusteetModelMapper; | ||
import fi.vm.sade.service.valintaperusteet.service.LaskentakaavaService; | ||
import java.time.Duration; | ||
import java.time.Instant; | ||
import java.util.concurrent.TimeUnit; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Component | ||
public class LaskentaKaavaMigrationService { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(LaskentaKaavaMigrationService.class); | ||
|
||
@Autowired private LaskentakaavaService laskentakaavaService; | ||
|
||
@Autowired private LaskentakaavaDAO laskentakaavaDAO; | ||
|
||
@Autowired private ValintaperusteetModelMapper modelMapper; | ||
|
||
@Scheduled(initialDelay = 5, fixedDelay = 50, timeUnit = TimeUnit.MILLISECONDS) | ||
@Transactional | ||
public void migrateLaskentakaavat() { | ||
Instant start = Instant.now(); | ||
|
||
laskentakaavaDAO.migrateLaskentakaavat(1); | ||
|
||
LOG.warn( | ||
"Saved laskentakaavat, duration: " + Duration.between(start, Instant.now()).toMillis()); | ||
} | ||
} |