Skip to content

Commit

Permalink
Merge pull request #73 from kbss-cvut/fix/fix-publish-updated-record-…
Browse files Browse the repository at this point in the history
…phase

Publish records - fix update phase of published records
  • Loading branch information
blcham authored Oct 8, 2024
2 parents 0a11569 + 509db12 commit 02c59ce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/cz/cvut/kbss/study/model/PatientRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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 02c59ce

Please sign in to comment.