Search in sources :

Example 6 with IntegreradEnhet

use of se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet in project webcert by sklintyg.

the class IntegreradeEnheterRegistryImpl method getIntegreradEnhet.

private IntegreradEnhet getIntegreradEnhet(String enhetsHsaId) {
    IntegreradEnhet enhet = integreradEnhetRepository.findOne(enhetsHsaId);
    if (enhet == null) {
        LOG.debug("Unit {} is not in the registry of integrated units", enhetsHsaId);
        return null;
    }
    // update entity with control date
    enhet.setSenasteKontrollDatum(LocalDateTime.now());
    integreradEnhetRepository.save(enhet);
    return enhet;
}
Also used : IntegreradEnhet(se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet)

Example 7 with IntegreradEnhet

use of se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet in project webcert by sklintyg.

the class IntegreradeEnheterRegistryImpl method deleteIntegreradEnhet.

@Override
@Transactional("jpaTransactionManager")
public void deleteIntegreradEnhet(String enhetsHsaId) {
    IntegreradEnhet unit = integreradEnhetRepository.findOne(enhetsHsaId);
    if (unit != null) {
        integreradEnhetRepository.delete(unit);
        LOG.debug("IntegreradEnhet {} deleted", enhetsHsaId);
    }
}
Also used : IntegreradEnhet(se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with IntegreradEnhet

use of se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet in project webcert by sklintyg.

the class IntegreradeEnheterRegistryImpl method putIntegreradEnhet.

/*
     * (non-Javadoc)
     *
     * @see
     * se.inera.intyg.webcert.web.service.integration.IntegreradeEnheterService#addIfNotExistsIntegreradEnhet(se.inera.
     * intyg.webcert.web
     * .service.integration.dto.IntegreradEnhetEntry)
     */
@Override
@Transactional("jpaTransactionManager")
public void putIntegreradEnhet(IntegreradEnhetEntry entry, boolean schemaVersion1, boolean schemaVersion3) {
    String enhetsId = entry.getEnhetsId();
    IntegreradEnhet intEnhet = integreradEnhetRepository.findOne(enhetsId);
    if (intEnhet != null) {
        LOG.debug("Updating existing integrerad enhet", enhetsId);
        if (schemaVersion1) {
            intEnhet.setSchemaVersion1(schemaVersion1);
        }
        if (schemaVersion3) {
            intEnhet.setSchemaVersion3(schemaVersion3);
        }
    } else {
        intEnhet = new IntegreradEnhet();
        intEnhet.setEnhetsId(enhetsId);
        intEnhet.setEnhetsNamn(entry.getEnhetsNamn());
        intEnhet.setVardgivarId(entry.getVardgivareId());
        intEnhet.setVardgivarNamn(entry.getVardgivareNamn());
        intEnhet.setSchemaVersion1(schemaVersion1);
        intEnhet.setSchemaVersion3(schemaVersion3);
        LOG.debug("Adding unit to registry: {}", intEnhet.toString());
    }
    integreradEnhetRepository.save(intEnhet);
}
Also used : IntegreradEnhet(se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with IntegreradEnhet

use of se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet in project webcert by sklintyg.

the class IntegreradeEnheterBootstrapBeanTest method testInitDataRequiredFields.

@Test
public void testInitDataRequiredFields() {
    bootstrapBean.initData();
    ArgumentCaptor<IntegreradEnhet> enhetCaptor = ArgumentCaptor.forClass(IntegreradEnhet.class);
    verify(integreradEnhetRepository, atLeastOnce()).save(enhetCaptor.capture());
    for (IntegreradEnhet enhet : enhetCaptor.getAllValues()) {
        assertNotNull(enhet.getEnhetsId());
        assertNotNull(enhet.getEnhetsNamn());
        assertNotNull(enhet.getVardgivarId());
        assertNotNull(enhet.getVardgivarNamn());
    }
}
Also used : IntegreradEnhet(se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet) Test(org.junit.Test)

Example 10 with IntegreradEnhet

use of se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet in project webcert by sklintyg.

the class IntegreradeEnheterBootstrapBean method addIntegreradEnhet.

private void addIntegreradEnhet(Resource res) {
    try {
        IntegreradEnhet integreradEnhet = new CustomObjectMapper().readValue(res.getInputStream(), IntegreradEnhet.class);
        integreradEnhet.setSkapadDatum(LocalDateTime.now());
        integreradEnhetRepository.save(integreradEnhet);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : CustomObjectMapper(se.inera.intyg.common.util.integration.json.CustomObjectMapper) IOException(java.io.IOException) IntegreradEnhet(se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet)

Aggregations

IntegreradEnhet (se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet)17 Test (org.junit.Test)12 IntegreradEnhetEntry (se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry)5 Transactional (org.springframework.transaction.annotation.Transactional)3 SchemaVersion (se.inera.intyg.common.support.modules.support.api.notification.SchemaVersion)3 IOException (java.io.IOException)1 CustomObjectMapper (se.inera.intyg.common.util.integration.json.CustomObjectMapper)1