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;
}
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);
}
}
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);
}
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());
}
}
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);
}
}
Aggregations