Skip to content

Commit

Permalink
[Fix partially kbss-cvut/record-manager-ui#207] publih records - prop…
Browse files Browse the repository at this point in the history
…erly update published record phase so that cache is cleared
  • Loading branch information
kostobog committed Oct 4, 2024
1 parent 1fe6ce2 commit 509db12
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<PatientRecordDto> findAllRecords() {
return em.createNativeQuery("SELECT ?x WHERE { ?x a ?type . }", PatientRecordDto.class)
.setParameter("type", typeUri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,7 @@ private void setImportedRecordProvenance(User currentUser, Date now, Optional<Re
@Override
public void setPhase(Set<String> 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);
}
}

Expand Down

0 comments on commit 509db12

Please sign in to comment.