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();
}
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);
}
}
Aggregations