diff --git a/dcm4chee-arc-diff-rs/src/main/java/org/dcm4chee/arc/diff/rs/DiffTaskRS.java b/dcm4chee-arc-diff-rs/src/main/java/org/dcm4chee/arc/diff/rs/DiffTaskRS.java index 8ec5ffe4cc..68276597dc 100644 --- a/dcm4chee-arc-diff-rs/src/main/java/org/dcm4chee/arc/diff/rs/DiffTaskRS.java +++ b/dcm4chee-arc-diff-rs/src/main/java/org/dcm4chee/arc/diff/rs/DiffTaskRS.java @@ -41,7 +41,6 @@ package org.dcm4chee.arc.diff.rs; -import com.querydsl.core.types.Predicate; import org.dcm4che3.conf.json.JsonReader; import org.dcm4che3.json.JSONWriter; import org.dcm4che3.net.Device; @@ -55,7 +54,6 @@ import org.dcm4chee.arc.event.QueueMessageEvent; import org.dcm4chee.arc.event.QueueMessageOperation; import org.dcm4chee.arc.qmgt.IllegalTaskStateException; -import org.dcm4chee.arc.query.util.MatchTask; import org.dcm4chee.arc.query.util.TaskQueryParam; import org.dcm4chee.arc.rs.client.RSClient; import org.jboss.resteasy.annotations.cache.NoCache; @@ -383,8 +381,8 @@ public String deleteTasks() { int deleteTasksFetchSize = queueTasksFetchSize(); do { count = diffService.deleteTasks( - matchQueueMessage(status(), deviceName, null), - matchDiffTask(updatedTime), + queueTaskQueryParam(deviceName, status()), + diffTaskQueryParam(updatedTime), deleteTasksFetchSize); deleted += count; } while (count >= deleteTasksFetchSize); @@ -541,16 +539,6 @@ private String exceptionAsString(Exception e) { return sw.toString(); } - private Predicate matchDiffTask(String updatedTime) { - return MatchTask.matchDiffTask( - localAET, primaryAET, secondaryAET, checkDifferent, checkMissing, comparefields, createdTime, updatedTime); - } - - private Predicate matchQueueMessage(QueueMessage.Status status, String devName, String updatedTime) { - return MatchTask.matchQueueMessage( - null, devName, status, batchID, null, null, updatedTime, null); - } - private int queueTasksFetchSize() { return arcDev().getQueueTasksFetchSize(); } diff --git a/dcm4chee-arc-diff/src/main/java/org/dcm4chee/arc/diff/DiffService.java b/dcm4chee-arc-diff/src/main/java/org/dcm4chee/arc/diff/DiffService.java index 39de5de840..80017722dc 100644 --- a/dcm4chee-arc-diff/src/main/java/org/dcm4chee/arc/diff/DiffService.java +++ b/dcm4chee-arc-diff/src/main/java/org/dcm4chee/arc/diff/DiffService.java @@ -41,7 +41,6 @@ package org.dcm4chee.arc.diff; -import com.querydsl.core.types.Predicate; import org.dcm4chee.arc.entity.AttributesBlob; import org.dcm4chee.arc.entity.DiffTask; import org.dcm4chee.arc.event.QueueMessageEvent; @@ -90,7 +89,7 @@ long cancelDiffTasks(TaskQueryParam queueTaskQueryParam, TaskQueryParam diffTask boolean deleteDiffTask(Long pk, QueueMessageEvent queueEvent); - int deleteTasks(Predicate matchQueueMessage, Predicate matchDiffTask, int deleteTasksFetchSize); + int deleteTasks(TaskQueryParam queueTaskQueryParam, TaskQueryParam diffTaskQueryParam, int deleteTasksFetchSize); List listDistinctDeviceNames(TaskQueryParam queueTaskQueryParam, TaskQueryParam diffTaskQueryParam); diff --git a/dcm4chee-arc-diff/src/main/java/org/dcm4chee/arc/diff/impl/DiffServiceEJB.java b/dcm4chee-arc-diff/src/main/java/org/dcm4chee/arc/diff/impl/DiffServiceEJB.java index 154658023e..1645ae68ee 100644 --- a/dcm4chee-arc-diff/src/main/java/org/dcm4chee/arc/diff/impl/DiffServiceEJB.java +++ b/dcm4chee-arc-diff/src/main/java/org/dcm4chee/arc/diff/impl/DiffServiceEJB.java @@ -176,11 +176,12 @@ public boolean deleteDiffTask(Long pk, QueueMessageEvent queueEvent) { return true; } - public int deleteTasks(Predicate matchQueueMessage, Predicate matchDiffTask, int deleteTasksFetchSize) { - List referencedQueueMsgIDs = createQuery(matchQueueMessage, matchDiffTask) - .select(QDiffTask.diffTask.queueMessage.messageID) - .limit(deleteTasksFetchSize) - .fetch(); + public int deleteTasks( + TaskQueryParam queueTaskQueryParam, TaskQueryParam diffTaskQueryParam, int deleteTasksFetchSize) { + List referencedQueueMsgIDs = em.createQuery(createQuery(queueTaskQueryParam, diffTaskQueryParam) + .select(queueMsg.get(QueueMessage_.messageID))) + .setMaxResults(deleteTasksFetchSize) + .getResultList(); for (String queueMsgID : referencedQueueMsgIDs) queueManager.deleteTask(queueMsgID, null); diff --git a/dcm4chee-arc-diff/src/main/java/org/dcm4chee/arc/diff/impl/DiffServiceImpl.java b/dcm4chee-arc-diff/src/main/java/org/dcm4chee/arc/diff/impl/DiffServiceImpl.java index 64c74c8ce0..0de4c32dab 100644 --- a/dcm4chee-arc-diff/src/main/java/org/dcm4chee/arc/diff/impl/DiffServiceImpl.java +++ b/dcm4chee-arc-diff/src/main/java/org/dcm4chee/arc/diff/impl/DiffServiceImpl.java @@ -41,7 +41,6 @@ package org.dcm4chee.arc.diff.impl; -import com.querydsl.core.types.Predicate; import org.dcm4che3.conf.api.ConfigurationException; import org.dcm4che3.conf.api.IApplicationEntityCache; import org.dcm4che3.data.Attributes; @@ -213,8 +212,8 @@ public boolean deleteDiffTask(Long pk, QueueMessageEvent queueEvent) { } @Override - public int deleteTasks(Predicate matchQueueMessage, Predicate matchDiffTask, int deleteTasksFetchSize) { - return ejb.deleteTasks(matchQueueMessage, matchDiffTask, deleteTasksFetchSize); + public int deleteTasks(TaskQueryParam queueTaskQueryParam, TaskQueryParam diffTaskQueryParam, int deleteTasksFetchSize) { + return ejb.deleteTasks(queueTaskQueryParam, diffTaskQueryParam, deleteTasksFetchSize); } private QueueMessage.Status check(String prompt, int failures, QueueMessage.Status status, StringBuilder sb) { diff --git a/dcm4chee-arc-query-util/src/main/java/org/dcm4chee/arc/query/util/MatchDateTimeRange.java b/dcm4chee-arc-query-util/src/main/java/org/dcm4chee/arc/query/util/MatchDateTimeRange.java index 7cd4281441..09ef2f3ec0 100644 --- a/dcm4chee-arc-query-util/src/main/java/org/dcm4chee/arc/query/util/MatchDateTimeRange.java +++ b/dcm4chee-arc-query-util/src/main/java/org/dcm4chee/arc/query/util/MatchDateTimeRange.java @@ -131,10 +131,6 @@ public static Predicate range(StringPath field, String range, FormatDate dt) { return range(field, parseDateRange(range), dt); } - public static Predicate range(DateTimePath field, String range, FormatDate dt) { - return range(field, parseDateRange(range), dt); - } - public static Predicate range(DateTimePath field, DateRange range, FormatDate dt) { Date startDate = range.getStartDate(); Date endDate = range.getEndDate(); diff --git a/dcm4chee-arc-query-util/src/main/java/org/dcm4chee/arc/query/util/MatchTask.java b/dcm4chee-arc-query-util/src/main/java/org/dcm4chee/arc/query/util/MatchTask.java index 8ce3e3d2cb..6e999bb951 100644 --- a/dcm4chee-arc-query-util/src/main/java/org/dcm4chee/arc/query/util/MatchTask.java +++ b/dcm4chee-arc-query-util/src/main/java/org/dcm4chee/arc/query/util/MatchTask.java @@ -40,7 +40,6 @@ package org.dcm4chee.arc.query.util; -import com.querydsl.core.BooleanBuilder; import javax.persistence.criteria.Predicate; import org.dcm4chee.arc.entity.*; @@ -63,31 +62,6 @@ public MatchTask(CriteriaBuilder cb) { this.cb = Objects.requireNonNull(cb); } - public static com.querydsl.core.types.Predicate matchQueueMessage( - String queueName, String deviceName, QueueMessage.Status status, String batchID, String jmsMessageID, - String createdTime, String updatedTime, Date updatedBefore) { - BooleanBuilder predicate = new BooleanBuilder(); - if (queueName != null) - predicate.and(QQueueMessage.queueMessage.queueName.eq(queueName)); - if (status != null && status != QueueMessage.Status.TO_SCHEDULE) - predicate.and(QQueueMessage.queueMessage.status.eq(status)); - if (deviceName != null) - predicate.and(QQueueMessage.queueMessage.deviceName.eq(deviceName)); - if (batchID != null) - predicate.and(QQueueMessage.queueMessage.batchID.eq(batchID)); - if (jmsMessageID != null) - predicate.and(QQueueMessage.queueMessage.messageID.eq(jmsMessageID)); - if (createdTime != null) - predicate.and(MatchDateTimeRange.range( - QQueueMessage.queueMessage.createdTime, createdTime, MatchDateTimeRange.FormatDate.DT)); - if (updatedTime != null) - predicate.and(MatchDateTimeRange.range( - QQueueMessage.queueMessage.updatedTime, updatedTime, MatchDateTimeRange.FormatDate.DT)); - if (updatedBefore != null) - predicate.and(QQueueMessage.queueMessage.updatedTime.before(updatedBefore)); - return predicate; - } - public List queueMsgPredicates( Root queueMsg, TaskQueryParam queueTaskQueryParam) { List predicates = new ArrayList<>(); @@ -257,31 +231,6 @@ private void matchStgVerTask( cb, stgVerTask.get(StorageVerificationTask_.updatedTime), taskQueryParam.getUpdatedTime())); } - public static com.querydsl.core.types.Predicate matchDiffTask( - String localAET, String primaryAET, String secondaryAET, String checkDifferent, - String checkMissing, String comparefields, String createdTime, String updatedTime) { - BooleanBuilder predicate = new BooleanBuilder(); - if (localAET != null) - predicate.and(QDiffTask.diffTask.localAET.eq(localAET)); - if (primaryAET != null) - predicate.and(QDiffTask.diffTask.primaryAET.eq(primaryAET)); - if (secondaryAET != null) - predicate.and(QDiffTask.diffTask.secondaryAET.eq(secondaryAET)); - if (checkDifferent != null) - predicate.and(QDiffTask.diffTask.checkDifferent.eq(Boolean.parseBoolean(checkDifferent))); - if (checkMissing != null) - predicate.and(QDiffTask.diffTask.checkMissing.eq(Boolean.parseBoolean(checkMissing))); - if (comparefields != null) - predicate.and(QDiffTask.diffTask.compareFields.eq(comparefields)); - if (createdTime != null) - predicate.and(MatchDateTimeRange.range( - QDiffTask.diffTask.createdTime, createdTime, MatchDateTimeRange.FormatDate.DT)); - if (updatedTime != null) - predicate.and(MatchDateTimeRange.range( - QDiffTask.diffTask.updatedTime, updatedTime, MatchDateTimeRange.FormatDate.DT)); - return predicate; - } - public Order exportTaskOrder(String orderby, Path exportTask) { return taskOrder(orderby, exportTask.get(ExportTask_.createdTime),