feat: add obi order visualization
parent
0d72f35ce1
commit
2831d87ab2
9
pom.xml
9
pom.xml
|
|
@ -19,7 +19,14 @@
|
|||
<dependency>
|
||||
<groupId>com.oracle.database.jdbc</groupId>
|
||||
<artifactId>ojdbc8</artifactId>
|
||||
<version>18.3.0.0</version> <!-- Assurez-vous d'utiliser la version compatible avec votre Oracle Database -->
|
||||
<version>18.3.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JDBC Driver for postgresql Database https://github.com/pgjdbc/pgjdbc -->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>42.2.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Jersey for JAX-RS (Java API for RESTful Web Services) -->
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ public class DatabaseConnectDOTSOFT implements AutoCloseable {
|
|||
try {
|
||||
Properties dbProperties = loadDatabaseProperties();
|
||||
|
||||
String url = dbProperties.getProperty(environment + ".db.url");
|
||||
String userpassword = dbProperties.getProperty(environment + ".db." + username + ".password");
|
||||
String url = dbProperties.getProperty(environment + ".dotsoft.db.url");
|
||||
String userpassword = dbProperties.getProperty(environment + ".dotsoft.db." + username + ".password");
|
||||
|
||||
connection = DriverManager.getConnection(url, username, userpassword);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,73 @@
|
|||
package com.example.services;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class DatabaseConnectOBI implements AutoCloseable {
|
||||
private static final Logger logger = LoggerFactory.getLogger(DatabaseConnectOBI.class);
|
||||
|
||||
private Connection connection;
|
||||
|
||||
public DatabaseConnectOBI(String username) throws SQLException {
|
||||
String environment = loadEnvironment();
|
||||
|
||||
//TODO TO DELETE
|
||||
environment="preprod";
|
||||
|
||||
try {
|
||||
Properties dbProperties = loadDatabaseProperties();
|
||||
|
||||
String url = dbProperties.getProperty(environment + ".obi.db.url");
|
||||
String userpassword = dbProperties.getProperty(environment + ".obi.db." + username + ".password");
|
||||
logger.info(url);
|
||||
logger.info(username);
|
||||
logger.info(userpassword);
|
||||
connection = DriverManager.getConnection(url, username, userpassword);
|
||||
|
||||
logger.info("OBI Connection OK for user " + username + " on environment " + environment);
|
||||
} catch (SQLException e) {
|
||||
logger.error("Failed to connect to OBI database for user " + username + " on environment " + environment, e);
|
||||
throw e; // re-throw the exception
|
||||
}
|
||||
}
|
||||
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws SQLException {
|
||||
if (connection != null && !connection.isClosed()) {
|
||||
connection.close();
|
||||
logger.info("OBI Connection closed");
|
||||
}
|
||||
}
|
||||
|
||||
private String loadEnvironment() {
|
||||
Properties envProperties = loadProperties("env.properties");
|
||||
return envProperties.getProperty("environment");
|
||||
}
|
||||
|
||||
private Properties loadDatabaseProperties() {
|
||||
Properties dbProperties = loadProperties("db.properties");
|
||||
return dbProperties;
|
||||
}
|
||||
|
||||
private Properties loadProperties(String fileName) {
|
||||
Properties properties = new Properties();
|
||||
try (InputStream input = getClass().getClassLoader().getResourceAsStream(fileName)) {
|
||||
properties.load(input);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
// Handle the exception correctly for your application
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
|
|
@ -16,17 +16,19 @@ public class DatabaseConnectXADMIN implements AutoCloseable {
|
|||
private Connection connection;
|
||||
|
||||
public DatabaseConnectXADMIN(String username) throws SQLException {
|
||||
String environment = loadEnvironment();
|
||||
|
||||
try {
|
||||
Properties dbProperties = loadDatabaseProperties();
|
||||
|
||||
String url = dbProperties.getProperty("xadmin.db.url");
|
||||
String userpassword = dbProperties.getProperty("xadmin.db." + username + ".password");
|
||||
String url = dbProperties.getProperty(environment + ".xadmin.db.url");
|
||||
String userpassword = dbProperties.getProperty(environment + ".xadmin.db." + username + ".password");
|
||||
|
||||
connection = DriverManager.getConnection(url, username, userpassword);
|
||||
|
||||
logger.info("XADMIN Connection OK for user " + username);
|
||||
logger.info("XADMIN Connection OK for user " + username + " on environment " + environment);
|
||||
} catch (SQLException e) {
|
||||
logger.error("Failed to connect to XADMIN database for user " + username, e);
|
||||
logger.error("Failed to connect to XADMIN database for user " + username + " on environment " + environment, e);
|
||||
throw e; // re-throw the exception
|
||||
}
|
||||
}
|
||||
|
|
@ -43,6 +45,11 @@ public class DatabaseConnectXADMIN implements AutoCloseable {
|
|||
}
|
||||
}
|
||||
|
||||
private String loadEnvironment() {
|
||||
Properties envProperties = loadProperties("env.properties");
|
||||
return envProperties.getProperty("environment");
|
||||
}
|
||||
|
||||
private Properties loadDatabaseProperties() {
|
||||
Properties dbProperties = loadProperties("db.properties");
|
||||
return dbProperties;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,378 @@
|
|||
package com.example.services;
|
||||
|
||||
import com.example.services.order.Order;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
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 javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
@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) {
|
||||
|
||||
DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes
|
||||
|
||||
try (DatabaseConnectOBI databaseConnection = new DatabaseConnectOBI("mobi")) {
|
||||
String countQuery = "SELECT COUNT(*) FROM obi_order oo ";
|
||||
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<String> conditions = new ArrayList<>();
|
||||
if (q != null && !q.isEmpty()) {
|
||||
conditions.add(" oo.order_id LIKE ? ");
|
||||
}
|
||||
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 + "%");
|
||||
}
|
||||
|
||||
ResultSet countResultSet = countStatement.executeQuery();
|
||||
countResultSet.next();
|
||||
int total = countResultSet.getInt(1);
|
||||
|
||||
ResultSet resultSet = statement.executeQuery(); {
|
||||
List<Order> 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);
|
||||
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("mobi")) {
|
||||
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.submit_ord_msg, 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);
|
||||
|
||||
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<Order.Lines> 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<Order.History> orderLinesHistoryList = new ArrayList<>();
|
||||
|
||||
while (orderLinesHistoryResultSet.next()) {
|
||||
orderLinesHistoryList.add(mapResultSetToOrderLinesHistory(orderLinesHistoryResultSet));
|
||||
}
|
||||
|
||||
orderLinesList.get(orderLinesList.size() - 1).setHistory(orderLinesHistoryList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
order.setLines(orderLinesList);
|
||||
}
|
||||
|
||||
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<Order.History> orderHistoryList = new ArrayList<>();
|
||||
|
||||
while (orderHistoryResultSet.next()) {
|
||||
orderHistoryList.add(mapResultSetToOrderHistory(orderHistoryResultSet));
|
||||
}
|
||||
|
||||
order.setHistory(orderHistoryList);
|
||||
}
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonResponse = objectMapper.writeValueAsString(order);
|
||||
|
||||
return Response.ok(jsonResponse).build();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"" + e.getMessage() + "\"}").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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
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");
|
||||
|
||||
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.setSubmitOrdMsg(resultSet.getString("SUBMIT_ORD_MSG"));
|
||||
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"));
|
||||
|
||||
// get subtotal, tax, total
|
||||
String xmlString = resultSet.getString("SUBMIT_ORD_MSG");
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder;
|
||||
|
||||
try {
|
||||
builder = factory.newDocumentBuilder();
|
||||
Document doc = builder.parse(new InputSource(new StringReader(xmlString)));
|
||||
doc.getDocumentElement().normalize();
|
||||
|
||||
XPathFactory xPathfactory = XPathFactory.newInstance();
|
||||
XPath xpath = xPathfactory.newXPath();
|
||||
|
||||
String firstName = xpath.evaluate("//sold_to_customer/name/first", doc.getDocumentElement());
|
||||
String lastName = xpath.evaluate("//sold_to_customer/name/last", doc.getDocumentElement());
|
||||
|
||||
common.setCustomerFirstName(firstName);
|
||||
common.setCustomerLastName(lastName);
|
||||
|
||||
String transaction_subtotal = xpath.evaluate("//transaction_subtotal", doc.getDocumentElement());
|
||||
String transaction_tax = xpath.evaluate("//transaction_tax", doc.getDocumentElement());
|
||||
String transaction_total = xpath.evaluate("//transaction_total", doc.getDocumentElement());
|
||||
|
||||
transaction.setTransactionSubtotal(null == transaction_subtotal ? null : new BigDecimal(transaction_subtotal));
|
||||
transaction.setTransactionTax(null == transaction_tax ? null : new BigDecimal(transaction_tax));
|
||||
transaction.setTransactionTotal(null == transaction_total ? null : new BigDecimal(transaction_total));
|
||||
|
||||
} catch (ParserConfigurationException | SAXException | IOException | XPathExpressionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
common.setStatusData(statusData);
|
||||
common.setTransaction(transaction);
|
||||
|
||||
order.setMeta(meta);
|
||||
order.setCommon(common);
|
||||
|
||||
return order;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,235 @@
|
|||
package com.example.services.order;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
public class Order {
|
||||
private Meta meta;
|
||||
private Common common;
|
||||
private List<Lines> lines = new ArrayList<>();
|
||||
private List<History> history = new ArrayList<>();
|
||||
|
||||
// getters and setters for Order
|
||||
public Meta getMeta() { return meta; }
|
||||
public void setMeta(Meta meta) { this.meta = meta; }
|
||||
public Common getCommon() { return common; }
|
||||
public void setCommon(Common common) { this.common = common; }
|
||||
public List<Lines> getLines() { return lines; }
|
||||
public void setLines(List<Lines> lines) { this.lines = lines; }
|
||||
public List<History> getHistory() { return history; }
|
||||
public void setHistory(List<History> history) { this.history = history; }
|
||||
|
||||
public static class Meta {
|
||||
private long id;
|
||||
|
||||
// getters and setters
|
||||
|
||||
public String getModel() {
|
||||
return "Order";
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
public class Common {
|
||||
private String orderId;
|
||||
private String requestingLocationCd;
|
||||
private String requestingSystemCd;
|
||||
private String customerId;
|
||||
private String customerFirstName;
|
||||
private String customerLastName;
|
||||
private String submitOrdMsg;
|
||||
private Timestamp fdateCreation;
|
||||
private boolean consumed;
|
||||
private String shipforpickupLocationCd;
|
||||
private String shipforpickupSystemCd;
|
||||
private StatusData statusData;
|
||||
private Transaction transaction;
|
||||
|
||||
// getters for Common
|
||||
public String getOrderId() { return orderId; }
|
||||
public String getRequestingLocationCd() { return requestingLocationCd; }
|
||||
public String getRequestingSystemCd() { return requestingSystemCd; }
|
||||
public String getCustomerId() { return customerId; }
|
||||
public String getCustomerFirstName() { return customerFirstName; }
|
||||
public String getCustomerLastName() { return customerLastName; }
|
||||
public String getSubmitOrdMsg() { return submitOrdMsg; }
|
||||
public String getFdateCreation() {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXXX")
|
||||
.withZone(ZoneId.of("Europe/Paris"));
|
||||
|
||||
return fdateCreation != null ? formatter.format(fdateCreation.toInstant()) : "";
|
||||
}
|
||||
public boolean isConsumed() { return consumed; }
|
||||
public String getShipforpickupLocationCd() { return shipforpickupLocationCd; }
|
||||
public String getShipforpickupSystemCd() { return shipforpickupSystemCd; }
|
||||
|
||||
// setters for Common
|
||||
public void setOrderId(String orderId) { this.orderId = orderId; }
|
||||
public void setRequestingLocationCd(String requestingLocationCd) { this.requestingLocationCd = requestingLocationCd; }
|
||||
public void setRequestingSystemCd(String requestingSystemCd) { this.requestingSystemCd = requestingSystemCd; }
|
||||
public void setCustomerId(String customerId) { this.customerId = customerId; }
|
||||
public void setCustomerFirstName(String customerFirstName) { this.customerFirstName = customerFirstName; }
|
||||
public void setCustomerLastName(String customerLastName) { this.customerLastName = customerLastName; }
|
||||
public void setSubmitOrdMsg(String submitOrdMsg) { this.submitOrdMsg = submitOrdMsg; }
|
||||
public void setFdateCreation(Timestamp fdateCreation) { this.fdateCreation = fdateCreation; }
|
||||
public void setConsumed(boolean consumed) { this.consumed = consumed; }
|
||||
public void setShipforpickupLocationCd(String shipforpickupLocationCd) { this.shipforpickupLocationCd = shipforpickupLocationCd; }
|
||||
public void setShipforpickupSystemCd(String shipforpickupSystemCd) { this.shipforpickupSystemCd = shipforpickupSystemCd; }
|
||||
|
||||
public class StatusData {
|
||||
private String code;
|
||||
private String title;
|
||||
|
||||
// getters for StatusData
|
||||
public String getCode() { return code; }
|
||||
public String getTitle() { return title; }
|
||||
|
||||
// setters for StatusData
|
||||
public void setCode(String code) { this.code = code; }
|
||||
public void setTitle(String title) { this.title = title; }
|
||||
}
|
||||
|
||||
// getters for order/statusdata
|
||||
public StatusData getStatusData() { return statusData; }
|
||||
|
||||
// setters for order/statusdata
|
||||
public void setStatusData(StatusData statusData) { this.statusData = statusData; }
|
||||
|
||||
public class Transaction {
|
||||
|
||||
private Integer transactionTypeId;
|
||||
private Timestamp transactionDate;
|
||||
private String transactionNo;
|
||||
private String transactionTypeDescription;
|
||||
private BigDecimal transactionSubtotal;
|
||||
private BigDecimal transactionTax;
|
||||
private BigDecimal transactionTotal;
|
||||
|
||||
// getters for Transaction
|
||||
public Integer getTransactionTypeId() { return transactionTypeId; }
|
||||
public String getTransactionDate() {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXXX")
|
||||
.withZone(ZoneId.of("Europe/Paris"));
|
||||
|
||||
return transactionDate != null ? formatter.format(transactionDate.toInstant()) : "";
|
||||
}
|
||||
public String getTransactionNo() { return transactionNo; }
|
||||
public String getTransactionTypeDescription() { return transactionTypeDescription; }
|
||||
public BigDecimal getTransactionSubtotal() { return transactionSubtotal; }
|
||||
public BigDecimal getTransactionTax() { return transactionTax; }
|
||||
public BigDecimal getTransactionTotal() { return transactionTotal; }
|
||||
|
||||
// setters for Transaction
|
||||
public void setTransactionTypeId(Integer transactionTypeId) { this.transactionTypeId = transactionTypeId; }
|
||||
public void setTransactionDate(Timestamp transactionDate) { this.transactionDate = transactionDate; }
|
||||
public void setTransactionNo(String transactionNo) { this.transactionNo = transactionNo; }
|
||||
public void setTransactionTypeDescription(String transactionTypeDescription) { this.transactionTypeDescription = transactionTypeDescription; }
|
||||
public void setTransactionSubtotal(BigDecimal transactionSubtotal) { this.transactionSubtotal = transactionSubtotal; }
|
||||
public void setTransactionTax(BigDecimal transactionTax) { this.transactionTax = transactionTax; }
|
||||
public void setTransactionTotal(BigDecimal transactionTotal) { this.transactionTotal = transactionTotal; }
|
||||
}
|
||||
|
||||
// getters for order/transaction
|
||||
public Transaction getTransaction() { return transaction; }
|
||||
|
||||
// setters for order/transaction
|
||||
public void setTransaction(Transaction transaction) { this.transaction = transaction; }
|
||||
}
|
||||
|
||||
public class Lines {
|
||||
private Long lineOrderId;
|
||||
private Integer lineItemNo;
|
||||
private String orderId;
|
||||
private Long requestId;
|
||||
private String lineItemOms;
|
||||
private String itemId;
|
||||
private Integer orderedLineQty;
|
||||
private String status;
|
||||
private Timestamp transactionDate;
|
||||
private String shippingAgent;
|
||||
private String trackingNumber;
|
||||
private String fulfillmentId;
|
||||
private String cartonNumber;
|
||||
private Timestamp fdateCreation;
|
||||
private Boolean consumed;
|
||||
private List<History> history = new ArrayList<>();
|
||||
|
||||
// getters
|
||||
public Long getLineOrderId() { return lineOrderId; }
|
||||
public Integer getLineItemNo() { return lineItemNo; }
|
||||
public String getOrderId() { return orderId; }
|
||||
public Long getRequestId() { return requestId; }
|
||||
public String getLineItemOms() { return lineItemOms; }
|
||||
public String getItemId() { return itemId; }
|
||||
public Integer getOrderedLineQty() { return orderedLineQty; }
|
||||
public String getStatus() { return status; }
|
||||
public Timestamp getTransactionDate() { return transactionDate; }
|
||||
public String getShippingAgent() { return shippingAgent; }
|
||||
public String getTrackingNumber() { return trackingNumber; }
|
||||
public String getFulfillmentId() { return fulfillmentId; }
|
||||
public String getCartonNumber() { return cartonNumber; }
|
||||
public Timestamp getFdateCreation() { return fdateCreation; }
|
||||
public Boolean isConsumed() { return consumed; }
|
||||
public List<History> getHistory() { return history; }
|
||||
|
||||
// setters
|
||||
public void setLineOrderId(Long lineOrderId) { this.lineOrderId = lineOrderId; }
|
||||
public void setLineItemNo(Integer lineItemNo) { this.lineItemNo = lineItemNo; }
|
||||
public void setOrderId(String orderId) { this.orderId = orderId; }
|
||||
public void setRequestId(Long requestId) { this.requestId = requestId; }
|
||||
public void setLineItemOms(String lineItemOms) { this.lineItemOms = lineItemOms; }
|
||||
public void setItemId(String itemId) { this.itemId = itemId; }
|
||||
public void setOrderedLineQty(Integer orderedLineQty) { this.orderedLineQty = orderedLineQty; }
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
public void setTransactionDate(Timestamp transactionDate) { this.transactionDate = transactionDate; }
|
||||
public void setShippingAgent(String shippingAgent) { this.shippingAgent = shippingAgent; }
|
||||
public void setTrackingNumber(String trackingNumber) { this.trackingNumber = trackingNumber; }
|
||||
public void setFulfillmentId(String fulfillmentId) { this.fulfillmentId = fulfillmentId; }
|
||||
public void setCartonNumber(String cartonNumber) { this.cartonNumber = cartonNumber; }
|
||||
public void setFdateCreation(Timestamp fdateCreation) { this.fdateCreation = fdateCreation; }
|
||||
public void setConsumed(Boolean consumed) { this.consumed = consumed; }
|
||||
public void setHistory(List<History> history) { this.history = history; }
|
||||
}
|
||||
|
||||
public class History {
|
||||
private Integer statusId;
|
||||
private Long Id;
|
||||
private String status;
|
||||
private Timestamp transactionDate;
|
||||
private Timestamp fdateCreation;
|
||||
|
||||
// Getters
|
||||
public Integer getStatusId() { return statusId; }
|
||||
public Long getId() { return Id; }
|
||||
public String getStatus() { return status; }
|
||||
public String getTransactionDate() {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXXX")
|
||||
.withZone(ZoneId.of("Europe/Paris"));
|
||||
|
||||
return fdateCreation != null ? formatter.format(transactionDate.toInstant()) : "";
|
||||
}
|
||||
public String getFdateCreation() {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXXX")
|
||||
.withZone(ZoneId.of("Europe/Paris"));
|
||||
|
||||
return fdateCreation != null ? formatter.format(fdateCreation.toInstant()) : "";
|
||||
}
|
||||
|
||||
// Setters
|
||||
public void setStatusId(Integer statusId) { this.statusId = statusId; }
|
||||
public void setId(Long Id) { this.Id = Id; }
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
public void setTransactionDate(Timestamp transactionDate) { this.transactionDate = transactionDate; }
|
||||
public void setFdateCreation(Timestamp fdateCreation) { this.fdateCreation = fdateCreation; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
# Development environment settings (dev)
|
||||
dev.db.url=jdbc:oracle:thin:@v-aspd-b01-irdc.adic.lan:1521/MASPDI
|
||||
dev.db.oai.password=base
|
||||
dev.db.com02.password=B1Xto9pAbtBCOxuecG7W
|
||||
# Development DOTSOFT environment settings
|
||||
dev.dotsoft.db.url=jdbc:oracle:thin:@v-aspd-b01-irdc.adic.lan:1521/MASPDI
|
||||
dev.dotsoft.db.oai.password=base
|
||||
dev.dotsoft.db.com02.password=B1Xto9pAbtBCOxuecG7W
|
||||
|
||||
# Pre-production environment settings (preprod)
|
||||
preprod.db.url=jdbc:oracle:thin:@v-aspd-b01-ii-d.adic.lan:1521/IASPDI
|
||||
preprod.db.oai.password=base
|
||||
preprod.db.com02.password=B1Xto9pAbtBCOxuecG7W
|
||||
# Pre-production DOTSOFT environment settings
|
||||
preprod.dotsoft.db.url=jdbc:oracle:thin:@v-aspd-b01-ii-d.adic.lan:1521/IASPDI
|
||||
preprod.dotsoft.db.oai.password=base
|
||||
preprod.dotsoft.db.com02.password=B1Xto9pAbtBCOxuecG7W
|
||||
|
||||
# Production environment settings (prod)
|
||||
prod.db.url=jdbc:oracle:thin:@v-aspd-b03-ip-d.adic.lan:1521/PASPDI
|
||||
prod.db.oai.password=base
|
||||
prod.db.com02.password=com20
|
||||
# Production DOTSOFT environment settings
|
||||
prod.dotsoft.db.url=jdbc:oracle:thin:@v-aspd-b03-ip-d.adic.lan:1521/PASPDI
|
||||
prod.dotsoft.db.oai.password=base
|
||||
prod.dotsoft.db.com02.password=com20
|
||||
|
||||
# XSTORE environment settings
|
||||
xstore.db.url=jdbc:oracle:thin:@HOST:1521/XSTORE
|
||||
|
|
@ -19,5 +19,14 @@ xstore.db.dtv.password=dtv
|
|||
xstore.db.repqueue.password=repqueue
|
||||
|
||||
# XADMIN environment settings
|
||||
xadmin.db.url=jdbc:oracle:thin:@p-ODBG-b01-ipDC.tech.ikks.lan:1522/PXSTOREI
|
||||
xadmin.db.dtv.password=oY3poRSprOuqasO
|
||||
prod.xadmin.db.url=jdbc:oracle:thin:@p-ODBG-b01-ipDC.tech.ikks.lan:1522/PXSTOREI
|
||||
prod.xadmin.db.dtv.password=oY3poRSprOuqasO
|
||||
|
||||
# Pre-production OBI environment settings
|
||||
preprod.obi.db.url=jdbc:postgresql://v-tlnd-b01-iidc.tech.ikks.lan:5432/mirobi
|
||||
preprod.obi.db.mobi.password=obi
|
||||
|
||||
# production OBI environment settings
|
||||
prod.obi.db.url=FREDjdbc:postgresql://v-tlnd-b01-ipdc.tech.ikks.lan:5432/pirobi
|
||||
prod.obi.db.pobi.password=FREDy!h`AGZjGVa.ae;(N
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue