Skip to content

Commit

Permalink
External Retrieve AET of Study/Series should be nullified on receive …
Browse files Browse the repository at this point in the history
…of another object of that Study/Series fix #4248

Size of Study/Series is not marked for recalculation on receive of another object of that Study/Series fix #4249
  • Loading branch information
gunterze committed Oct 10, 2023
1 parent b9ab3db commit 953ce46
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@
@NamedQuery(
name=Series.SET_SERIES_SIZE,
query="update Series se set se.size = ?2 where se.pk = ?1"),
@NamedQuery(
name=Series.RESET_SERIES_SIZE_AND_EXTERNAL_RETRIEVE_AET,
query="update Series se set se.size = -1L, se.externalRetrieveAET = null where se.pk = ?1"),
@NamedQuery(
name=Series.SET_COMPLETENESS,
query="update Series ser set ser.completeness = ?3 " +
Expand Down Expand Up @@ -351,6 +354,7 @@ public class Series {
public static final String SERIES_PKS_OF_STUDY_WITH_UNKNOWN_SIZE = "Series.seriesPKsOfStudyWithUnknownSize";
public static final String SIZE_OF_STUDY="Series.sizeOfStudy";
public static final String SET_SERIES_SIZE = "Series.SetSeriesSize";
public static final String RESET_SERIES_SIZE_AND_EXTERNAL_RETRIEVE_AET = "Series.ResetSeriesSizeAndExternalRetrieveAET";
public static final String SET_COMPLETENESS = "Series.SetCompleteness";
public static final String SET_COMPLETENESS_OF_STUDY = "Series.SetCompletenessOfStudy";
public static final String INCREMENT_FAILED_RETRIEVES = "Series.IncrementFailedRetrieves";
Expand Down Expand Up @@ -889,8 +893,16 @@ public void setExternalRetrieveAET(String externalRetrieveAET) {
this.externalRetrieveAET = externalRetrieveAET;
}

public void resetSize() {
public boolean resetExternalRetrieveAET() {
if (externalRetrieveAET == null) return false;
this.externalRetrieveAET = null;
return true;
}

public boolean resetSize() {
if (size == -1) return false;
this.size = -1L;
return true;
}

public long getSize() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
@NamedQuery(
name=Study.SET_STUDY_SIZE,
query="update Study st set st.size = ?2 where st.pk = ?1"),
@NamedQuery(
name=Study.RESET_STUDY_SIZE_AND_EXTERNAL_RETRIEVE_AET,
query="update Study st set st.size = -1L, st.externalRetrieveAET = null where st.pk = ?1"),
@NamedQuery(
name=Study.SET_COMPLETENESS,
query="update Study st set st.completeness = ?2 " +
Expand Down Expand Up @@ -174,6 +177,7 @@ public class Study {
public static final String FIND_BY_STUDY_IUID_EAGER = "Study.findByStudyIUIDEager";
public static final String UPDATE_ACCESS_TIME = "Study.UpdateAccessTime";
public static final String SET_STUDY_SIZE = "Study.setStudySize";
public static final String RESET_STUDY_SIZE_AND_EXTERNAL_RETRIEVE_AET = "Study.resetStudySizeAndExternalRetrieve";
public static final String SET_COMPLETENESS = "Study.setCompleteness";
public static final String INCREMENT_FAILED_RETRIEVES = "Study.incrementFailedRetrieves";
public static final String COUNT_STUDIES_OF_PATIENT = "Study.countStudiesOfPatient";
Expand Down Expand Up @@ -596,8 +600,16 @@ public void setExternalRetrieveAET(String externalRetrieveAET) {
this.externalRetrieveAET = externalRetrieveAET;
}

public void resetSize() {
public boolean resetExternalRetrieveAET() {
if (externalRetrieveAET == null) return false;
this.externalRetrieveAET = null;
return true;
}

public boolean resetSize() {
if (size == -1) return false;
this.size = -1L;
return true;
}

public Collection<CodeEntity> getProcedureCodes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ && getRejectionNote(arcDev, prevInstance.getConceptNameCode()) != null) {
deleteQueryAttributes(instance);
Series series = instance.getSeries();
Study study = series.getStudy();
study.resetSize();
if (replaceLocationOnDifferentStorage) {
String prevStorageIDs = study.getEncodedStorageIDs();
study.setStorageIDs(queryStorageIDsOfStudy(study).toArray(StringUtils.EMPTY_STRING));
Expand Down Expand Up @@ -1018,8 +1017,10 @@ private Study updateStudy(StoreContext ctx, Study study, Date now, String reason
updated = attrs.updateSelected(updatePolicy,
ctx.getAttributes(), updateInfo.modified, filter.getSelection(false))
|| updated;
if (!updated)
if (!updated) {
resetStudySizeAndExternalRetrieveAET(study);
return study;
}

updateInfo.log(session, study, attrs);
study = em.find(Study.class, study.getPk());
Expand All @@ -1031,9 +1032,20 @@ private Study updateStudy(StoreContext ctx, Study study, Date now, String reason
em.createNamedQuery(Series.SCHEDULE_METADATA_UPDATE_FOR_STUDY)
.setParameter(1, study)
.executeUpdate();
study.resetSize();
study.resetExternalRetrieveAET();
return study;
}

private void resetStudySizeAndExternalRetrieveAET(Study study) {
boolean resetSize = study.resetSize();
boolean resetExternalRetrieveAET = study.resetExternalRetrieveAET();
if (resetSize || resetExternalRetrieveAET) {
em.createNamedQuery(Study.RESET_STUDY_SIZE_AND_EXTERNAL_RETRIEVE_AET)
.setParameter(1, study.getPk());
}
}

private boolean supplementIssuer(Attributes attrs, Attributes newAttrs, Attributes modified,
int idtag, int seqtag) {
String id = attrs.getString(idtag);
Expand Down Expand Up @@ -1070,8 +1082,10 @@ private Series updateSeries(StoreContext ctx, Series series, Date now, String re
Attributes attrs = series.getAttributes();
UpdateInfo updateInfo = new UpdateInfo(attrs);
Attributes.unifyCharacterSets(attrs, ctx.getAttributes());
if (!attrs.updateSelected(updatePolicy, ctx.getAttributes(), updateInfo.modified, filter.getSelection(false)))
if (!attrs.updateSelected(updatePolicy, ctx.getAttributes(), updateInfo.modified, filter.getSelection(false))) {
resetSeriesSizeAndExternalRetrieveAET(series);
return series;
}

updateInfo.log(session, series, attrs);
series = em.find(Series.class, series.getPk());
Expand All @@ -1083,9 +1097,20 @@ private Series updateSeries(StoreContext ctx, Series series, Date now, String re
series.setInstitutionCode(findOrCreateCode(attrs, Tag.InstitutionCodeSequence));
series.setInstitutionalDepartmentTypeCode(findOrCreateCode(attrs, Tag.InstitutionalDepartmentTypeCodeSequence));
setRequestAttributes(series, attrs, fuzzyStr);
series.resetSize();
series.resetExternalRetrieveAET();
return series;
}

private void resetSeriesSizeAndExternalRetrieveAET(Series series) {
boolean resetSize = series.resetSize();
boolean resetExternalRetrieveAET = series.resetExternalRetrieveAET();
if (resetSize || resetExternalRetrieveAET) {
em.createNamedQuery(Series.RESET_SERIES_SIZE_AND_EXTERNAL_RETRIEVE_AET)
.setParameter(1, series.getPk());
}
}

public void replaceLocation(StoreContext ctx, InstanceLocations inst) {
Instance instance = new Instance();
instance.setPk(inst.getInstancePk());
Expand Down

0 comments on commit 953ce46

Please sign in to comment.