From 946914ffaa8e7212d67f6f45acfc36afae2fab81 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Fri, 23 Oct 2020 16:07:51 -0600 Subject: [PATCH] Find orders by a subject list, not a single subject: This allows us to return orders for groups associated with the caller as well as the caller's subject. We did this previously in the SubscriptionStore, so we're migrating the functionality over here. refs #70 --- .../java/org/dataone/bookkeeper/jdbi/OrderStore.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/dataone/bookkeeper/jdbi/OrderStore.java b/src/main/java/org/dataone/bookkeeper/jdbi/OrderStore.java index 8be1544..f775b98 100644 --- a/src/main/java/org/dataone/bookkeeper/jdbi/OrderStore.java +++ b/src/main/java/org/dataone/bookkeeper/jdbi/OrderStore.java @@ -27,6 +27,7 @@ import org.jdbi.v3.sqlobject.config.RegisterBeanMapper; import org.jdbi.v3.sqlobject.config.RegisterRowMapper; import org.jdbi.v3.sqlobject.customizer.Bind; +import org.jdbi.v3.sqlobject.customizer.BindList; import org.jdbi.v3.sqlobject.customizer.BindMethods; import org.jdbi.v3.sqlobject.statement.GetGeneratedKeys; import org.jdbi.v3.sqlobject.statement.SqlQuery; @@ -84,7 +85,7 @@ public interface OrderStore { String SELECT_CUSTOMER = SELECT_CLAUSE + "WHERE customer = :customer "; - String SELECT_SUBJECT = SELECT_CLAUSE + "WHERE o.subject = :subject " + ORDER_CLAUSE; + String SELECT_SUBJECTS = SELECT_CLAUSE + "WHERE o.subject IN () " + ORDER_CLAUSE; /** * List all orders @@ -120,15 +121,14 @@ public interface OrderStore { /** * Find orders by subject - * @param subject the subject of the customer + * @param subjects the list of subjects for the desired orders * @return the desired orders */ - @SqlQuery(SELECT_SUBJECT) + @SqlQuery(SELECT_SUBJECTS) @RegisterBeanMapper(value = Quota.class, prefix = "q") @RegisterRowMapper(OrderMapper.class) @UseRowReducer(OrderQuotasReducer.class) - List findOrdersBySubject(@Bind("subject") String subject); - + List findOrdersBySubjects(@BindList("subjects") List subjects); /** * Insert an order * @param order the order to insert