Search in sources :

Example 1 with AttributesBlob

use of org.dcm4chee.arc.entity.AttributesBlob in project dcm4chee-arc-light by dcm4che.

the class DiffServiceEJB method getDiffTaskAttributes.

public List<byte[]> getDiffTaskAttributes(TaskQueryParam taskQueryParam, int offset, int limit) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<byte[]> q = cb.createQuery(byte[].class);
    Root<Task> task = q.from(Task.class);
    CollectionJoin<Task, AttributesBlob> attrsBlobs = task.join(Task_.diffTaskAttributes);
    List<Predicate> predicates = new QueryBuilder(cb).taskPredicates(task, taskQueryParam);
    q.where(predicates.toArray(new Predicate[0]));
    TypedQuery<byte[]> query = em.createQuery(q.select(attrsBlobs.get(AttributesBlob_.encodedAttributes)));
    if (offset > 0)
        query.setFirstResult(offset);
    if (limit > 0)
        query.setMaxResults(limit);
    return query.getResultList();
}
Also used : Task(org.dcm4chee.arc.entity.Task) AttributesBlob(org.dcm4chee.arc.entity.AttributesBlob) QueryBuilder(org.dcm4chee.arc.query.util.QueryBuilder)

Example 2 with AttributesBlob

use of org.dcm4chee.arc.entity.AttributesBlob in project dcm4chee-arc-light by dcm4che.

the class PamRS method updateCharset.

@POST
@Path("/patients/charset/{charset}")
public Response updateCharset(@Pattern(regexp = "ISO_IR 100|ISO_IR 101|ISO_IR 109|ISO_IR 110|ISO_IR 144|ISO_IR 127|ISO_IR 126|ISO_IR 138|ISO_IR 148|ISO_IR 13|ISO_IR 166|ISO_IR 192|GB18030|GBK") @PathParam("charset") String charset, @QueryParam("test") @Pattern(regexp = "true|false") @DefaultValue("false") String test) {
    ArchiveAEExtension arcAE = getArchiveAE();
    boolean update = !Boolean.parseBoolean(test);
    int updated = 0;
    List<IDWithIssuer> failures = new ArrayList<>();
    try {
        QueryAttributes queryAttrs = new QueryAttributes(uriInfo, null);
        Attributes queryKeys = queryAttrs.getQueryKeys();
        CriteriaQuery<AttributesBlob> query = queryService.createPatientAttributesQuery(queryParam(arcAE.getApplicationEntity(), false), queryKeys);
        int limit = arcAE.getArchiveDeviceExtension().getUpdateCharsetFetchSize();
        int offset = 0;
        List<AttributesBlob> blobs = patientService.queryWithOffsetAndLimit(query, offset, limit);
        if (blobs.isEmpty()) {
            return Response.status(Response.Status.NO_CONTENT).build();
        }
        for (; ; ) {
            for (AttributesBlob blob : blobs) {
                Attributes attrs = blob.getAttributes();
                if (charset.equals(attrs.getString(Tag.SpecificCharacterSet)))
                    continue;
                attrs.setSpecificCharacterSet(charset);
                blob.setAttributes(attrs);
                if (attrs.equals(AttributesBlob.decodeAttributes(blob.getEncodedAttributes(), null))) {
                    if (update)
                        patientService.merge(blob);
                    updated++;
                } else {
                    failures.add(IDWithIssuer.pidOf(attrs));
                }
            }
            if (blobs.size() < limit)
                break;
            offset += blobs.size();
        }
        if (updated > 0)
            rsForward.forward(RSOperation.UpdateCharset, arcAE, null, request);
        return updateCharsetResponse(updated, failures).build();
    } catch (Exception e) {
        return errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR);
    }
}
Also used : QueryAttributes(org.dcm4chee.arc.query.util.QueryAttributes) ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) AttributesBlob(org.dcm4chee.arc.entity.AttributesBlob) QueryAttributes(org.dcm4chee.arc.query.util.QueryAttributes) SAXException(org.xml.sax.SAXException) JsonParsingException(javax.json.stream.JsonParsingException) ConfigurationException(org.dcm4che3.conf.api.ConfigurationException) DicomServiceException(org.dcm4che3.net.service.DicomServiceException) ConfigurationNotFoundException(org.dcm4che3.conf.api.ConfigurationNotFoundException) ConnectException(java.net.ConnectException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException)

Aggregations

AttributesBlob (org.dcm4chee.arc.entity.AttributesBlob)2 ConnectException (java.net.ConnectException)1 JsonParsingException (javax.json.stream.JsonParsingException)1 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)1 ConfigurationException (org.dcm4che3.conf.api.ConfigurationException)1 ConfigurationNotFoundException (org.dcm4che3.conf.api.ConfigurationNotFoundException)1 DicomServiceException (org.dcm4che3.net.service.DicomServiceException)1 ArchiveAEExtension (org.dcm4chee.arc.conf.ArchiveAEExtension)1 Task (org.dcm4chee.arc.entity.Task)1 QueryAttributes (org.dcm4chee.arc.query.util.QueryAttributes)1 QueryBuilder (org.dcm4chee.arc.query.util.QueryBuilder)1 SAXException (org.xml.sax.SAXException)1