Skip to content

Commit

Permalink
RESTful service to list Compare Studies Tasks #1304
Browse files Browse the repository at this point in the history
RESTful service to get result of Compare Studies Task #1305
  • Loading branch information
vrindanayak committed Apr 9, 2018
1 parent a481108 commit 9620e76
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

import org.dcm4che3.conf.json.JsonWriter;
import org.dcm4chee.arc.diff.DiffBatch;
import org.dcm4chee.arc.diff.DiffBatchOrder;
import org.dcm4chee.arc.diff.DiffService;
import org.dcm4chee.arc.entity.QueueMessage;
import org.dcm4chee.arc.query.util.MatchTask;
Expand All @@ -56,9 +55,7 @@
import javax.json.stream.JsonGenerator;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.Pattern;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
Expand Down Expand Up @@ -125,6 +122,7 @@ public class DiffBatchRS {
private String limit;

@QueryParam("orderby")
@DefaultValue("-updatedTime")
@Pattern(regexp = "(-?)createdTime|(-?)updatedTime")
private String orderby;

Expand Down Expand Up @@ -203,10 +201,4 @@ private QueueMessage.Status status() {
return status != null ? QueueMessage.Status.fromString(status) : null;
}

private static DiffBatchOrder order(String orderby) {
return orderby != null
? DiffBatchOrder.valueOf(orderby.replace('-', '_'))
: DiffBatchOrder._updatedTime;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public class DiffTaskRS {
private String limit;

@QueryParam("orderby")
@DefaultValue("-updatedTime")
@Pattern(regexp = "(-?)createdTime|(-?)updatedTime")
private String orderby;

Expand Down Expand Up @@ -257,13 +258,13 @@ private static boolean isCSV(MediaType type) {
abstract Object entity(final DiffTaskQuery tasks);
}

private StreamingOutput entity(List<byte[]> diffTaskAttributes) {
private StreamingOutput entity(List<AttributesBlob> diffTaskAttributesList) {
return output -> {
try (JsonGenerator gen = Json.createGenerator(output)) {
JSONWriter writer = new JSONWriter(gen);
gen.writeStartArray();
for (byte[] diffTaskAttributesEncoded : diffTaskAttributes)
writer.write(AttributesBlob.decodeAttributes(diffTaskAttributesEncoded, null));
for (AttributesBlob diffTaskAttributes : diffTaskAttributesList)
writer.write(AttributesBlob.decodeAttributes(diffTaskAttributes.getEncodedAttributes(), null));
gen.writeEnd();
}
};
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.Predicate;
import org.dcm4chee.arc.entity.AttributesBlob;
import org.dcm4chee.arc.entity.DiffTask;
import org.dcm4chee.arc.qmgt.HttpServletRequestInfo;
import org.dcm4chee.arc.qmgt.Outcome;
Expand Down Expand Up @@ -73,7 +74,7 @@ DiffTaskQuery listDiffTasks(Predicate matchQueueMessage, Predicate matchDiffTask

DiffTask getDiffTask(long taskPK);

List<byte[]> getDiffTaskAttributes(DiffTask diffTask, int offset, int limit);
List<AttributesBlob> getDiffTaskAttributes(DiffTask diffTask, int offset, int limit);

List<DiffBatch> listDiffBatches(Predicate matchQueueBatch, Predicate matchDiffBatch, OrderSpecifier<Date> order,
int offset, int limit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ public DiffTask getDiffTask(long taskPK) {
return em.find(DiffTask.class, taskPK);
}

public List<byte[]> getDiffTaskAttributes(DiffTask diffTask, int offset, int limit) {
return em.createNamedQuery(DiffTaskAttributes.FIND_BY_DIFF_TASK, byte[].class)
public List<AttributesBlob> getDiffTaskAttributes(DiffTask diffTask, int offset, int limit) {
return em.createNamedQuery(DiffTaskAttributes.FIND_BY_DIFF_TASK, AttributesBlob.class)
.setParameter(1, diffTask)
.setFirstResult(offset)
.setMaxResults(limit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.dcm4che3.data.Attributes;
import org.dcm4che3.net.Device;
import org.dcm4chee.arc.diff.*;
import org.dcm4chee.arc.entity.AttributesBlob;
import org.dcm4chee.arc.entity.DiffTask;
import org.dcm4chee.arc.entity.QueueMessage;
import org.dcm4chee.arc.qmgt.HttpServletRequestInfo;
Expand Down Expand Up @@ -129,7 +130,7 @@ public DiffTask getDiffTask(long taskPK) {
}

@Override
public List<byte[]> getDiffTaskAttributes(DiffTask diffTask, int offset, int limit) {
public List<AttributesBlob> getDiffTaskAttributes(DiffTask diffTask, int offset, int limit) {
return ejb.getDiffTaskAttributes(diffTask, offset, limit);
}

Expand Down

0 comments on commit 9620e76

Please sign in to comment.