use of org.dcm4chee.arc.store.StoreSession in project dcm4chee-arc-light by dcm4che.
the class RejectionServiceImpl method reject.
@Override
public int reject(ApplicationEntity ae, String aet, String studyIUID, String seriesIUID, String sopIUID, RejectionNote rjNote, HttpServletRequestInfo httpRequest) throws Exception {
String changeRequesterAET = ae.getAEExtension(ArchiveAEExtension.class).changeRequesterAET();
StoreSession storeSession = storeService.newStoreSession(httpRequest, ae, aet, changeRequesterAET != null ? changeRequesterAET : ae.getAETitle());
String rejectionNoteObjectStorageID = rejectionNoteObjectStorageID(storeSession);
storeSession.withObjectStorageID(rejectionNoteObjectStorageID);
storeService.restoreInstances(storeSession, studyIUID, seriesIUID, null);
Attributes attrs = queryService.createRejectionNote(ae, studyIUID, seriesIUID, sopIUID, rjNote);
if (attrs == null)
return 0;
int count = countInstances(attrs);
LOG.info("Start rejection of {} instances of Study[UID={}], Series[UID={}], SOPInstance[UID={}].", count, studyIUID, seriesIUID, sopIUID);
StoreContext storeCtx = storeService.newStoreContext(storeSession);
storeCtx.setReceiveTransferSyntax(UID.ExplicitVRLittleEndian);
storeService.store(storeCtx, attrs);
LOG.info("Rejection of {} instances of Study[UID={}], Series[UID={}], SOPInstance[UID={}] completed.", count, studyIUID, seriesIUID, sopIUID);
return count;
}
use of org.dcm4chee.arc.store.StoreSession in project dcm4chee-arc-light by dcm4che.
the class UPSServiceImpl method onStore.
public void onStore(@Observes StoreContext ctx) {
if (ctx.getStoredInstance() == null || ctx.getException() != null)
return;
StoreSession session = ctx.getStoreSession();
Calendar now = Calendar.getInstance();
ArchiveAEExtension arcAE = session.getArchiveAEExtension();
ArchiveDeviceExtension arcDev = arcAE.getArchiveDeviceExtension();
arcAE.upsOnStoreStream().filter(upsOnStore -> upsOnStore.match(now, session.getRemoteHostName(), session.getCallingAET(), session.getLocalHostName(), session.getCalledAET(), ctx.getAttributes())).forEach(upsOnStore -> createOrUpdateOnStore(arcDev, ctx, now, upsOnStore));
}
use of org.dcm4chee.arc.store.StoreSession in project dcm4chee-arc-light by dcm4che.
the class StoreServiceEJB method applyStudyRetentionPolicy.
private void applyStudyRetentionPolicy(StoreContext ctx, Series series) {
Study study = series.getStudy();
LocalDate studyExpirationDate = study.getExpirationDate();
StoreSession session = ctx.getStoreSession();
ArchiveAEExtension arcAE = session.getArchiveAEExtension();
StudyRetentionPolicy retentionPolicy = arcAE.findStudyRetentionPolicy(session.getRemoteHostName(), session.getCallingAET(), session.getLocalHostName(), session.getCalledAET(), ctx.getAttributes());
if (retentionPolicy != null && retentionPolicy.isFreezeExpirationDate() && retentionPolicy.isRevokeExpiration()) {
LOG.info("Protect Study[UID={}] from being expired, triggered by {}. Set ExpirationDate[=null] and " + "ExpirationState[={FROZEN}].", study.getStudyInstanceUID(), retentionPolicy);
freezeStudyAndItsSeries(series, study, null, "Protect");
return;
}
if (study.getExpirationState() == ExpirationState.FROZEN) {
freezeSeries(series, study, studyExpirationDate, "Freeze");
return;
}
if (retentionPolicy == null)
return;
study.setExpirationExporterID(retentionPolicy.getExporterID());
LocalDate expirationDate = retentionPolicy.expirationDate(ctx.getAttributes());
if (retentionPolicy.isFreezeExpirationDate()) {
LOG.info("Freeze Study[UID={}] with ExpirationDate[={}] and ExpirationState[=FROZEN], triggered by {}", study.getStudyInstanceUID(), expirationDate, retentionPolicy);
freezeStudyAndItsSeries(series, study, expirationDate, "Freeze");
} else {
if (studyExpirationDate == null || studyExpirationDate.compareTo(expirationDate) < 0)
study.setExpirationDate(expirationDate);
if (retentionPolicy.isExpireSeriesIndividually())
series.setExpirationDate(expirationDate);
}
}
use of org.dcm4chee.arc.store.StoreSession in project dcm4chee-arc-light by dcm4che.
the class StoreServiceEJB method updateStudy.
private Study updateStudy(StoreContext ctx, Study study, Date now, String reason) {
StoreSession session = ctx.getStoreSession();
Attributes.UpdatePolicy updatePolicy = study.getRejectionState() == RejectionState.EMPTY ? Attributes.UpdatePolicy.OVERWRITE : session.getStudyUpdatePolicy();
ArchiveDeviceExtension arcDev = getArchiveDeviceExtension();
AttributeFilter filter = arcDev.getAttributeFilter(Entity.Study);
Attributes attrs = study.getAttributes();
UpdateInfo updateInfo = new UpdateInfo(attrs);
Attributes.unifyCharacterSets(attrs, ctx.getAttributes());
if (!attrs.updateSelected(updatePolicy, ctx.getAttributes(), updateInfo.modified, filter.getSelection(false)))
return study;
updateInfo.log(session, study, attrs);
study = em.find(Study.class, study.getPk());
study.setAttributes(recordAttributeModification(ctx) ? attrs.addOriginalAttributes(null, now, reason, device.getDeviceName(), updateInfo.modified) : attrs, filter, true, arcDev.getFuzzyStr());
study.setIssuerOfAccessionNumber(findOrCreateIssuer(attrs, Tag.IssuerOfAccessionNumberSequence));
study.setIssuerOfAdmissionID(findOrCreateIssuer(attrs, Tag.IssuerOfAdmissionIDSequence));
setCodes(study.getProcedureCodes(), attrs, Tag.ProcedureCodeSequence);
em.createNamedQuery(Series.SCHEDULE_METADATA_UPDATE_FOR_STUDY).setParameter(1, study).executeUpdate();
return study;
}
use of org.dcm4chee.arc.store.StoreSession in project dcm4chee-arc-light by dcm4che.
the class StoreServiceEJB method copyLocations.
private void copyLocations(StoreContext ctx, Instance instance, UpdateDBResult result) {
StoreSession session = ctx.getStoreSession();
Map<Long, UIDMap> uidMapCache = session.getUIDMapCache();
Map<String, String> uidMap = session.getUIDMap();
for (Location prevLocation : ctx.getLocations()) {
result.getLocations().add(copyLocation(session, prevLocation, instance, uidMap, uidMapCache));
if (prevLocation.getObjectType() == Location.ObjectType.DICOM_FILE)
instance.getSeries().getStudy().addStorageID(prevLocation.getStorageID());
}
}
Aggregations