Search in sources :

Example 1 with QueryAttributes

use of org.dcm4chee.arc.query.util.QueryAttributes in project dcm4chee-arc-light by dcm4che.

the class UPSServiceImpl method queryKeysUPSNotCompleted.

private static Attributes queryKeysUPSNotCompleted(String refStudyIUID, String queryString) {
    Attributes keys = new QueryAttributes(QueryAttributes.parseQueryString(queryString), null).getQueryKeys();
    Attributes item = new Attributes(1);
    item.setString(Tag.StudyInstanceUID, VR.UI, refStudyIUID);
    keys.newSequence(Tag.ReferencedRequestSequence, 1).add(item);
    keys.setString(Tag.ProcedureStepState, VR.CS, "SCHEDULED", "IN PROGRESS", "CANCELED");
    return keys;
}
Also used : QueryAttributes(org.dcm4chee.arc.query.util.QueryAttributes) QueryAttributes(org.dcm4chee.arc.query.util.QueryAttributes)

Example 2 with QueryAttributes

use of org.dcm4chee.arc.query.util.QueryAttributes in project dcm4chee-arc-light by dcm4che.

the class UpsMatchingRS method queryContext.

private QueryContext queryContext(String method, QueryRetrieveLevel2 qrlevel, String studyInstanceUID, String seriesInstanceUID, ApplicationEntity ae) {
    QueryContext ctx = queryService.newQueryContextQIDO(HttpServletRequestInfo.valueOf(request), method, aet, ae, queryParam(ae));
    ctx.setQueryRetrieveLevel(qrlevel);
    QueryAttributes queryAttrs = new QueryAttributes(uriInfo, null);
    Attributes keys = queryAttrs.getQueryKeys();
    IDWithIssuer idWithIssuer = IDWithIssuer.pidOf(keys);
    if (idWithIssuer != null && !idWithIssuer.getID().equals("*"))
        ctx.setPatientIDs(idWithIssuer);
    else if (ctx.getArchiveAEExtension().filterByIssuerOfPatientID())
        ctx.setIssuerOfPatientID(Issuer.fromIssuerOfPatientID(keys));
    if (studyInstanceUID != null)
        keys.setString(Tag.StudyInstanceUID, VR.UI, studyInstanceUID);
    if (seriesInstanceUID != null)
        keys.setString(Tag.SeriesInstanceUID, VR.UI, seriesInstanceUID);
    ctx.setQueryKeys(keys);
    Attributes returnKeys = new Attributes(3);
    returnKeys.setNull(Tag.StudyInstanceUID, VR.UI);
    switch(qrlevel) {
        case IMAGE:
            returnKeys.setNull(Tag.SOPInstanceUID, VR.UI);
        case SERIES:
            returnKeys.setNull(Tag.SeriesInstanceUID, VR.UI);
    }
    ctx.setReturnKeys(returnKeys);
    return ctx;
}
Also used : QueryAttributes(org.dcm4chee.arc.query.util.QueryAttributes) QueryAttributes(org.dcm4chee.arc.query.util.QueryAttributes) QueryContext(org.dcm4chee.arc.query.QueryContext)

Example 3 with QueryAttributes

use of org.dcm4chee.arc.query.util.QueryAttributes in project dcm4chee-arc-light by dcm4che.

the class ImportStorageRS method importInstanceOnStorage.

private void importInstanceOnStorage(AsyncResponse ar, InputStream in, String storageID, Output output) {
    ApplicationEntity ae = getApplicationEntity();
    Storage storage = storageFactory.getStorage(getStorageDesc(storageID));
    final StoreSession session = service.newStoreSession(HttpServletRequestInfo.valueOf(request), ae, aet, null).withObjectStorageID(storageID);
    Attributes coerce = new QueryAttributes(uriInfo, null).getQueryKeys();
    Date now = reasonForModification != null && !coerce.isEmpty() ? new Date() : null;
    Attributes.UpdatePolicy updatePolicy = Attributes.UpdatePolicy.valueOf(this.updatePolicy);
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
        reader.lines().forEach(storagePath -> importInstanceOnStorage(storage, service.newStoreContext(session), coerce, updatePolicy, now, storagePath));
    } catch (Exception e) {
        throw new WebApplicationException(errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR));
    }
    response.setString(Tag.RetrieveURL, VR.UR, retrieveURL());
    Response.ResponseBuilder responseBuilder = Response.status(status());
    ar.resume(responseBuilder.entity(output.entity(response, ae)).header("Warning", response.getString(Tag.ErrorComment)).build());
}
Also used : QueryAttributes(org.dcm4chee.arc.query.util.QueryAttributes) DicomServiceException(org.dcm4che3.net.service.DicomServiceException) StudyNotEmptyException(org.dcm4chee.arc.delete.StudyNotEmptyException) StudyNotFoundException(org.dcm4chee.arc.delete.StudyNotFoundException) AsyncResponse(javax.ws.rs.container.AsyncResponse) QueryAttributes(org.dcm4chee.arc.query.util.QueryAttributes) Storage(org.dcm4chee.arc.storage.Storage) ApplicationEntity(org.dcm4che3.net.ApplicationEntity) StoreSession(org.dcm4chee.arc.store.StoreSession)

Example 4 with QueryAttributes

use of org.dcm4chee.arc.query.util.QueryAttributes in project dcm4chee-arc-light by dcm4che.

the class ImportStorageRS method reimportStudy.

@POST
@Path("/studies/{study}/reimport")
public void reimportStudy(@Suspended AsyncResponse ar, @PathParam("study") String studyUID) {
    Output output = selectMediaType();
    ApplicationEntity ae = getApplicationEntity();
    try {
        ArchiveAEExtension arcAE = ae.getAEExtensionNotNull(ArchiveAEExtension.class);
        List<Location> locations = deletionService.reimportStudy(studyUID, HttpServletRequestInfo.valueOf(request), arcAE);
        Attributes coerce = new QueryAttributes(uriInfo, null).getQueryKeys();
        Date now = reasonForModification != null && !coerce.isEmpty() ? new Date() : null;
        Attributes.UpdatePolicy updatePolicy = Attributes.UpdatePolicy.valueOf(this.updatePolicy);
        for (Location location : locations) {
            if (location.getObjectType() == Location.ObjectType.METADATA)
                continue;
            Storage storage = storageFactory.getStorage(getStorageDesc(location.getStorageID()));
            final StoreSession session = service.newStoreSession(HttpServletRequestInfo.valueOf(request), ae, aet, null).withObjectStorageID(location.getStorageID());
            StoreContext ctx = service.newStoreContext(session);
            ctx.getLocations().add(location);
            importInstanceOnStorage(storage, ctx, coerce, updatePolicy, now, location.getStoragePath());
        }
        rsForward.forward(RSOperation.ReimportStudy, arcAE, null, request);
    } catch (StudyNotFoundException e) {
        throw new WebApplicationException(e.getMessage(), Response.Status.NOT_FOUND);
    } catch (StudyNotEmptyException e) {
        throw new WebApplicationException(e.getMessage(), Response.Status.FORBIDDEN);
    } catch (Exception e) {
        throw new WebApplicationException(errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR));
    }
    response.setString(Tag.RetrieveURL, VR.UR, retrieveURL());
    Response.ResponseBuilder responseBuilder = Response.status(status());
    ar.resume(responseBuilder.entity(output.entity(response, ae)).header("Warning", response.getString(Tag.ErrorComment)).build());
}
Also used : ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) QueryAttributes(org.dcm4chee.arc.query.util.QueryAttributes) DicomServiceException(org.dcm4che3.net.service.DicomServiceException) StudyNotEmptyException(org.dcm4chee.arc.delete.StudyNotEmptyException) StudyNotFoundException(org.dcm4chee.arc.delete.StudyNotFoundException) AsyncResponse(javax.ws.rs.container.AsyncResponse) QueryAttributes(org.dcm4chee.arc.query.util.QueryAttributes) Storage(org.dcm4chee.arc.storage.Storage) ApplicationEntity(org.dcm4che3.net.ApplicationEntity) StudyNotFoundException(org.dcm4chee.arc.delete.StudyNotFoundException) Location(org.dcm4chee.arc.entity.Location) StoreSession(org.dcm4chee.arc.store.StoreSession) StoreContext(org.dcm4chee.arc.store.StoreContext) StudyNotEmptyException(org.dcm4chee.arc.delete.StudyNotEmptyException)

Example 5 with QueryAttributes

use of org.dcm4chee.arc.query.util.QueryAttributes in project dcm4chee-arc-light by dcm4che.

the class StowRS method coerceAttributes.

private void coerceAttributes(Attributes attrs) {
    Attributes coerce = new QueryAttributes(uriInfo, null).getQueryKeys();
    if (!coerce.isEmpty()) {
        Attributes modified = new Attributes();
        attrs.update(Attributes.UpdatePolicy.valueOf(updatePolicy), false, coerce, modified);
        if (!modified.isEmpty() && reasonForModification != null) {
            attrs.addOriginalAttributes(sourceOfPreviousValues, new Date(), reasonForModification, device.getDeviceName(), modified);
        }
    }
}
Also used : QueryAttributes(org.dcm4chee.arc.query.util.QueryAttributes) QueryAttributes(org.dcm4chee.arc.query.util.QueryAttributes)

Aggregations

QueryAttributes (org.dcm4chee.arc.query.util.QueryAttributes)28 QueryContext (org.dcm4chee.arc.query.QueryContext)12 Attributes (org.dcm4che3.data.Attributes)6 ConfigurationException (org.dcm4che3.conf.api.ConfigurationException)5 ArchiveAEExtension (org.dcm4chee.arc.conf.ArchiveAEExtension)5 DicomServiceException (org.dcm4che3.net.service.DicomServiceException)4 JsonParsingException (javax.json.stream.JsonParsingException)3 AsyncResponse (javax.ws.rs.container.AsyncResponse)3 ApplicationEntity (org.dcm4che3.net.ApplicationEntity)3 ArchiveDeviceExtension (org.dcm4chee.arc.conf.ArchiveDeviceExtension)3 StudyNotEmptyException (org.dcm4chee.arc.delete.StudyNotEmptyException)3 StudyNotFoundException (org.dcm4chee.arc.delete.StudyNotFoundException)3 IOException (java.io.IOException)2 ConnectException (java.net.ConnectException)2 Response (javax.ws.rs.core.Response)2 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)2 ConfigurationNotFoundException (org.dcm4che3.conf.api.ConfigurationNotFoundException)2 IDWithIssuer (org.dcm4che3.data.IDWithIssuer)2 Query (org.dcm4chee.arc.query.Query)2 Storage (org.dcm4chee.arc.storage.Storage)2