package com.example.services; import com.example.services.order.Order; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.json.JSONObject; import org.json.XML; @Path("/obi") public class OrderService { private static final Logger logger = LoggerFactory.getLogger(OrderService.class); @GET @Path("/order") @Produces(MediaType.APPLICATION_JSON) public Response getAllOrders(@QueryParam("q") String q, @QueryParam("page") int page, @QueryParam("itemsPerPage") int itemsPerPage, @QueryParam("sortBy") String sortBy, @QueryParam("orderBy") String orderBy, @QueryParam("status") String status, @QueryParam("type") String type, @QueryParam("minDate") String minDate, @QueryParam("maxDate") String maxDate) { DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes try (DatabaseConnectOBI databaseConnection = new DatabaseConnectOBI()) { String countQuery = "SELECT COUNT(*), " + "SUM (CASE WHEN oo.status = 'new_order' THEN 1 ELSE 0 END) AS stat_status1, " + "SUM (CASE WHEN oo.status = 'polled' THEN 1 ELSE 0 END) AS stat_status2, " + "SUM (CASE WHEN oo.status = 'fulfilled' THEN 1 ELSE 0 END) AS stat_status3, " + "SUM (CASE WHEN oo.status = 'received' THEN 1 ELSE 0 END) AS stat_status4, " + "SUM (CASE WHEN oo.status = 'unfulfillable' THEN 1 ELSE 0 END) AS stat_status5, " + "SUM (CASE WHEN oo.status = 'canceled' THEN 1 ELSE 0 END) AS stat_status6 " + "FROM obi_order oo " + "JOIN obi_transaction_type ott on ott.transaction_type_id = oo.transaction_type_id"; String query = "SELECT oo.request_id, " + "oo.order_id, " + "oo.transaction_date, " + "oo.status as status, " + "ott.transaction_type_description " + "FROM obi_order oo " + "JOIN obi_transaction_type ott on ott.transaction_type_id = oo.transaction_type_id"; List conditions = new ArrayList<>(); if (q != null && !q.isEmpty()) { conditions.add(" oo.order_id LIKE ? "); } if (status != null && !status.isEmpty()) { conditions.add(" oo.status = ? "); } if (type != null && !type.isEmpty()) { conditions.add(" ott.transaction_type_code = ? "); } if (minDate != null && !minDate.isEmpty()) { conditions.add(" DATE_TRUNC('day', oo.transaction_date) >= ? "); } if (maxDate != null && !maxDate.isEmpty()) { conditions.add(" DATE_TRUNC('day', oo.transaction_date) <= ? "); } if (!conditions.isEmpty()) { countQuery += " WHERE " + String.join(" AND ", conditions); query += " WHERE " + String.join(" AND ", conditions); } if (sortBy != null && !sortBy.isEmpty()) { query += " ORDER BY " + sortBy; if (orderBy != null && !orderBy.isEmpty()) { query += " " + orderBy; } } if (page > 0 && itemsPerPage > 0) { query += " LIMIT " + itemsPerPage + " OFFSET " + (page - 1) * itemsPerPage; } logger.info(query); try (PreparedStatement countStatement = databaseConnection.getConnection().prepareStatement(countQuery); PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query)) { int index = 1; if (q != null && !q.isEmpty()) { countStatement.setString(index, "%" + q + "%"); statement.setString(index++, "%" + q + "%"); } if(status != null && !status.isEmpty()) { countStatement.setString(index, status ); statement.setString(index++, status ); } if (type != null && !type.isEmpty()) { countStatement.setString(index, type); statement.setString(index++, type); } SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); if (minDate != null && !minDate.isEmpty()) { try { java.util.Date parsedMinDate = dateFormat.parse(minDate); java.sql.Date sqlMinDate = new java.sql.Date(parsedMinDate.getTime()); countStatement.setDate(index, sqlMinDate); statement.setDate(index++, sqlMinDate); } catch (ParseException e) { e.printStackTrace(); } } if (maxDate != null && !maxDate.isEmpty()) { try { java.util.Date parsedMaxDate = dateFormat.parse(maxDate); java.sql.Date sqlMaxDate = new java.sql.Date(parsedMaxDate.getTime()); countStatement.setDate(index, sqlMaxDate); statement.setDate(index++, sqlMaxDate); } catch (ParseException e) { e.printStackTrace(); } } ResultSet countResultSet = countStatement.executeQuery(); countResultSet.next(); int total = countResultSet.getInt(1); int statStatus1 = countResultSet.getInt(2); int statStatus2 = countResultSet.getInt(3); int statStatus3 = countResultSet.getInt(4); int statStatus4 = countResultSet.getInt(5); int statStatus5 = countResultSet.getInt(6); int statStatus6 = countResultSet.getInt(7); ResultSet resultSet = statement.executeQuery(); { List orderList = new ArrayList<>(); while (resultSet.next()) { Order order = mapResultSetToOrderList(resultSet); orderList.add(order); } ObjectMapper objectMapper = new ObjectMapper(); ObjectNode responseNode = objectMapper.createObjectNode(); responseNode.put("total", total); ArrayNode statisticsArray = objectMapper.createArrayNode(); String[] titles = {"new_order", "polled", "fulfilled", "received","unfulfillable","canceled"}; String[] icons = {"tabler-calendar-stats", "tabler-progress-check", "tabler-checks", "tabler-checks","tabler-wallet","tabler-circle-x"}; int[] counts = {statStatus1, statStatus2, statStatus3, statStatus4, statStatus5, statStatus6}; for (int i = 0; i < titles.length; i++) { ObjectNode node = objectMapper.createObjectNode(); node.put("title", titles[i]); node.put("value", counts[i]); node.put("icon", icons[i]); statisticsArray.add(node); } responseNode.set("statistics", statisticsArray); responseNode.set("orders", objectMapper.valueToTree(orderList)); String jsonResponse; try { jsonResponse = objectMapper.writeValueAsString(responseNode); return Response.ok(jsonResponse).build(); } catch (JsonProcessingException e) { e.printStackTrace(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"Error processing JSON\"}").build(); } } } } catch (SQLException e) { e.printStackTrace(); String errorResponse = "{\"error\":\"" + e.getMessage() + "\"}"; return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponse).build(); } } @GET @Path("/order/{requestId}") @Produces(MediaType.APPLICATION_JSON) public Response getOrderById( @PathParam("requestId") Long requestId) throws SQLException { DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes try (DatabaseConnectOBI databaseConnection = new DatabaseConnectOBI()) { // ORDER SECTION --------------------------------- String orderQuery = "SELECT oo.request_id, oo.order_id, oo.requesting_location_cd, oo.requesting_system_cd, " + "oo.customer_id, oo.transaction_no, oo.transaction_type_id, oo.transaction_date, oo.status, " + "oo.fdate_creation, oo.consumed, oo.shipforpickup_location_cd, oo.shipforpickup_system_cd, " + "ott.transaction_type_description " + "FROM obi_order oo " + "JOIN obi_transaction_type ott on ott.transaction_type_id = oo.transaction_type_id " + "WHERE oo.request_id = ?"; logger.info(orderQuery); try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(orderQuery)) { statement.setLong(1, requestId); try (ResultSet resultSet = statement.executeQuery()) { if (resultSet.next()) { Order order = mapResultSetToOrder(resultSet); // ORDER LINES SECTION --------------------------------- String orderLinesQuery = "SELECT olo.line_order_id, olo.line_item_no, olo.order_id, olo.request_id, olo.line_item_oms, " + "olo.item_id, olo.ordered_line_qty, olo.status, olo.transaction_date, olo.shipping_agent, " + "olo.tracking_number, olo.fulfillment_id, olo.carton_number, olo.fdate_creation, olo.consumed " + "FROM obi.obi_ln_order olo " + "WHERE olo.request_id = ? " + "ORDER BY olo.line_item_no"; logger.info(orderLinesQuery); try (PreparedStatement linesStatement = databaseConnection.getConnection().prepareStatement(orderLinesQuery)) { linesStatement.setLong(1, requestId); try (ResultSet linesResultSet = linesStatement.executeQuery()) { List orderLinesList = new ArrayList<>(); while (linesResultSet.next()) { orderLinesList.add(mapResultSetToOrderLine(linesResultSet)); String orderLinesHistoryQuery = "SELECT ohlo.status_id, ohlo.line_order_id, ohlo.status, ohlo.transaction_date, ohlo.fdate_creation " + "FROM obi.obi_h_ln_order ohlo " + "WHERE ohlo.line_order_id = ? " + "ORDER BY ohlo.status_id DESC"; logger.info(orderLinesHistoryQuery); try (PreparedStatement orderLinesHistoryStatement = databaseConnection.getConnection().prepareStatement(orderLinesHistoryQuery)) { orderLinesHistoryStatement.setLong(1, orderLinesList.get(orderLinesList.size() - 1).getLineOrderId()); try (ResultSet orderLinesHistoryResultSet = orderLinesHistoryStatement.executeQuery()) { List orderLinesHistoryList = new ArrayList<>(); while (orderLinesHistoryResultSet.next()) { orderLinesHistoryList.add(mapResultSetToOrderLinesHistory(orderLinesHistoryResultSet)); } orderLinesList.get(orderLinesList.size() - 1).setHistory(orderLinesHistoryList); } } } order.setLines(orderLinesList); } } // ORDER HISTORY SECTION --------------------------------- String orderHistoryQuery = "SELECT oho.status_id, oho.request_id, oho.status, oho.transaction_date, oho.fdate_creation " + "FROM obi.obi_h_order oho " + "WHERE oho.request_id = ? " + "ORDER BY oho.status_id DESC"; logger.info(orderHistoryQuery); try (PreparedStatement orderHistoryStatement = databaseConnection.getConnection().prepareStatement(orderHistoryQuery)) { orderHistoryStatement.setLong(1, requestId); try (ResultSet orderHistoryResultSet = orderHistoryStatement.executeQuery()) { List orderHistoryList = new ArrayList<>(); while (orderHistoryResultSet.next()) { orderHistoryList.add(mapResultSetToOrderHistory(orderHistoryResultSet)); } order.setHistory(orderHistoryList); } } // PREPARATION SECTION --------------------------------- String preparationQuery = "SELECT oop.prep_int_id, oop.prep_id, oop.order_id, oop.request_id, oop.transaction_date, oop.fulfillment_system_cd, " + "oop.fulfillment_location_cd, oop.status, oop.date_prepartion, oop.fdate_creation " + "FROM obi.obi_order_prep oop " + "WHERE oop.request_id = ? " + "ORDER BY oop.prep_int_id DESC"; logger.info(preparationQuery); try(PreparedStatement preparationStatement = databaseConnection.getConnection().prepareStatement(preparationQuery)) { preparationStatement.setLong(1, requestId); try(ResultSet preparationResultSet = preparationStatement.executeQuery()) { List preparationList = new ArrayList<>(); while(preparationResultSet.next()) { preparationList.add(mapResultSetToPreparation(preparationResultSet)); // PREPARATION LINES SECTION --------------------------------- String preparationLinesQuery = "SELECT " + "olop.line_fulfill_id, " + "olop.line_order_id, " + "olop.prep_int_id, " + "olop.order_id, " + "olop.request_id, " + "olop.transaction_date, " + "olop.line_item_no, " + "olop.item_id, " + "olop.line_item_oms, " + "olop.fulfill_qty, " + "olop.validated_fulfill_qty, " + "olop.fulfillment_system_cd, " + "olop.fulfillment_location_cd, " + "olop.status, " + "olop.numero_expedition, " + "olop.season_code, " + "olop.finition_speciale, " + "olop.carrier, " + "olop.tracking_code, " + "olop.tracking_url, " + "olop.fdate_creation, " + "olop.fdate_modification, " + "olop.to_orlix_consumed, " + "null as restocking_code " //"olop.restocking_code " + "FROM obi.obi_ln_order_prep olop " + "WHERE olop.prep_int_id = ? " + "ORDER BY olop.line_item_oms"; logger.info(preparationLinesQuery); try(PreparedStatement preparationLinesStatement = databaseConnection.getConnection().prepareStatement(preparationLinesQuery)) { preparationLinesStatement.setLong(1, preparationList.get(preparationList.size() - 1).getPrepIntId()); try(ResultSet preparationLinesResultSet = preparationLinesStatement.executeQuery()) { List preparationLinesList = new ArrayList<>(); while(preparationLinesResultSet.next()) { preparationLinesList.add(mapResultSetToPreparationLines(preparationLinesResultSet)); } preparationList.get(preparationList.size() - 1).setLines(preparationLinesList); } } } order.setPreparations(preparationList); } } // RECEPTION SECTION --------------------------------- String receptionQuery = "SELECT ocr.intransit_int_id, ocr.intransit_id, ocr.prep_int_id, " + "ocr.order_id, ocr.request_id, ocr.status, ocr.transaction_date, " + "ocr.intransit_system_cd, ocr.intransit_location_cd, ocr.fdate_receipt, " + "ocr.fdate_creation " + "FROM obi.obi_cr_receipt ocr " + "WHERE ocr.request_id = ? " + "ORDER BY ocr.intransit_id DESC"; logger.info(receptionQuery); try(PreparedStatement receptionStatement = databaseConnection.getConnection().prepareStatement(receptionQuery)) { receptionStatement.setLong(1, requestId); try(ResultSet receptionResultSet = receptionStatement.executeQuery()) { List receptionList = new ArrayList<>(); while(receptionResultSet.next()) { receptionList.add(mapResultSetToReception(receptionResultSet)); // RECEPTION LINES SECTION --------------------------------- String receptionLinesQuery = "SELECT " + "olcr.line_intransit_id AS line_intransit_id, " + "olcr.intransit_int_id AS intransit_int_id, " + "olcr.line_fulfill_id AS line_fulfill_id, " + "olcr.transaction_date AS transaction_date, " + "olcr.line_item_no AS line_item_no, " + "olcr.item_id AS item_id, " + "olcr.intransit_qty AS intransit_qty, " + "olcr.validated_intransit_qty AS validated_intransit_qty, " + "olcr.intransit_system_cd AS intransit_system_cd, " + "olcr.intransit_location_cd AS intransit_location_cd, " + "olcr.status AS status, " + "olcr.colis_id AS colis_id, " + "olcr.fdate_creation AS fdate_creation, " + "olcr.fdate_receipt AS fdate_receipt, " + "olcr.order_line_ship_weight AS order_line_ship_weight, " + "olcr.tracking_number AS tracking_number " + "FROM obi.obi_ln_cr_receipt olcr " + "WHERE olcr.intransit_int_id = ? " + "ORDER BY olcr.line_item_no"; logger.info(receptionLinesQuery); try(PreparedStatement receptionLinesStatement = databaseConnection.getConnection().prepareStatement(receptionLinesQuery)) { receptionLinesStatement.setLong(1, receptionList.get(receptionList.size() - 1).getIntransitIntId()); try(ResultSet receptionLinesResultSet = receptionLinesStatement.executeQuery()) { List receptionLinesList = new ArrayList<>(); while(receptionLinesResultSet.next()) { receptionLinesList.add(mapResultSetToReceptionLines(receptionLinesResultSet)); } receptionList.get(receptionList.size() - 1).setLines(receptionLinesList); } } } order.setReceptions(receptionList); } } ObjectMapper objectMapper = new ObjectMapper(); String jsonResponse = objectMapper.writeValueAsString(order); return Response.ok(jsonResponse).build(); } else { return Response.status(Response.Status.NOT_FOUND).entity("{\"error\":\"No order found\"}").build(); } } catch (JsonProcessingException e) { e.printStackTrace(); // Handle exceptions correctly in a production environment return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"Error processing JSON\"}").build(); } } catch (SQLException e) { e.printStackTrace(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"" + e.getMessage() + "\"}").build(); } } } @GET @Path("/order/{requestId}/orderMessage") @Produces(MediaType.APPLICATION_JSON) public Response getOrderMessage(@PathParam("requestId") Long requestId) throws SQLException { DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes try (DatabaseConnectOBI databaseConnection = new DatabaseConnectOBI()) { String orderXmlQuery = "SELECT oo.submit_ord_msg " + "FROM obi_order oo " + "WHERE oo.request_id = ?"; logger.info(orderXmlQuery); try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(orderXmlQuery)) { statement.setLong(1, requestId); try (ResultSet resultSet = statement.executeQuery()) { if (resultSet.next()) { String xmlString = resultSet.getString("SUBMIT_ORD_MSG"); JSONObject jsonObject = XML.toJSONObject(xmlString); ObjectMapper objectMapper = new ObjectMapper(); JsonNode jsonNode = objectMapper.readTree(jsonObject.toString()); return Response.ok(jsonNode).build(); } else { return Response.status(Response.Status.NOT_FOUND).entity("{\"error\":\"No transaction found with the provided ID\"}").build(); } } catch (SQLException e) { e.printStackTrace(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"" + e.getMessage() + "\"}").build(); } } catch (SQLException e) { e.printStackTrace(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"" + e.getMessage() + "\"}").build(); } } catch (JsonProcessingException e) { e.printStackTrace(); // Handle exceptions correctly in a production environment return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"Error processing JSON\"}").build(); } } private Order.Preparation.PreparationLines mapResultSetToPreparationLines(ResultSet resultSet) throws SQLException { Order.Preparation.PreparationLines preparationLines = new Order().new Preparation().new PreparationLines(); preparationLines.setLineFulfillId(resultSet.getInt("LINE_FULFILL_ID")); preparationLines.setLineOrderId(resultSet.getInt("LINE_ORDER_ID")); preparationLines.setPrepIntId(resultSet.getInt("PREP_INT_ID")); preparationLines.setOrderId(resultSet.getString("ORDER_ID")); preparationLines.setRequestId(resultSet.getLong("REQUEST_ID")); preparationLines.setTransactionDate(resultSet.getTimestamp("TRANSACTION_DATE")); preparationLines.setLineItemNo(resultSet.getInt("LINE_ITEM_NO")); preparationLines.setItemId(resultSet.getString("ITEM_ID")); preparationLines.setLineItemOms(resultSet.getString("LINE_ITEM_OMS")); preparationLines.setFulfillQty(resultSet.getInt("FULFILL_QTY")); preparationLines.setValidatedFulfillQty(resultSet.getInt("VALIDATED_FULFILL_QTY")); preparationLines.setFulfillmentSystemCd(resultSet.getString("FULFILLMENT_SYSTEM_CD")); preparationLines.setFulfillmentLocationCd(resultSet.getString("FULFILLMENT_LOCATION_CD")); preparationLines.setStatus(resultSet.getString("STATUS")); preparationLines.setNumeroExpedition(resultSet.getString("NUMERO_EXPEDITION")); preparationLines.setSeasonCode(resultSet.getString("SEASON_CODE")); preparationLines.setFinitionSpeciale(resultSet.getString("FINITION_SPECIALE")); preparationLines.setCarrier(resultSet.getString("CARRIER")); preparationLines.setTrackingCode(resultSet.getString("TRACKING_CODE")); preparationLines.setTrackingUrl(resultSet.getString("TRACKING_URL")); preparationLines.setFdateCreation(resultSet.getTimestamp("FDATE_CREATION")); preparationLines.setFdateModification(resultSet.getTimestamp("FDATE_MODIFICATION")); preparationLines.setToOrlixConsumed(resultSet.getBoolean("TO_ORLIX_CONSUMED")); preparationLines.setRestockingCode(resultSet.getString("RESTOCKING_CODE")); return preparationLines; } private Order.Preparation mapResultSetToPreparation(ResultSet resultSet) throws SQLException { Order.Preparation preparation = new Order().new Preparation(); preparation.setPrepIntId(resultSet.getInt("PREP_INT_ID")); preparation.setPrepId(resultSet.getInt("PREP_ID")); preparation.setOrderId(resultSet.getString("ORDER_ID")); preparation.setRequestId(resultSet.getLong("REQUEST_ID")); preparation.setTransactionDate(resultSet.getTimestamp("TRANSACTION_DATE")); preparation.setFulfillmentSystemCd(resultSet.getString("FULFILLMENT_SYSTEM_CD")); preparation.setFulfillmentLocationCd(resultSet.getString("FULFILLMENT_LOCATION_CD")); preparation.setStatus(resultSet.getString("STATUS")); preparation.setDatePreparation(resultSet.getTimestamp("DATE_PREPARTION")); preparation.setFdateCreation(resultSet.getTimestamp("FDATE_CREATION")); return preparation; } private Order.Reception.ReceptionLines mapResultSetToReceptionLines(ResultSet resultSet) throws SQLException { Order.Reception.ReceptionLines receptionLines = new Order().new Reception().new ReceptionLines(); receptionLines.setLineIntransitId(resultSet.getInt("LINE_INTRANSIT_ID")); receptionLines.setIntransitIntId(resultSet.getInt("INTRANSIT_INT_ID")); receptionLines.setLineFulfillId(resultSet.getInt("LINE_FULFILL_ID")); receptionLines.setTransactionDate(resultSet.getTimestamp("TRANSACTION_DATE")); receptionLines.setLineItemNo(resultSet.getInt("LINE_ITEM_NO")); receptionLines.setItemId(resultSet.getString("ITEM_ID")); receptionLines.setIntransitQty(resultSet.getInt("INTRANSIT_QTY")); receptionLines.setValidatedIntransitQty(resultSet.getInt("VALIDATED_INTRANSIT_QTY")); receptionLines.setIntransitSystemCd(resultSet.getString("INTRANSIT_SYSTEM_CD")); receptionLines.setIntransitLocationCd(resultSet.getString("INTRANSIT_LOCATION_CD")); receptionLines.setStatus(resultSet.getString("STATUS")); receptionLines.setColisId(resultSet.getString("COLIS_ID")); receptionLines.setFdateCreation(resultSet.getTimestamp("FDATE_CREATION")); receptionLines.setFdateReceipt(resultSet.getTimestamp("FDATE_RECEIPT")); receptionLines.setOrderLineShipWeight(resultSet.getDouble("ORDER_LINE_SHIP_WEIGHT")); receptionLines.setTrackingNumber(resultSet.getString("TRACKING_NUMBER")); return receptionLines; } private Order.Reception mapResultSetToReception(ResultSet resultSet) throws SQLException { Order.Reception reception = new Order().new Reception(); reception.setIntransitIntId(resultSet.getInt("INTRANSIT_INT_ID")); reception.setIntransitId(resultSet.getString("INTRANSIT_ID")); reception.setPrepIntId(resultSet.getInt("PREP_INT_ID")); reception.setOrderId(resultSet.getString("ORDER_ID")); reception.setRequestId(resultSet.getLong("REQUEST_ID")); reception.setStatus(resultSet.getString("STATUS")); reception.setTransactionDate(resultSet.getTimestamp("TRANSACTION_DATE")); reception.setIntransitSystemCd(resultSet.getString("INTRANSIT_SYSTEM_CD")); reception.setIntransitLocationCd(resultSet.getString("INTRANSIT_LOCATION_CD")); reception.setFdateReceipt(resultSet.getTimestamp("FDATE_RECEIPT")); reception.setFdateCreation(resultSet.getTimestamp("FDATE_CREATION")); return reception; } private Order.History mapResultSetToOrderLinesHistory(ResultSet resultSet) throws SQLException { Order.History orderLinesHistory = new Order().new History(); orderLinesHistory.setStatusId(resultSet.getInt("STATUS_ID")); orderLinesHistory.setId(resultSet.getLong("LINE_ORDER_ID")); orderLinesHistory.setStatus(resultSet.getString("STATUS")); orderLinesHistory.setTransactionDate(resultSet.getTimestamp("TRANSACTION_DATE")); orderLinesHistory.setFdateCreation(resultSet.getTimestamp("FDATE_CREATION")); return orderLinesHistory; } private Order.History mapResultSetToOrderHistory(ResultSet resultSet) throws SQLException { Order.History orderHistory = new Order().new History(); orderHistory.setStatusId(resultSet.getInt("STATUS_ID")); orderHistory.setId(resultSet.getLong("REQUEST_ID")); orderHistory.setStatus(resultSet.getString("STATUS")); orderHistory.setTransactionDate(resultSet.getTimestamp("TRANSACTION_DATE")); orderHistory.setFdateCreation(resultSet.getTimestamp("FDATE_CREATION")); return orderHistory; } private Order.Lines mapResultSetToOrderLine(ResultSet resultSet) throws SQLException { Order.Lines orderLine = new Order().new Lines(); orderLine.setLineOrderId(resultSet.getLong("LINE_ORDER_ID")); orderLine.setLineItemNo(resultSet.getInt("LINE_ITEM_NO")); orderLine.setLineItemOms(resultSet.getString("LINE_ITEM_OMS")); orderLine.setItemId(resultSet.getString("ITEM_ID")); orderLine.setOrderedLineQty(resultSet.getInt("ORDERED_LINE_QTY")); orderLine.setStatus(resultSet.getString("STATUS")); orderLine.setTransactionDate(resultSet.getTimestamp("TRANSACTION_DATE")); orderLine.setShippingAgent(resultSet.getString("SHIPPING_AGENT")); orderLine.setTrackingNumber(resultSet.getString("TRACKING_NUMBER")); orderLine.setFulfillmentId(resultSet.getString("FULFILLMENT_ID")); orderLine.setCartonNumber(resultSet.getString("CARTON_NUMBER")); orderLine.setFdateCreation(resultSet.getTimestamp("FDATE_CREATION")); orderLine.setConsumed(resultSet.getBoolean("CONSUMED")); return orderLine; } private Order mapResultSetToOrderList(ResultSet resultSet) throws SQLException { Order order = new Order(); Order.Meta meta = new Order.Meta(); Order.Common common = order.new Common(); Order.Common.StatusData statusData = common.new StatusData(); Order.Common.Transaction transaction = common.new Transaction(); meta.setId(resultSet.getLong("REQUEST_ID")); order.setMeta(meta); statusData.setCode(resultSet.getString("STATUS")); statusData.setTitle("TEST"); // TODO A VOIR common.setOrderId(resultSet.getString("ORDER_ID")); transaction.setTransactionDate(resultSet.getTimestamp("TRANSACTION_DATE")); transaction.setTransactionTypeDescription(resultSet.getString("TRANSACTION_TYPE_DESCRIPTION")); common.setStatusData(statusData); common.setTransaction(transaction); order.setMeta(meta); order.setCommon(common); return order; } private Order mapResultSetToOrder(ResultSet resultSet) throws SQLException { Order order = new Order(); Order.Meta meta = new Order.Meta(); Order.Common common = order.new Common(); Order.Common.StatusData statusData = common.new StatusData(); Order.Common.Transaction transaction = common.new Transaction(); meta.setId(resultSet.getLong("REQUEST_ID")); order.setMeta(meta); statusData.setCode(resultSet.getString("STATUS")); statusData.setTitle("TEST"); // TODO A VOIR common.setOrderId(resultSet.getString("ORDER_ID")); common.setRequestingLocationCd(resultSet.getString("REQUESTING_LOCATION_CD")); common.setRequestingSystemCd(resultSet.getString("REQUESTING_SYSTEM_CD")); common.setCustomerId(resultSet.getString("CUSTOMER_ID")); common.setFdateCreation(resultSet.getTimestamp("FDATE_CREATION")); common.setConsumed(resultSet.getBoolean("CONSUMED")); common.setShipforpickupLocationCd(resultSet.getString("SHIPFORPICKUP_LOCATION_CD")); common.setShipforpickupSystemCd(resultSet.getString("SHIPFORPICKUP_SYSTEM_CD")); transaction.setTransactionNo(resultSet.getString("TRANSACTION_NO")); transaction.setTransactionTypeId(resultSet.getInt("TRANSACTION_TYPE_ID")); transaction.setTransactionDate(resultSet.getTimestamp("TRANSACTION_DATE")); transaction.setTransactionTypeDescription(resultSet.getString("TRANSACTION_TYPE_DESCRIPTION")); common.setStatusData(statusData); common.setTransaction(transaction); order.setMeta(meta); order.setCommon(common); return order; } }