Skip to content

Commit

Permalink
Find orders by a subject list, not a single subject:
Browse files Browse the repository at this point in the history
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
  • Loading branch information
csjx committed Oct 23, 2020
1 parent fd93141 commit 946914f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/org/dataone/bookkeeper/jdbi/OrderStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 (<subjects>) " + ORDER_CLAUSE;

/**
* List all orders
Expand Down Expand Up @@ -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<Order> findOrdersBySubject(@Bind("subject") String subject);

List<Order> findOrdersBySubjects(@BindList("subjects") List<String> subjects);
/**
* Insert an order
* @param order the order to insert
Expand Down

0 comments on commit 946914f

Please sign in to comment.