diff --git a/src/main/java/cz/cvut/kbss/study/model/PatientRecord.java b/src/main/java/cz/cvut/kbss/study/model/PatientRecord.java index 52d37dd5..3184e3d9 100644 --- a/src/main/java/cz/cvut/kbss/study/model/PatientRecord.java +++ b/src/main/java/cz/cvut/kbss/study/model/PatientRecord.java @@ -56,7 +56,7 @@ public class PatientRecord implements Serializable, HasOwlKey, HasUri { private Question question; @Enumerated(EnumType.OBJECT_ONE_OF) - @OWLObjectProperty(iri = Vocabulary.s_p_has_phase) + @OWLObjectProperty(iri = Vocabulary.s_p_has_phase, cascade = {CascadeType.MERGE}, fetch = FetchType.EAGER) private RecordPhase phase; @Override diff --git a/src/main/java/cz/cvut/kbss/study/persistence/dao/PatientRecordDao.java b/src/main/java/cz/cvut/kbss/study/persistence/dao/PatientRecordDao.java index a61e42e5..de50e67c 100644 --- a/src/main/java/cz/cvut/kbss/study/persistence/dao/PatientRecordDao.java +++ b/src/main/java/cz/cvut/kbss/study/persistence/dao/PatientRecordDao.java @@ -113,6 +113,15 @@ public void update(PatientRecord entity) { em.getEntityManagerFactory().getCache().evict(PatientRecordDto.class, entity.getUri(), null); } + public void updateStatus(URI entityUri, RecordPhase targetPhase){ + PatientRecord entity = find(entityUri); + if(entity == null) + return; + entity.setPhase(targetPhase); + em.getEntityManagerFactory().getCache().evict(PatientRecord.class, entity.getUri(), null); + em.getEntityManagerFactory().getCache().evict(PatientRecordDto.class, entity.getUri(), null); + } + public List findAllRecords() { return em.createNativeQuery("SELECT ?x WHERE { ?x a ?type . }", PatientRecordDto.class) .setParameter("type", typeUri) diff --git a/src/main/java/cz/cvut/kbss/study/service/repository/RepositoryPatientRecordService.java b/src/main/java/cz/cvut/kbss/study/service/repository/RepositoryPatientRecordService.java index 0efdba85..896c5c4a 100644 --- a/src/main/java/cz/cvut/kbss/study/service/repository/RepositoryPatientRecordService.java +++ b/src/main/java/cz/cvut/kbss/study/service/repository/RepositoryPatientRecordService.java @@ -123,10 +123,7 @@ private void setImportedRecordProvenance(User currentUser, Date now, Optional recordUris, RecordPhase targetPhase){ for(String uri : recordUris){ - PatientRecord record = find(URI.create(uri)); - if (record == null) - continue; - record.setPhase(targetPhase); + patientRecordDao.updateStatus(URI.create(uri), targetPhase); } }