Skip to content

Commit

Permalink
Update the OrderMapper to accommodate new properties:
Browse files Browse the repository at this point in the history
Since the result set may include joined quotas, use table prefixes to identify columns, and add in the new Order properties to the mapper.

refs #65
  • Loading branch information
csjx committed Oct 7, 2020
1 parent 032b38c commit a1c95fc
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/main/java/org/dataone/bookkeeper/jdbi/mappers/OrderMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,36 +69,36 @@ public Order map(ResultSet rs, StatementContext ctx) throws SQLException {

try {
itemsArray =
(ArrayNode) mapper.readTree(rs.getString("items"));
(ArrayNode) mapper.readTree(rs.getString("o_items"));

Iterator<JsonNode> iterator = itemsArray.elements();
while ( iterator.hasNext() ) {
ObjectNode item = (ObjectNode) iterator.next();
items.add(mapper.readValue(item.toString(), OrderItem.class));
}
order = new Order(
new Integer(rs.getInt("id")),
rs.getString("object"),
new Integer(rs.getInt("amount")),
new Integer(rs.getInt("amountReturned")),
rs.getString("charge") != null ?
(ObjectNode) mapper.readTree(rs.getString("charge")) : null,
new Integer(rs.getInt("created")),
rs.getString("currency"),
rs.getString("subject"),
new Integer(rs.getInt("customer")),
rs.getString("email"),
new Integer(rs.getInt("o_id")),
rs.getString("o_object"),
new Integer(rs.getInt("o_amount")),
new Integer(rs.getInt("o_amountReturned")),
rs.getString("o_charge") != null ?
(ObjectNode) mapper.readTree(rs.getString("o_charge")) : null,
new Integer(rs.getInt("o_created")),
rs.getString("o_currency"),
rs.getString("o_subject"),
new Integer(rs.getInt("o_customer")),
rs.getString("o_email"),
items,
rs.getString("metadata") != null ?
(ObjectNode) mapper.readTree(rs.getString("metadata")) : null,
rs.getString("name"),
rs.getString("status"),
rs.getString("statusTransitions") != null ?
(ObjectNode) mapper.readTree(rs.getString("statusTransitions")) : null,
new Integer(rs.getInt("updated")),
rs.getString("seriesId"),
new Integer(rs.getInt("startDate")),
new Integer(rs.getInt("endDate")),
rs.getString("o_metadata") != null ?
(ObjectNode) mapper.readTree(rs.getString("o_metadata")) : null,
rs.getString("o_name"),
rs.getString("o_status"),
rs.getString("o_statusTransitions") != null ?
(ObjectNode) mapper.readTree(rs.getString("o_statusTransitions")) : null,
new Integer(rs.getInt("o_updated")),
rs.getString("o_seriesId"),
new Integer(rs.getInt("o_startDate")),
new Integer(rs.getInt("o_endDate")),
null // let the row reducer populate quotas

);
Expand Down

0 comments on commit a1c95fc

Please sign in to comment.