Merge pull request 'feature/issue-1/ws-read-store-detail' (#5) from feature/issue-1/ws-read-store-detail into dev

Reviewed-on: #5
pull/6/head
Frédérik Benoist 2024-01-02 21:07:16 +01:00
commit 0d72f35ce1
33 changed files with 3755 additions and 479 deletions

38
pom.xml
View File

@ -18,8 +18,8 @@
<!-- JDBC Driver for Oracle Database -->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc10</artifactId>
<version>19.8.0.0</version> <!-- Assurez-vous d'utiliser la version compatible avec votre Oracle Database -->
<artifactId>ojdbc8</artifactId>
<version>18.3.0.0</version> <!-- Assurez-vous d'utiliser la version compatible avec votre Oracle Database -->
</dependency>
<!-- Jersey for JAX-RS (Java API for RESTful Web Services) -->
@ -44,7 +44,7 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version> <!-- Remplacez par la version appropriée -->
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
@ -52,9 +52,39 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.0</version> <!-- Utilisez la dernière version disponible -->
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.13.0</version> <!-- Use the latest version here -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.13</version>
</dependency>
<!-- LOG dependencies -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.3.0</version>
</dependency>
<!-- LOG dependencies -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.3.0</version>
</dependency>
<!-- LOG dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
</dependency>
</dependencies>
<build>

View File

@ -27,6 +27,7 @@ public class CorsFilters implements Filter {
// Autoriser les en-têtes spécifiés dans la requête
httpResponse.setHeader("Access-Control-Allow-Headers", "Content-Type");
httpResponse.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
// Permettre l'envoi de cookies (si nécessaire)
httpResponse.setHeader("Access-Control-Allow-Credentials", "true");

View File

@ -0,0 +1,144 @@
package com.example.services;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Arrays;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Path("/auth")
public class AuthService {
private static final Logger logger = LoggerFactory.getLogger(AuthService.class);
public class UserAbilityRules {
private List<String> rules;
public UserAbilityRules() {
this.rules = Arrays.asList("admin", "editor");
}
public List<String> getRules() {
return rules;
}
}
public class UserData {
private int id;
private String fullName;
private String username;
private String avatar;
private String email;
private String role;
public UserData() {
this.id = 1;
this.fullName = "Frédérik Benoist";
this.username = "fbenoist";
this.avatar = "/images/avatars/avatar-1.png";
this.email = "admin@demo.com";
this.role = "admin";
}
public int getId() {
return id;
}
public String getFullName() {
return fullName;
}
public String getUsername() {
return username;
}
public String getAvatar() {
return avatar;
}
public String getEmail() {
return email;
}
public String getRole() {
return role;
}
}
public class AuthResponse {
private String accessToken;
private UserAbilityRules userAbilityRules;
private UserData userData;
public AuthResponse() {
this.accessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MX0.fhc3wykrAnRpcKApKhXiahxaOe8PSHatad31NuIZ0Zg";
this.userAbilityRules = new UserAbilityRules();
this.userData = new UserData();
}
public String getAccessToken() {
return accessToken;
}
public UserAbilityRules getUserAbilityRules() {
return userAbilityRules;
}
public UserData getUserData() {
return userData;
}
}
@POST
@Path("/login")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public AuthResponse login(Credentials credentials) {
logger.info(credentials.getUsername() + " is attempting to login");
if (!isValidPassword(credentials.getPassword())) {
logger.info("User " + credentials.getUsername() + " failed to login");
throw new WebApplicationException("Invalid password", Response.Status.UNAUTHORIZED);
}
logger.info("User " + credentials.getUsername() + " successfully logged in");
return new AuthResponse();
}
private boolean isValidPassword(String password) {
return "admin123".equals(password) || "support123".equals(password);
}
public static class Credentials {
private String username;
private String password;
// Getter pour username
public String getUsername() {
return username;
}
// Setter pour username
public void setUsername(String username) {
this.username = username;
}
// Getter pour password
public String getPassword() {
return password;
}
// Setter pour password
public void setPassword(String password) {
this.password = password;
}
}
}

View File

@ -0,0 +1,68 @@
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 DatabaseConnectDOTSOFT implements AutoCloseable {
private static final Logger logger = LoggerFactory.getLogger(DatabaseConnectDOTSOFT.class);
private Connection connection;
public DatabaseConnectDOTSOFT(String username) throws SQLException {
String environment = loadEnvironment();
try {
Properties dbProperties = loadDatabaseProperties();
String url = dbProperties.getProperty(environment + ".db.url");
String userpassword = dbProperties.getProperty(environment + ".db." + username + ".password");
connection = DriverManager.getConnection(url, username, userpassword);
logger.info("DOTSOFT Connection OK for user " + username + " on environment " + environment);
} catch (SQLException e) {
logger.error("Failed to connect to DOTSOFT 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("DOTSOFT 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;
}
}

View File

@ -0,0 +1,61 @@
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 DatabaseConnectXADMIN implements AutoCloseable {
private static final Logger logger = LoggerFactory.getLogger(DatabaseConnectXADMIN.class);
private Connection connection;
public DatabaseConnectXADMIN(String username) throws SQLException {
try {
Properties dbProperties = loadDatabaseProperties();
String url = dbProperties.getProperty("xadmin.db.url");
String userpassword = dbProperties.getProperty("xadmin.db." + username + ".password");
connection = DriverManager.getConnection(url, username, userpassword);
logger.info("XADMIN Connection OK for user " + username);
} catch (SQLException e) {
logger.error("Failed to connect to XADMIN database for user " + username, 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("XADMIN Connection closed");
}
}
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;
}
}

View File

@ -0,0 +1,61 @@
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 DatabaseConnectXSTORE implements AutoCloseable {
private static final Logger logger = LoggerFactory.getLogger(DatabaseConnectXSTORE.class);
private Connection connection;
public DatabaseConnectXSTORE(String dbHost, String username) throws SQLException {
try {
Properties dbProperties = loadDatabaseProperties();
String url = dbProperties.getProperty("xstore.db.url").replace("HOST", dbHost);
String userpassword = dbProperties.getProperty("xstore.db." + username + ".password");
connection = DriverManager.getConnection(url, username, userpassword);
logger.info("XSTORE Connection OK for user " + username + " on host " + dbHost);
} catch (SQLException e) {
logger.error("Failed to connect to XSTORE database for user " + username + " on host " + dbHost, 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("XSTORE Connection closed");
}
}
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;
}
}

View File

@ -1,26 +0,0 @@
package com.example.services;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DatabaseConnection implements AutoCloseable {
private Connection connection;
public DatabaseConnection(String dbHost, String username, String password) throws SQLException {
// Initialiser votre connexion à la base de données ici
connection = DriverManager.getConnection("jdbc:oracle:thin:@" + dbHost + ":1521/XSTORE", username, password);
}
public Connection getConnection() {
return connection;
}
@Override
public void close() throws SQLException {
if (connection != null && !connection.isClosed()) {
connection.close();
}
}
}

View File

@ -1,28 +0,0 @@
package com.example.services;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DatabaseConnectionDS implements AutoCloseable {
private Connection connection;
public DatabaseConnectionDS(String username, String password) throws SQLException {
// Initialiser votre connexion à la base de données ici
// jdbc:oracle:thin:@v-aspd-b01-ii-d.adic.lan:1521/IASPDI
// jdbc:oracle:thin:@v-aspd-b01-irdc.adic.lan:1521/MASPDI
connection = DriverManager.getConnection("jdbc:oracle:thin:@v-aspd-b01-irdc.adic.lan:1521/MASPDI", username, password);
}
public Connection getConnection() {
return connection;
}
@Override
public void close() throws SQLException {
if (connection != null && !connection.isClosed()) {
connection.close();
}
}
}

View File

@ -1,52 +0,0 @@
package com.example.services;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@Path("/database")
public class DatabaseService {
@GET
@Path("/replication")
@Produces(MediaType.APPLICATION_JSON)
public Response getCount(@QueryParam("dbHost") String dbHost) {
if (dbHost == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"dbHost parameter is required\"}").build();
}
DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes
try (DatabaseConnection databaseConnection = new DatabaseConnection(dbHost, "repqueue", "repqueue")) {
String query = "SELECT COUNT(*) FROM CTL_REPLICATION_QUEUE";
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query);
ResultSet resultSet = statement.executeQuery()) {
if (resultSet.next()) {
long count = resultSet.getLong(1);
// Construction manuelle de la réponse JSON
String jsonResponse = "{\"count\":" + count + "}";
return Response.ok(jsonResponse).build();
}
}
} catch (SQLException e) {
e.printStackTrace(); // Gérer les exceptions correctement dans un environnement de production
// Construction de la réponse JSON en cas d'erreur
String errorResponse = "{\"error\":\"" + e.getMessage() + "\"}";
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponse).build();
}
return null;
}
}

View File

@ -0,0 +1,114 @@
package com.example.services;
import com.example.services.flux.bl.*;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
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.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Path("/flux")
public class FluxService {
private static final Logger logger = LoggerFactory.getLogger(DatabaseConnectDOTSOFT.class);
/**
* Retrieves the FluxBlNotSent object from the server.
*
* @return the FluxBlNotSent object obtained from the server
*/
@GET
@Path("/bl/notsent")
@Produces(MediaType.APPLICATION_JSON)
public Response getFluxBlNotSent() {
DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes
try (DatabaseConnectDOTSOFT databaseConnection = new DatabaseConnectDOTSOFT("com02")) {
String query = "WITH err_bl AS (" +
"SELECT id_bon_livraison FROM omni.aspd_xsto_adrr_bl WHERE job_id = (" +
"SELECT MAX(job_id) FROM omni.aspd_xsto_adrr_bl))" +
"SELECT DISTINCT s.id_distrib, dis.libelle AS libelle_dis, s.id_structure, TRIM(s.nom) AS nom, s.enseigne, mq.code AS marque, m.code_saison, p.code_reference AS ref_r," +
"p.code_reference || '-' || pavc.code_externe AS ref_rc, p.code_reference || '-' || pavc.code_externe || '-' || TRIM(p.troc_axe2) AS ref_rct, p.nom AS nom_produit," +
"p.id_produit, bl.code_externe, bl.id_bon_livraison, bl.fdate AS date_bl, bl.id_structure AS id_expediteur, TRIM(st2.nom) AS expediteur, bl.remarques " +
"FROM COM02.bon_livraison bl " +
"JOIN err_bl ON err_bl.id_bon_livraison = bl.id_bon_livraison " +
"JOIN COM02.structure s ON s.id_structure = bl.id_destinataire " +
"LEFT OUTER JOIN COM02.STRUCTURE st2 ON st2.id_structure = bl.id_structure " +
"JOIN COM02.distributeur dis ON dis.id_distrib = s.id_distrib " +
"JOIN COM02.bon_livraison_colis blc ON blc.id_bordereau = bl.id_bon_livraison " +
"JOIN COM02.bon_livraison_colis_ligne blcl ON blcl.id_colis = blc.id_colis " +
"JOIN COM02.produit p ON p.id_produit = blcl.id_produit " +
"JOIN COM02.param_axe_valeur pavc ON pavc.id = p.id_type_axe_valeur1 " +
"JOIN COM02.modele m ON m.id_modele = p.code_modele " +
"JOIN COM02.marque mq ON mq.id_marque = m.id_marque " +
"LEFT OUTER JOIN OMNI.xst_produit xp ON (xp.id_distrib = s.id_distrib AND xp.id_produit = blcl.id_produit) " +
"WHERE bl.date_envoi_bl_numerique IS NULL AND blc.id_etat = 4 AND blcl.quantite != 0 AND xp.id_produit IS NULL " +
"ORDER BY s.id_distrib, dis.libelle, s.id_structure, TRIM(s.nom), m.code_saison";
logger.info(query);
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query)) {
ResultSet resultSet = statement.executeQuery();
List<FluxBlNotSent> blNotSentList = new ArrayList<>();
while (resultSet.next()) {
FluxBlNotSent blnotsent = mapResultSetToBlNotSent(resultSet);
blNotSentList.add(blnotsent);
}
ObjectMapper objectMapper = new ObjectMapper();
String jsonResponse;
try {
jsonResponse = objectMapper.writeValueAsString(blNotSentList);
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();
}
}
private FluxBlNotSent mapResultSetToBlNotSent(ResultSet resultSet) throws SQLException {
FluxBlNotSent blNotSent = new FluxBlNotSent();
blNotSent.setIdDistrib(resultSet.getInt("id_distrib"));
blNotSent.setLibelleDis(resultSet.getString("libelle_dis"));
blNotSent.setIdStructure(resultSet.getInt("id_structure"));
blNotSent.setNomStructure(resultSet.getString("nom"));
blNotSent.setEnseigne(resultSet.getString("enseigne"));
blNotSent.setMarque(resultSet.getString("marque"));
blNotSent.setCodeSaison(resultSet.getString("code_saison"));
blNotSent.setRefR(resultSet.getString("ref_r"));
blNotSent.setRefRc(resultSet.getString("ref_rc"));
blNotSent.setRefRct(resultSet.getString("ref_rct"));
blNotSent.setNomProduit(resultSet.getString("nom_produit"));
blNotSent.setIdProduit(resultSet.getInt("id_produit"));
blNotSent.setCodeExterne(resultSet.getString("code_externe"));
blNotSent.setIdBonLivraison(resultSet.getInt("id_bon_livraison"));
blNotSent.setDateBl(resultSet.getDate("date_bl"));
blNotSent.setIdExpediteur(resultSet.getInt("id_expediteur"));
blNotSent.setExpediteur(resultSet.getString("expediteur"));
blNotSent.setRemarques(resultSet.getString("remarques"));
return blNotSent;
}
}

View File

@ -8,6 +8,6 @@ public class HelloWebService {
@GET
public String sayHello() {
return "Hello, world!";
return "Hello, I'm here to serve you!";
}
}

View File

@ -1,7 +1,13 @@
package com.example.services;
import com.example.services.item.Item;
import com.example.services.item.ItemOption;
import com.example.services.item.ItemPrice;
import com.example.services.item.ItemStock;
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;
@ -14,35 +20,41 @@ import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Path("/items")
public class ItemService {
private static final Logger logger = LoggerFactory.getLogger(DatabaseConnectDOTSOFT.class);
@GET
@Path("/get")
@Path("/{itemId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getItemById(
@QueryParam("dbHost") String dbHost,
@QueryParam("itemId") String itemId) {
@PathParam("itemId") String itemId,
@QueryParam("dbHost") String dbHost) {
if (itemId == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"itemId parameter is required\"}").build();
} else if (itemId.length() < 6) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"Length of itemId must be greater than or equal to 6\"}").build();
}
if (dbHost == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"dbHost parameter is required\"}").build();
}
if (itemId == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"itemId parameter is required\"}").build();
}
DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes
try (DatabaseConnection databaseConnection = new DatabaseConnection(dbHost, "dtv", "dtv")) {
String query = "SELECT * FROM ITM_ITEM WHERE ITEM_ID LIKE ?" ;
try (DatabaseConnectXSTORE databaseConnection = new DatabaseConnectXSTORE(dbHost, "dtv")) {
String query = "SELECT * FROM dtv.ITM_ITEM WHERE ORGANIZATION_ID = 1 AND ITEM_ID LIKE ?";
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query)) {
// Concaténer % au paramètre itemId
// Concatenate % to parameter itemId
statement.setString(1, itemId + "%");
try (ResultSet resultSet = statement.executeQuery()) {
@ -53,13 +65,166 @@ public class ItemService {
itemList.add(item);
}
if (!itemList.isEmpty()) {
ObjectMapper objectMapper = new ObjectMapper();
String jsonResponse = objectMapper.writeValueAsString(itemList);
return Response.ok(jsonResponse).build();
} else {
return Response.status(Response.Status.NOT_FOUND).entity("{\"error\":\"No items found\"}").build();
ObjectMapper objectMapper = new ObjectMapper();
String jsonResponse = objectMapper.writeValueAsString(itemList);
return Response.ok(jsonResponse).build();
}
}
} catch (SQLException e) {
e.printStackTrace();
String errorResponse = "{\"error\":\"" + e.getMessage() + "\"}";
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponse).build();
} catch (JsonProcessingException e) {
e.printStackTrace(); // Gérer les exceptions correctement dans un environnement de production
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"Error processing JSON\"}").build();
}
}
@GET
@Path("/{itemId}/options")
@Produces(MediaType.APPLICATION_JSON)
public Response getItemOptionsById(
@PathParam("itemId") String itemId,
@QueryParam("dbHost") String dbHost) {
if (itemId == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"itemId parameter is required\"}").build();
} else if (itemId.length() < 6) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"Length of itemId must be greater than or equal to 6\"}").build();
}
if (dbHost == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"dbHost parameter is required\"}").build();
}
DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes
try (DatabaseConnectXSTORE databaseConnection = new DatabaseConnectXSTORE(dbHost, "dtv")) {
String query = "SELECT item_id,level_code,level_value,item_availability_code,tax_group_id,Vendor,season_code,create_date,create_user_id,update_date,update_user_id " +
"FROM dtv.ITM_ITEM_OPTIONS " +
"WHERE ORGANIZATION_ID = 1 AND ITEM_ID LIKE ?";
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query)) {
// Concatenate % to parameter itemId
statement.setString(1, itemId + "%");
try (ResultSet resultSet = statement.executeQuery()) {
List<ItemOption> itemOptionList = new ArrayList<>();
while (resultSet.next()) {
ItemOption itemOption = mapResultSetToItemOptionDetails(resultSet);
itemOptionList.add(itemOption);
}
ObjectMapper objectMapper = new ObjectMapper();
String jsonResponse = objectMapper.writeValueAsString(itemOptionList);
return Response.ok(jsonResponse).build();
}
}
} catch (SQLException e) {
e.printStackTrace();
String errorResponse = "{\"error\":\"" + e.getMessage() + "\"}";
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponse).build();
} catch (JsonProcessingException e) {
e.printStackTrace(); // Gérer les exceptions correctement dans un environnement de production
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"Error processing JSON\"}").build();
}
}
@GET
@Path("/{itemId}/price")
@Produces(MediaType.APPLICATION_JSON)
public Response getItemPricesById(
@PathParam("itemId") String itemId,
@QueryParam("dbHost") String dbHost) {
if (itemId == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"itemId parameter is required\"}").build();
} else if (itemId.length() < 6) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"Length of itemId must be greater than or equal to 6\"}").build();
}
if (dbHost == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"dbHost parameter is required\"}").build();
}
DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes
try (DatabaseConnectXSTORE databaseConnection = new DatabaseConnectXSTORE(dbHost, "dtv")) {
String query = "SELECT item_id, level_code, level_value, itm_price_property_code, effective_date, expiration_date, price, price_qty, external_id, external_system, create_date, create_user_id, update_date, update_user_id " +
"FROM dtv.itm_item_prices " +
"WHERE organization_id = 1 AND item_id LIKE ?";
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query)) {
// Concatenate % to parameter itemId
statement.setString(1, itemId + "%");
try (ResultSet resultSet = statement.executeQuery()) {
List<ItemPrice> itemPriceList = new ArrayList<>();
while (resultSet.next()) {
ItemPrice itemPrice = mapResultSetToItemPriceDetails(resultSet);
itemPriceList.add(itemPrice);
}
ObjectMapper objectMapper = new ObjectMapper();
String jsonResponse = objectMapper.writeValueAsString(itemPriceList);
return Response.ok(jsonResponse).build();
}
}
} catch (SQLException e) {
e.printStackTrace();
String errorResponse = "{\"error\":\"" + e.getMessage() + "\"}";
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponse).build();
} catch (JsonProcessingException e) {
e.printStackTrace(); // Gérer les exceptions correctement dans un environnement de production
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"Error processing JSON\"}").build();
}
}
@GET
@Path("/{itemId}/stock")
@Produces(MediaType.APPLICATION_JSON)
public Response getItemStocksById(
@PathParam("itemId") String itemId,
@QueryParam("dbHost") String dbHost) {
if (itemId == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"itemId parameter is required\"}").build();
} else if (itemId.length() < 6) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"Length of itemId must be greater than or equal to 6\"}").build();
}
if (dbHost == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"dbHost parameter is required\"}").build();
}
DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes
try (DatabaseConnectXSTORE databaseConnection = new DatabaseConnectXSTORE(dbHost, "dtv")) {
String query = "SELECT organization_id,rtl_loc_id,inv_location_id,bucket_id,item_id, unitcount,inventory_value,create_date, create_user_id,update_date , update_user_id " +
"FROM dtv.inv_stock_ledger_acct " +
"WHERE organization_id = 1 AND item_id LIKE ?";
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query)) {
// Concatenate % to parameter itemId
statement.setString(1, itemId + "%");
try (ResultSet resultSet = statement.executeQuery()) {
List<ItemStock> itemStockList = new ArrayList<>();
while (resultSet.next()) {
ItemStock itemStock = mapResultSetToItemStockDetails(resultSet);
itemStockList.add(itemStock);
}
ObjectMapper objectMapper = new ObjectMapper();
String jsonResponse = objectMapper.writeValueAsString(itemStockList);
return Response.ok(jsonResponse).build();
}
}
} catch (SQLException e) {
@ -99,287 +264,68 @@ public class ItemService {
item.setDimension2(resultSet.getString("DIMENSION2"));
item.setDimension3(resultSet.getString("DIMENSION3"));
item.setExternalSystem(resultSet.getString("EXTERNAL_SYSTEM"));
item.setCreateDate(resultSet.getTimestamp("CREATE_DATE"));
item.setCreateDate(resultSet.getDate("CREATE_DATE"));
item.setCreateUserId(resultSet.getString("CREATE_USER_ID"));
item.setUpdateDate(resultSet.getTimestamp("UPDATE_DATE"));
item.setUpdateDate(resultSet.getDate("UPDATE_DATE"));
item.setUpdateUserId(resultSet.getString("UPDATE_USER_ID"));
item.setRecordState(resultSet.getString("RECORD_STATE"));
return item;
}
public class Item {
private Long organizationId;
private String itemId;
private String orgCode;
private String orgValue;
private String name;
private String description;
private String merchLevel1;
private String merchLevel2;
private String merchLevel3;
private String merchLevel4;
private Integer listPrice;
private Integer measureReqFlag;
private String itemLevelCode;
private String parentItemId;
private Integer notInventoriedFlag;
private Integer serializedItemFlag;
private String itemTypeCode;
private String dtvClassName;
private String dimensionSystem;
private Integer disallowMatrixDisplayFlag;
private String itemMatrixColor;
private String dimension1;
private String dimension2;
private String dimension3;
private String externalSystem;
private Timestamp createDate;
private String createUserId;
private Timestamp updateDate;
private String updateUserId;
private String recordState;
private ItemOption mapResultSetToItemOptionDetails(ResultSet resultSet) throws SQLException {
ItemOption itemOption = new ItemOption();
// Getters and Setters for all fields
itemOption.setItemId(resultSet.getString("ITEM_ID"));
itemOption.setLevelCode(resultSet.getString("LEVEL_CODE"));
itemOption.setLevelValue(resultSet.getString("LEVEL_VALUE"));
itemOption.setItemAvailabilityCode(resultSet.getString("ITEM_AVAILABILITY_CODE"));
itemOption.setTaxGroupId(resultSet.getString("TAX_GROUP_ID"));
itemOption.setVendor(resultSet.getString("VENDOR"));
itemOption.setSeasonCode(resultSet.getString("SEASON_CODE"));
itemOption.setCreateDate(resultSet.getDate("CREATE_DATE"));
itemOption.setCreateUserId(resultSet.getString("CREATE_USER_ID"));
itemOption.setUpdateDate(resultSet.getDate("UPDATE_DATE"));
itemOption.setUpdateUserId(resultSet.getString("UPDATE_USER_ID"));
public Long getOrganizationId() {
return organizationId;
}
public void setOrganizationId(Long organizationId) {
this.organizationId = organizationId;
}
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getOrgCode() {
return orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public String getOrgValue() {
return orgValue;
}
public void setOrgValue(String orgValue) {
this.orgValue = orgValue;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getMerchLevel1() {
return merchLevel1;
}
public void setMerchLevel1(String merchLevel1) {
this.merchLevel1 = merchLevel1;
}
public String getMerchLevel2() {
return merchLevel2;
}
public void setMerchLevel2(String merchLevel2) {
this.merchLevel2 = merchLevel2;
}
public String getMerchLevel3() {
return merchLevel3;
}
public void setMerchLevel3(String merchLevel3) {
this.merchLevel3 = merchLevel3;
}
public String getMerchLevel4() {
return merchLevel4;
}
public void setMerchLevel4(String merchLevel4) {
this.merchLevel4 = merchLevel4;
}
public Integer getListPrice() {
return listPrice;
}
public void setListPrice(Integer listPrice) {
this.listPrice = listPrice;
}
public Integer getMeasureReqFlag() {
return measureReqFlag;
}
public void setMeasureReqFlag(Integer measureReqFlag) {
this.measureReqFlag = measureReqFlag;
}
public String getItemLevelCode() {
return itemLevelCode;
}
public void setItemLevelCode(String itemLevelCode) {
this.itemLevelCode = itemLevelCode;
}
public String getParentItemId() {
return parentItemId;
}
public void setParentItemId(String parentItemId) {
this.parentItemId = parentItemId;
}
public Integer getNotInventoriedFlag() {
return notInventoriedFlag;
}
public void setNotInventoriedFlag(Integer notInventoriedFlag) {
this.notInventoriedFlag = notInventoriedFlag;
}
public Integer getSerializedItemFlag() {
return serializedItemFlag;
}
public void setSerializedItemFlag(Integer serializedItemFlag) {
this.serializedItemFlag = serializedItemFlag;
}
public String getItemTypeCode() {
return itemTypeCode;
}
public void setItemTypeCode(String itemTypeCode) {
this.itemTypeCode = itemTypeCode;
}
public String getDtvClassName() {
return dtvClassName;
}
public void setDtvClassName(String dtvClassName) {
this.dtvClassName = dtvClassName;
}
public String getDimensionSystem() {
return dimensionSystem;
}
public void setDimensionSystem(String dimensionSystem) {
this.dimensionSystem = dimensionSystem;
}
public Integer getDisallowMatrixDisplayFlag() {
return disallowMatrixDisplayFlag;
}
public void setDisallowMatrixDisplayFlag(Integer disallowMatrixDisplayFlag) {
this.disallowMatrixDisplayFlag = disallowMatrixDisplayFlag;
}
public String getItemMatrixColor() {
return itemMatrixColor;
}
public void setItemMatrixColor(String itemMatrixColor) {
this.itemMatrixColor = itemMatrixColor;
}
public String getDimension1() {
return dimension1;
}
public void setDimension1(String dimension1) {
this.dimension1 = dimension1;
}
public String getDimension2() {
return dimension2;
}
public void setDimension2(String dimension2) {
this.dimension2 = dimension2;
}
public String getDimension3() {
return dimension3;
}
public void setDimension3(String dimension3) {
this.dimension3 = dimension3;
}
public String getExternalSystem() {
return externalSystem;
}
public void setExternalSystem(String externalSystem) {
this.externalSystem = externalSystem;
}
public Timestamp getCreateDate() {
return createDate;
}
public void setCreateDate(Timestamp createDate) {
this.createDate = createDate;
}
public String getCreateUserId() {
return createUserId;
}
public void setCreateUserId(String createUserId) {
this.createUserId = createUserId;
}
public Timestamp getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Timestamp updateDate) {
this.updateDate = updateDate;
}
public String getUpdateUserId() {
return updateUserId;
}
public void setUpdateUserId(String updateUserId) {
this.updateUserId = updateUserId;
}
public String getRecordState() {
return recordState;
}
public void setRecordState(String recordState) {
this.recordState = recordState;
}
return itemOption;
}
}
private ItemPrice mapResultSetToItemPriceDetails(ResultSet resultSet) throws SQLException {
ItemPrice itemPrices = new ItemPrice();
itemPrices.setItemId(resultSet.getString("ITEM_ID"));
itemPrices.setLevelCode(resultSet.getString("LEVEL_CODE"));
itemPrices.setLevelValue(resultSet.getString("LEVEL_VALUE"));
itemPrices.setItmPricePropertyCode(resultSet.getString("ITM_PRICE_PROPERTY_CODE"));
itemPrices.setEffectiveDate(resultSet.getDate("EFFECTIVE_DATE"));
itemPrices.setExpirationDate(resultSet.getDate("EXPIRATION_DATE"));
itemPrices.setPrice(resultSet.getDouble("PRICE"));
itemPrices.setPriceQty(resultSet.getDouble("PRICE_QTY"));
itemPrices.setExternalId(resultSet.getString("EXTERNAL_ID"));
itemPrices.setExternalSystem(resultSet.getString("EXTERNAL_SYSTEM"));
itemPrices.setCreateDate(resultSet.getDate("CREATE_DATE"));
itemPrices.setCreateUserId(resultSet.getString("CREATE_USER_ID"));
itemPrices.setUpdateDate(resultSet.getDate("UPDATE_DATE"));
itemPrices.setUpdateUserId(resultSet.getString("UPDATE_USER_ID"));
return itemPrices;
}
private ItemStock mapResultSetToItemStockDetails(ResultSet resultSet) throws SQLException {
ItemStock itemStock = new ItemStock();
itemStock.setOrganizationId(resultSet.getString("ORGANIZATION_ID"));
itemStock.setRtlLocId(resultSet.getString("RTL_LOC_ID"));
itemStock.setInvLocationId(resultSet.getString("INV_LOCATION_ID"));
itemStock.setBucketId(resultSet.getString("BUCKET_ID"));
itemStock.setItemId(resultSet.getString("ITEM_ID"));
itemStock.setUnitCount(resultSet.getInt("UNITCOUNT"));
itemStock.setInventoryValue(resultSet.getDouble("INVENTORY_VALUE"));
itemStock.setCreateDate(resultSet.getDate("CREATE_DATE"));
itemStock.setCreateUserId(resultSet.getString("CREATE_USER_ID"));
itemStock.setUpdateDate(resultSet.getDate("UPDATE_DATE"));
itemStock.setUpdateUserId(resultSet.getString("UPDATE_USER_ID"));
return itemStock;
}
}

View File

@ -1,7 +1,11 @@
package com.example.services;
import com.example.services.store.*;
import com.example.services.xadmin.log.XadminLog;
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;
@ -10,6 +14,7 @@ import javax.ws.rs.core.Response;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -20,35 +25,67 @@ import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Path("/stores")
public class StoreService {
private static List<store> cachedStoreList;
private static final Logger logger = LoggerFactory.getLogger(StoreService.class);
private static List<Store> cachedStoreList;
private static final Lock cacheLock = new ReentrantLock();
/**
* Retrieves a store by its ID.
*
* @param storeId the ID of the store to retrieve
* @return a response containing the store information in JSON format
*/
@GET
@Path("/get")
@Path("/{storeId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getStoreById(@QueryParam("storeId") String storeId) {
public Response getStoreById(@PathParam("storeId") String storeId) {
if (storeId == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"storeId parameter is required\"}").build();
}
DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes
DriverManager.setLoginTimeout(5); // Set timeout to 5 seconds
// IASPDI com02 / B1Xto9pAbtBCOxuecG7W
// MASPDI com02 /
try (DatabaseConnectionDS databaseConnection = new DatabaseConnectionDS("com02", "B1Xto9pAbtBCOxuecG7W")) {
String query = "SELECT id_structure,nom,'10.100.0.18' AS ip, tel1 AS telephone FROM structure WHERE id_structure = ?" ;
try (DatabaseConnectDOTSOFT databaseConnection = new DatabaseConnectDOTSOFT("com02")) {
String query = "SELECT st.id_structure," +
" TRIM(st.nom) as nom," +
" st.tel1 as telephone," +
" st.enseigne," +
" 'https://mp4.ikksgroup.com/photos/' || CASE WHEN metabp.id_photo_principale IS NOT NULL THEN mpprinc.url || TO_CHAR (metabp.id_photo_principale) " + "ELSE '0/0' END || '-small.JPG' as photoLink," +
" TRIM(pp.nom) AS pays, " +
" (" +
" SELECT" +
" NVL(STRAGG(hsc2.id_caisse || '|' || hsc2.ip),'0|0.0.0.0')" +
" FROM" +
" com02.HOTLINE_STRUCTURE_CAISSE hsc2" +
" WHERE" +
" hsc2.id_structure = st.id_structure" +
" AND hsc2.id_caisse BETWEEN 20 AND 39) AS caisses," +
" REPLACE(REPLACE(TRIM(st.adresse1), chr(10), ''), chr(13), '') AS adresse," +
" axs.date_stock as date_migration" +
" FROM COM02.structure st" +
" JOIN com02.PARAM_PAYS pp ON pp.id_pays = st.id_pays" +
" LEFT OUTER JOIN mobretail.mp_etab_param metabp ON metabp.id_etab = st.id_structure" +
" LEFT OUTER JOIN mobretail.mr_photo mpprinc ON mpprinc.id_photo = metabp.id_photo_principale" +
" LEFT OUTER JOIN omni.ASPD_XSTO_STRUCTURE axs ON st.ID_STRUCTURE = axs.ID_STRUCTURE " +
" WHERE st.id_structure = ?";
logger.info(query);
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query)) {
statement.setString(1, storeId);
try (ResultSet resultSet = statement.executeQuery()) {
if (resultSet.next()) {
store store = mapResultSetTostore(resultSet);
Store store = mapResultSetTostore(resultSet);
ObjectMapper objectMapper = new ObjectMapper();
String jsonResponse = objectMapper.writeValueAsString(store);
return Response.ok(jsonResponse).build();
} else {
return Response.status(Response.Status.NOT_FOUND).entity("{\"error\":\"No store found\"}").build();
@ -60,22 +97,44 @@ public class StoreService {
String errorResponse = "{\"error\":\"" + e.getMessage() + "\"}";
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponse).build();
} catch (JsonProcessingException e) {
e.printStackTrace(); // Gérer les exceptions correctement dans un environnement de production
e.printStackTrace(); // Handle exceptions correctly in a production environment
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"Error processing JSON\"}").build();
}
}
/**
* Sets cachedStoreList to null, forcing a reload of stores from the database on the next call to /stores.
*
* @return A response indicating success
*/
@GET
@Path("/reload")
public Response reloadStores() {
cacheLock.lock();
try {
cachedStoreList = null;
} finally {
cacheLock.unlock();
}
return Response.ok("{\"status\":\"Cache cleared\"}").build();
}
/**
* Retrieves all stores from the database and returns them as a JSON response.
*
* @return A JSON response containing the list of stores
*/
@GET
@Path("/getAll")
@Produces(MediaType.APPLICATION_JSON)
public Response getAllStores() {
if (cachedStoreList == null) {
// Utilisation d'un verrou pour éviter que plusieurs requêtes déclenchent la récupération simultanée
// Use of a lock to prevent multiple requests from triggering simultaneous retrieval
cacheLock.lock();
try {
// Vérification à nouveau après avoir acquis le verrou
// Check again after acquiring the lock
if (cachedStoreList == null) {
// Récupérer depuis la base de données seulement si la liste n'est pas en cache
// Retrieve from database only if list is not cached
cachedStoreList = retrieveStoresFromDatabase();
}
} finally {
@ -83,38 +142,58 @@ public class StoreService {
}
}
if (!cachedStoreList.isEmpty()) {
ObjectMapper objectMapper = new ObjectMapper();
String jsonResponse;
try {
jsonResponse = objectMapper.writeValueAsString(cachedStoreList);
return Response.ok(jsonResponse).build();
} catch (JsonProcessingException e) {
e.printStackTrace();
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"Error processing JSON\"}").build();
}
} else {
return Response.status(Response.Status.NOT_FOUND).entity("{\"error\":\"No stores found\"}").build();
ObjectMapper objectMapper = new ObjectMapper();
String jsonResponse;
try {
jsonResponse = objectMapper.writeValueAsString(cachedStoreList);
return Response.ok(jsonResponse).build();
} catch (JsonProcessingException e) {
e.printStackTrace();
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"Error processing JSON\"}").build();
}
}
private List<store> retrieveStoresFromDatabase() {
DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes
/**
* Retrieves stores from the database.
*
* @return a list of stores retrieved from the database
*/
private List<Store> retrieveStoresFromDatabase() {
DriverManager.setLoginTimeout(5); // Set timeout to 5 seconds
try (DatabaseConnectionDS databaseConnection = new DatabaseConnectionDS("com02", "B1Xto9pAbtBCOxuecG7W")) {
String query = "SELECT st.id_structure, TRIM(st.nom) as nom, '10.100.0.18' AS ip, " +
"st.tel1 AS telephone " +
"FROM COM02.STRUCTURE st " +
"LEFT OUTER JOIN omni.ASPD_XSTO_STRUCTURE axs ON st.ID_STRUCTURE = axs.ID_STRUCTURE " +
"WHERE st.id_structure < 50";
try (DatabaseConnectDOTSOFT databaseConnection = new DatabaseConnectDOTSOFT("com02")) {
String query = "SELECT st.id_structure," +
" TRIM(st.nom) as nom," +
" st.tel1 as telephone," +
" st.enseigne," +
" 'https://mp4.ikksgroup.com/photos/' || CASE WHEN metabp.id_photo_principale IS NOT NULL THEN mpprinc.url || TO_CHAR (metabp.id_photo_principale) " + "ELSE '0/0' END || '-small.JPG' as photoLink," +
" TRIM(pp.nom) AS pays, " +
" (" +
" SELECT" +
" NVL(STRAGG(hsc2.id_caisse || '|' || hsc2.ip),'0|0.0.0.0')" +
" FROM" +
" com02.HOTLINE_STRUCTURE_CAISSE hsc2" +
" WHERE" +
" hsc2.id_structure = st.id_structure" +
" AND hsc2.id_caisse BETWEEN 20 AND 39) AS caisses," +
" REPLACE(REPLACE(TRIM(st.adresse1), chr(10), ''), chr(13), '') AS adresse," +
" axs.date_stock as date_migration" +
" FROM COM02.structure st" +
" JOIN com02.PARAM_PAYS pp ON pp.id_pays = st.id_pays" +
" LEFT OUTER JOIN mobretail.mp_etab_param metabp ON metabp.id_etab = st.id_structure" +
" LEFT OUTER JOIN mobretail.mr_photo mpprinc ON mpprinc.id_photo = metabp.id_photo_principale" +
" LEFT OUTER JOIN omni.ASPD_XSTO_STRUCTURE axs ON st.ID_STRUCTURE = axs.ID_STRUCTURE" +
" WHERE axs.date_stock is not null AND st.ID_NIVEAU=4 AND st.STATUT=2 AND st.id_canal_distribution = 1 and st.magasin_demo = 0" +
" ORDER BY st.id_structure";
logger.info(query);
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query);
ResultSet resultSet = statement.executeQuery()) {
List<store> storeList = new ArrayList<>();
List<Store> storeList = new ArrayList<>();
while (resultSet.next()) {
store store = mapResultSetTostore(resultSet);
Store store = mapResultSetTostore(resultSet);
storeList.add(store);
}
@ -126,54 +205,722 @@ public class StoreService {
}
}
private store mapResultSetTostore(ResultSet resultSet) throws SQLException {
store store = new store();
@GET
@Path("/{storeId}/sequence")
@Produces(MediaType.APPLICATION_JSON)
public Response getSequence(
@PathParam("storeId") Integer storeId,
@QueryParam("dbHost") String dbHost) {
if(storeId == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"storeId parameter is required\"}").build();
}
if (dbHost == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"dbHost parameter is required\"}").build();
}
DriverManager.setLoginTimeout(5); // Set timeout to 5 seconds
try (DatabaseConnectXSTORE databaseConnection = new DatabaseConnectXSTORE(dbHost,"dtv")) {
String query = "SELECT ORGANIZATION_ID, RTL_LOC_ID, WKSTN_ID, SEQUENCE_ID, SEQUENCE_MODE, SEQUENCE_NBR, CREATE_DATE, CREATE_USER_ID, UPDATE_DATE, UPDATE_USER_ID, RECORD_STATE "+
"FROM DTV.COM_SEQUENCE " +
"WHERE organization_id = 1 " +
"ORDER BY WKSTN_ID, SEQUENCE_ID";
logger.info(query);
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query)) {
ResultSet resultSet = statement.executeQuery();
List<StoreSequence> sequenceList = new ArrayList<>();
while (resultSet.next()) {
StoreSequence sequence = mapResultSetToStoreSequence(resultSet);
sequenceList.add(sequence);
}
ObjectMapper objectMapper = new ObjectMapper();
String jsonResponse;
try {
jsonResponse = objectMapper.writeValueAsString(sequenceList);
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("/{storeId}/signature")
@Produces(MediaType.APPLICATION_JSON)
public Response getSignature(
@PathParam("storeId") Integer storeId,
@QueryParam("dbHost") String dbHost) {
if(storeId == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"storeId parameter is required\"}").build();
}
if (dbHost == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"dbHost parameter is required\"}").build();
}
DriverManager.setLoginTimeout(5); // Set timeout to 5 seconds
try (DatabaseConnectXSTORE databaseConnection = new DatabaseConnectXSTORE(dbHost,"dtv")) {
String query = "SELECT ORGANIZATION_ID, RTL_LOC_ID, WKSTN_ID, SIGNATURE_ID, SIGNATURE_MODE, SIGNATURE_STRING, SIGNATURE_SOURCE, CREATE_DATE, CREATE_USER_ID, UPDATE_DATE, UPDATE_USER_ID, RECORD_STATE " +
"FROM DTV.COM_SIGNATURE " +
"WHERE organization_id = 1 " +
"ORDER BY WKSTN_ID";
logger.info(query);
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query)) {
ResultSet resultSet = statement.executeQuery();
List<StoreSignature> signatureList = new ArrayList<>();
while (resultSet.next()) {
StoreSignature signature = mapResultSetToStoreSignature(resultSet);
signatureList.add(signature);
}
ObjectMapper objectMapper = new ObjectMapper();
String jsonResponse;
try {
jsonResponse = objectMapper.writeValueAsString(signatureList);
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("/{storeId}/version")
@Produces(MediaType.APPLICATION_JSON)
public Response getVersion(
@PathParam("storeId") Integer storeId,
@QueryParam("dbHost") String dbHost) {
if(storeId == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"storeId parameter is required\"}").build();
}
if (dbHost == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"dbHost parameter is required\"}").build();
}
DriverManager.setLoginTimeout(5); // Set timeout to 5 seconds
try (DatabaseConnectXSTORE databaseConnection = new DatabaseConnectXSTORE(dbHost,"dtv")) {
String query = "SELECT ORGANIZATION_ID,SEQ,BASE_SCHEMA_VERSION,CUSTOMER_SCHEMA_VERSION,CUSTOMER,BASE_SCHEMA_DATE,CUSTOMER_SCHEMA_DATE, " +
"CREATE_DATE,CREATE_USER_ID,UPDATE_DATE,UPDATE_USER_ID " +
"FROM dtv.CTL_VERSION_HISTORY " +
"WHERE organization_id = 1 AND customer IS NOT NULL " +
"ORDER BY seq DESC";
logger.info(query);
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query)) {
ResultSet resultSet = statement.executeQuery();
List<StoreVersion> versionList = new ArrayList<>();
while (resultSet.next()) {
StoreVersion version = mapResultSetToStoreVersion(resultSet);
versionList.add(version);
}
ObjectMapper objectMapper = new ObjectMapper();
String jsonResponse;
try {
jsonResponse = objectMapper.writeValueAsString(versionList);
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("/{storeId}/log")
@Produces(MediaType.APPLICATION_JSON)
public Response getLog(
@PathParam("storeId") Integer storeId,
@QueryParam("dbHost") String dbHost,
@QueryParam("logDate") String logDate) {
if(storeId == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"storeId parameter is required\"}").build();
}
if (logDate == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"logDate parameter is required\"}").build();
}
if (dbHost == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"dbHost parameter is required\"}").build();
}
DriverManager.setLoginTimeout(5); // Set timeout to 5 seconds
try (DatabaseConnectXSTORE databaseConnection = new DatabaseConnectXSTORE(dbHost,"dtv")) {
String query = "SELECT" +
" FROM_TZ(cel.CREATE_DATE, 'UTC') " +
" AT TIME ZONE " +
" CASE loc.COUNTRY " +
" WHEN 'CH' THEN 'Europe/Zurich' " +
" WHEN 'NL' THEN 'Europe/Amsterdam' " +
" WHEN 'MC' THEN 'Europe/Monaco' " +
" WHEN 'LU' THEN 'Europe/Luxembourg' " +
" WHEN 'ES' THEN 'Europe/Madrid' " +
" WHEN 'FR' THEN 'Europe/Paris' " +
" WHEN 'US' THEN 'America/New_York' " +
" WHEN 'GB' THEN 'Europe/London' " +
" WHEN 'BE' THEN 'Europe/Brussels' " +
" ELSE 'UTC' " +
" END " +
"AS CREATE_DATE, " +
"cel.CREATE_USER_ID, " +
"cel.BUSINESS_DATE, " +
"cel.RTL_LOC_ID, "+
"cel.RTL_LOC_ID || ' - ' || loc.STORE_NAME AS STORE_NAME, " +
"cel.WKSTN_ID, " +
"cel.LOG_LEVEL, " +
"cel.THREAD_NAME, " +
"cel.LOG_MESSAGE, " +
"CASE WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.app.preflight' THEN 'Pre-flight error' " +
" WHEN cel.LOGGER_CATEGORY LIKE 'dtv.xstore.dataloader%' THEN 'DataLoader' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.sysadmin.data.failover' THEN 'Data-failover' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.order.download.offline' THEN 'Order error' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.state.app.startup' THEN 'Xstore startup' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.state.app.shutdown' THEN 'Xstore shutdown' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.helpdesk.memory' THEN 'Application core' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.helpdesk' THEN 'Application core' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.sysadmin.data.repqueue.errors' THEN 'Replication errors' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.sysadmin.data.repqueue.nofails' THEN 'Replication errors' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.hardware.init' THEN 'Hardware init' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.sensitive-data.logging' THEN 'Sensitive data logging' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.uncaught' THEN 'Uncaught exception' " +
"ELSE cel.LOGGER_CATEGORY END as LOGGER_CATEGORY " +
"FROM dtv.CTL_EVENT_LOG cel " +
"JOIN dtv.LOC_RTL_LOC loc ON loc.RTL_LOC_ID = cel.RTL_LOC_ID " +
"WHERE cel.CREATE_DATE BETWEEN " +
"TO_TIMESTAMP(?, 'YYYYMMDD HH24:MI:SS') - INTERVAL '3' HOUR " +
"AND " +
"TO_TIMESTAMP(?, 'YYYYMMDD HH24:MI:SS') + INTERVAL '3' HOUR " +
"AND TO_CHAR(FROM_TZ(cel.CREATE_DATE, 'UTC') AT TIME ZONE " +
"CASE loc.COUNTRY " +
" WHEN 'CH' THEN 'Europe/Zurich' " +
" WHEN 'NL' THEN 'Europe/Amsterdam' " +
" WHEN 'MC' THEN 'Europe/Monaco' " +
" WHEN 'LU' THEN 'Europe/Luxembourg' " +
" WHEN 'ES' THEN 'Europe/Madrid' " +
" WHEN 'FR' THEN 'Europe/Paris' " +
" WHEN 'US' THEN 'America/New_York' " +
" WHEN 'GB' THEN 'Europe/London' " +
" WHEN 'BE' THEN 'Europe/Brussels' " +
" ELSE 'UTC' " +
"END, 'YYYYMMDD HH24:MI:SS') BETWEEN ? AND ? " +
"AND cel.ORGANIZATION_ID = 1 " +
"AND cel.RTL_LOC_ID = ? " +
"AND cel.THREAD_NAME IS NOT NULL " +
"ORDER BY cel.CREATE_DATE DESC";
logger.info(query);
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query)) {
statement.setString(1, logDate + " 00:00:00");
statement.setString(2, logDate + " 23:59:59");
statement.setString(3, logDate + " 00:00:00");
statement.setString(4, logDate + " 23:59:59");
statement.setInt(5, storeId);
ResultSet resultSet = statement.executeQuery();
List<XadminLog> storeLogList = new ArrayList<>();
while (resultSet.next()) {
XadminLog storeLog = mapResultSetToStoreLog(resultSet);
storeLogList.add(storeLog);
}
ObjectMapper objectMapper = new ObjectMapper();
String jsonResponse;
try {
jsonResponse = objectMapper.writeValueAsString(storeLogList);
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();
}
}
public XadminLog mapResultSetToStoreLog(ResultSet resultSet) throws SQLException {
XadminLog xadminlog = new XadminLog();
xadminlog.setCreateDate(resultSet.getDate("CREATE_DATE"));
xadminlog.setCreateUserId(resultSet.getString("CREATE_USER_ID"));
xadminlog.setBusinessDate(resultSet.getDate("BUSINESS_DATE"));
xadminlog.setRtlLocId(resultSet.getInt("RTL_LOC_ID"));
xadminlog.setStoreName(resultSet.getString("STORE_NAME"));
xadminlog.setWkstnId(resultSet.getInt("WKSTN_ID"));
xadminlog.setLogLevel(resultSet.getString("LOG_LEVEL"));
xadminlog.setThreadName(resultSet.getString("THREAD_NAME"));
xadminlog.setLogMessage(resultSet.getString("LOG_MESSAGE"));
xadminlog.setLoggerCategory(resultSet.getString("LOGGER_CATEGORY"));
return xadminlog;
}
/**
* Maps a ResultSet to a store object.
*
* @param resultSet the ResultSet containing the data to be mapped
* @return the store object with mapped data
* @throws SQLException if there is an error accessing the data from the ResultSet
*/
private Store mapResultSetTostore(ResultSet resultSet) throws SQLException {
Store store = new Store();
store.setId_structure(resultSet.getInt("ID_STRUCTURE"));
store.setNom(resultSet.getString("NOM"));
store.setIp(resultSet.getString("IP"));
store.setTelephone(resultSet.getString("TELEPHONE"));
store.setEnseigne(resultSet.getString("ENSEIGNE"));
store.setPhotoLink(resultSet.getString("PHOTOLINK"));
store.setPays(resultSet.getString("PAYS"));
store.setCaisses(resultSet.getString("CAISSES"));
store.setAdresse(resultSet.getString("ADRESSE"));
store.setDate_migration(resultSet.getDate("DATE_MIGRATION"));
return store;
}
public class store {
private Integer id_structure;
private String nom;
private String ip;
private String telephone;
public Integer getId_structure() {
return id_structure;
@GET
@Path("/{storeId}/details")
@Produces(MediaType.APPLICATION_JSON)
public Response getStoreDetails(
@PathParam("storeId") Integer storeId,
@QueryParam("dbHost") String dbHost) {
if (dbHost == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"dbHost parameter is required\"}").build();
}
if (storeId == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"storeId parameter is required\"}").build();
}
public void setId_structure(Integer id_structure) {
this.id_structure = id_structure;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
try {
StoreDetails storeDetails = retrieveStoreDetails(dbHost,storeId);
ObjectMapper objectMapper = new ObjectMapper();
try {
String jsonResponse = objectMapper.writeValueAsString(storeDetails);
return Response.ok(jsonResponse).build();
} catch (JsonProcessingException e) {
e.printStackTrace();
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
.entity("{\"error\":\"Error converting StoreDetails to JSON\"}")
.build();
}
} catch (RuntimeException e) {
// Capture the RuntimeException to manage SQL errors
e.printStackTrace();
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"" + e.getMessage() + "\"}").build();
}
}
/**
* Retrieves storeDetails from the database.
*
* @param dbHost the host of the database
* @param storeId the ID of the store
* @param workstationId the ID of the workstation
* @return storeDetails
*/
private StoreDetails retrieveStoreDetails(String dbHost, Integer storeId) {
DriverManager.setLoginTimeout(5);
StoreDetails storeDetails = new StoreDetails(); // Declare object outside try blocks
try (DatabaseConnectXSTORE databaseConnection = new DatabaseConnectXSTORE(dbHost,"dtv")) {
// get Pos list
String PosQuery = "SELECT cdr.RTL_LOC_ID, " +
"cdr.WKSTN_ID, " +
"cdr.IP_ADDRESS, " +
"cdr.BUSINESS_DATE, " +
"cdr.XSTORE_VERSION, " +
"cdr.PRIMARY_REGISTER_FLAG " +
"FROM dtv.ctl_device_registration cdr " +
"WHERE cdr.ORGANIZATION_ID = 1 " +
"ORDER BY cdr.PRIMARY_REGISTER_FLAG desc, cdr.WKSTN_ID";
logger.info(PosQuery);
try (PreparedStatement posStatement = databaseConnection.getConnection().prepareStatement(PosQuery)) {
try (ResultSet posResultSet = posStatement.executeQuery()) {
Integer posRtlLocId = 0;
Integer posWkstnId = 0;
String posIp = "";
String posVersion = "";
Date posBusinessDate = null;
Integer primaryRegisterFlag = 0;
while (posResultSet.next()) {
posRtlLocId = posResultSet.getInt("RTL_LOC_ID");
posWkstnId = posResultSet.getInt("WKSTN_ID");
posIp = posResultSet.getString("IP_ADDRESS");
posVersion = posResultSet.getString("XSTORE_VERSION");
posBusinessDate = posResultSet.getDate("BUSINESS_DATE");
primaryRegisterFlag = posResultSet.getInt("PRIMARY_REGISTER_FLAG");
StorePos pos = new StorePos();
// add new pos object
storeDetails.getPos().add(pos);
pos.setWorkstationId(posWkstnId);
pos.setIp(posIp);
pos.setVersion(posVersion);
pos.setBusinessDate(posBusinessDate);
pos.setPrimaryRegister(primaryRegisterFlag);
pos.setFatalError(1);
// retrieve all pos details only on database of the master pos
retrieveStorePosDetails(databaseConnection, posRtlLocId, posWkstnId, posBusinessDate, pos);
/* if (posResultSet.getString("IP_ADDRESS").equals(dbHost)) {
retrieveStorePosDetails(databaseConnection, posRtlLocId, posWkstnId, posBusinessDate, pos);
} else {
try (DatabaseConnectXSTORE newDatabaseConnection = new DatabaseConnectXSTORE(posIp,"dtv")) {
retrieveStorePosDetails(newDatabaseConnection, posRtlLocId, posWkstnId, posBusinessDate, pos);
} catch (SQLException e) {
e.printStackTrace();
// Handle exceptions correctly in a production environment
}
} */
}
}
}
} catch (SQLException e) {
e.printStackTrace();
// Handle exceptions correctly in a production environment
}
try (DatabaseConnectDOTSOFT databaseConnectionDS = new DatabaseConnectDOTSOFT("com02")) {
// Store section
String storeQuery = "SELECT st.id_structure," +
" TRIM(st.nom) as nom," +
" st.tel1 as telephone," +
" st.enseigne," +
" 'https://mp4.ikksgroup.com/photos/' || CASE WHEN metabp.id_photo_principale IS NOT NULL THEN mpprinc.url || TO_CHAR (metabp.id_photo_principale) " + "ELSE '0/0' END || '-small.JPG' as photoLink," +
" TRIM(pp.nom) AS pays, " +
" (" +
" SELECT" +
" NVL(STRAGG(hsc2.id_caisse || '|' || hsc2.ip),'0|0.0.0.0')" +
" FROM" +
" com02.HOTLINE_STRUCTURE_CAISSE hsc2" +
" WHERE" +
" hsc2.id_structure = st.id_structure" +
" AND hsc2.id_caisse BETWEEN 20 AND 39) AS caisses," +
" REPLACE(REPLACE(TRIM(st.adresse1), chr(10), ''), chr(13), '') AS adresse," +
" axs.date_stock as date_migration" +
" FROM COM02.structure st" +
" JOIN com02.PARAM_PAYS pp ON pp.id_pays = st.id_pays" +
" LEFT OUTER JOIN mobretail.mp_etab_param metabp ON metabp.id_etab = st.id_structure" +
" LEFT OUTER JOIN mobretail.mr_photo mpprinc ON mpprinc.id_photo = metabp.id_photo_principale" +
" LEFT OUTER JOIN omni.ASPD_XSTO_STRUCTURE axs ON st.ID_STRUCTURE = axs.ID_STRUCTURE " +
" WHERE st.id_structure = ?";
logger.info(storeQuery);
try (PreparedStatement storeStatement = databaseConnectionDS.getConnection().prepareStatement(storeQuery)) {
storeStatement.setInt(1, storeId); // Set the value of the parameter
try (ResultSet storeResultSet = storeStatement.executeQuery()) {
if (storeResultSet.next()) {
Store store = mapResultSetToStore(storeResultSet);
storeDetails.setStore(store);
} else {
// Adjust to the desired behavior if no results are found
}
}
}
// Transaction section
String boTransactionQuery =
"SELECT COUNT(*) AS backOfficeTransactions, " +
" MIN(cf.fdate_integration) AS minBackOfficeTransactionDate, " +
" MAX(cf.fdate_integration) AS maxBackOfficeTransactionDate " +
"FROM com02.client_facture cf " +
"WHERE cf.id_structure = ? " +
" AND cf.id_caisse = ? " +
" AND TRUNC(cf.fdate) = ? " +
" AND cf.version_info = 'XSTORE'";
for (StorePos pos : storeDetails.getPos()) {
logger.info(boTransactionQuery);
try (PreparedStatement boTransactionStatement = databaseConnectionDS.getConnection().prepareStatement(boTransactionQuery)) {
boTransactionStatement.setInt(1, storeId);
boTransactionStatement.setInt(2, pos.getWorkstationId());
boTransactionStatement.setDate(3, pos.getBusinessDate());
try (ResultSet boTransactionResultSet = boTransactionStatement.executeQuery()) {
if (boTransactionResultSet.next()) {
BackOfficeTransaction boTransaction = mapResultSetToBoTransaction(boTransactionResultSet);
pos.setBoTransaction(boTransaction);
} else {
// Adjust to the desired behavior if no results are found
}
}
} catch (SQLException e) {
// Handle exception
}
}
} catch (SQLException e) {
e.printStackTrace();
// Handle exceptions correctly in a production environment
}
// Return the complete StoreDetails object
return storeDetails;
}
private void retrieveStorePosDetails(DatabaseConnectXSTORE databaseConnection, Integer storeId, Integer workstationId, Date businessDate, StorePos pos) throws SQLException {
// Replication section
String replicationQuery = "SELECT COUNT(*) AS pendingReplications, " +
"MIN(crq.CREATE_DATE) AS minPendingReplicationDate, " +
"MAX(crq.CREATE_DATE) AS maxPendingReplicationDate " +
"FROM repqueue.CTL_REPLICATION_QUEUE crq " +
"WHERE crq.organization_id = 1 AND crq.RTL_LOC_ID = ? and crq.WKSTN_ID = ?";
logger.info(replicationQuery);
try (PreparedStatement replicationStatement = databaseConnection.getConnection().prepareStatement(replicationQuery)) {
replicationStatement.setInt(1, storeId);
replicationStatement.setInt(2, workstationId);
try (ResultSet replicationResultSet = replicationStatement.executeQuery()) {
if (replicationResultSet.next()) {
PosReplication posReplication = mapResultSetToPosReplication(replicationResultSet);
pos.setReplication(posReplication);
} else {
// Adjust to the desired behavior if no results are found
}
}
}
// opening transation section
String openingQuery =
"SELECT MIN(lsj.TIME_STAMP) AS minOpeningDate " +
"FROM loc_state_journal lsj " +
"WHERE lsj.TIME_STAMP BETWEEN TRUNC(SYSDATE) AND TRUNC(SYSDATE + 1) " +
"AND lsj.ORGANIZATION_ID = 1 " +
"AND lsj.RTL_LOC_ID = ? " +
"AND lsj.WKSTN_ID = ? " +
"AND lsj.STATUS_TYPCODE = 'WKSTN_STATE' " +
"AND lsj.STRING_VALUE = 'OPEN'";
logger.info(openingQuery);
try (PreparedStatement openingStatement = databaseConnection.getConnection().prepareStatement(openingQuery)) {
openingStatement.setInt(1, storeId);
openingStatement.setInt(2, workstationId);
try (ResultSet openingResultSet = openingStatement.executeQuery()) {
if (openingResultSet.next()) {
pos.setOpeningDate(openingResultSet.getTimestamp("minOpeningDate"));
} else {
// Adjust to the desired behavior if no results are found
}
}
}
// closing transation section
String closingQuery =
"SELECT MAX(lsj.TIME_STAMP) AS maxClosingDate " +
"FROM loc_state_journal lsj " +
"WHERE lsj.TIME_STAMP BETWEEN TRUNC(SYSDATE) AND TRUNC(SYSDATE + 1) " +
"AND lsj.ORGANIZATION_ID = 1 " +
"AND lsj.RTL_LOC_ID = ? " +
"AND lsj.WKSTN_ID = ? " +
"AND lsj.STATUS_TYPCODE = 'WKSTN_STATE' " +
"AND lsj.STRING_VALUE = 'CLOSED'";
logger.info(closingQuery);
try (PreparedStatement closingStatement = databaseConnection.getConnection().prepareStatement(closingQuery)) {
closingStatement.setInt(1, storeId);
closingStatement.setInt(2, workstationId);
try (ResultSet closingResultSet = closingStatement.executeQuery()) {
if (closingResultSet.next()) {
pos.setClosingDate(closingResultSet.getTimestamp("maxClosingDate"));
} else {
// Adjust to the desired behavior if no results are found
}
}
}
// sale transation section
String saleTransactionQuery =
"SELECT COUNT(*) AS counter, " +
"MIN(tt.END_DATETIME) AS minDate, " +
"MAX(tt.END_DATETIME) AS maxDate " +
"FROM dtv.trn_trans tt " +
"WHERE tt.ORGANIZATION_ID = 1 "+
"AND tt.RTL_LOC_ID = ? " +
"AND tt.BUSINESS_DATE = ? " +
"AND tt.WKSTN_ID = ? " +
"AND tt.trans_TYPCODE = 'RETAIL_SALE' " +
"AND tt.TRANS_STATCODE = 'COMPLETE'";
logger.info(saleTransactionQuery);
try (PreparedStatement saleTransactionStatement = databaseConnection.getConnection().prepareStatement(saleTransactionQuery)) {
saleTransactionStatement.setInt(1, storeId);
saleTransactionStatement.setDate(2, pos.getBusinessDate());
saleTransactionStatement.setInt(3, workstationId);
try (ResultSet saleTransactionResultSet = saleTransactionStatement.executeQuery()) {
if (saleTransactionResultSet.next()) {
XstoreTransaction saleTransaction = mapResultSetToSaleTransaction(saleTransactionResultSet);
pos.setSaleTransaction(saleTransaction);
} else {
// Adjust to the desired behavior if no results are found
}
}
}
// sale transation section
String logQuery = "SELECT COUNT(*) as counter " +
"FROM dtv.CTL_EVENT_LOG cel " +
"WHERE cel.CREATE_DATE BETWEEN TRUNC(SYSDATE) AND TRUNC(SYSDATE + 1) " +
"AND cel.ORGANIZATION_ID = 1 " +
"AND cel.RTL_LOC_ID = ? " +
"AND cel.WKSTN_ID = ? " +
"AND cel.LOG_LEVEL = 'FATAL'";
logger.info(logQuery);
try (PreparedStatement logStatement = databaseConnection.getConnection().prepareStatement(logQuery)) {
logStatement.setInt(1, storeId);
logStatement.setInt(2, workstationId);
try (ResultSet logResultSet = logStatement.executeQuery()) {
if (logResultSet.next()) {
pos.setFatalError(logResultSet.getInt("counter"));
} else {
// Adjust to the desired behavior if no results are found
}
}
}
}
private Store mapResultSetToStore(ResultSet resultSet) throws SQLException {
Integer id_structure = resultSet.getInt("id_structure");
String nom = resultSet.getString("nom");
String telephone = resultSet.getString("telephone");
String photoLink = resultSet.getString("photoLink");
String enseigne = resultSet.getString("enseigne");
String pays = resultSet.getString("pays");
String caisses = resultSet.getString("caisses");
String adresse = resultSet.getString("adresse");
Date date_migration = resultSet.getDate("date_migration");
return new Store(id_structure, nom, telephone, photoLink, enseigne, pays, caisses, adresse, date_migration);
}
private PosReplication mapResultSetToPosReplication(ResultSet resultSet) throws SQLException {
int pendingReplications = resultSet.getInt("pendingReplications");
Date minPendingReplicationDate = resultSet.getDate("minPendingReplicationDate");
Date maxPendingReplicationDate = resultSet.getDate("maxPendingReplicationDate");
return new PosReplication(pendingReplications, minPendingReplicationDate, maxPendingReplicationDate);
}
private XstoreTransaction mapResultSetToSaleTransaction(ResultSet resultSet) throws SQLException {
int count = resultSet.getInt("counter");
Date minDate = resultSet.getDate("minDate");
Date maxDate = resultSet.getDate("maxDate");
return new XstoreTransaction(count, minDate, maxDate);
}
private BackOfficeTransaction mapResultSetToBoTransaction(ResultSet resultSet) throws SQLException {
int backofficeTransactions = resultSet.getInt("backOfficeTransactions");
Date minBackofficeTransactionDate = resultSet.getDate("minBackOfficeTransactionDate");
Date maxBackofficeTransactionDate = resultSet.getDate("maxBackOfficeTransactionDate");
return new BackOfficeTransaction(backofficeTransactions, minBackofficeTransactionDate, maxBackofficeTransactionDate);
}
private StoreVersion mapResultSetToStoreVersion(ResultSet resultSet) throws SQLException {
long organizationId = resultSet.getLong("ORGANIZATION_ID");
long seq = resultSet.getLong("SEQ");
String baseSchemaVersion = resultSet.getString("BASE_SCHEMA_VERSION");
String customerSchemaVersion = resultSet.getString("CUSTOMER_SCHEMA_VERSION");
String customer = resultSet.getString("CUSTOMER");
Date baseSchemaDate = resultSet.getDate("BASE_SCHEMA_DATE");
Date customerSchemaDate = resultSet.getDate("CUSTOMER_SCHEMA_DATE");
Date createDate= (resultSet.getDate("CREATE_DATE"));
String createUserId = resultSet.getString("CREATE_USER_ID");
Date updateDate = (resultSet.getDate("UPDATE_DATE"));
String updateUserId =(resultSet.getString("UPDATE_USER_ID"));
return new StoreVersion( organizationId, seq, baseSchemaVersion, customerSchemaVersion, customer, baseSchemaDate, customerSchemaDate, createDate, createUserId, updateDate, updateUserId);
}
private StoreSequence mapResultSetToStoreSequence(ResultSet resultSet) throws SQLException {
long organizationId = resultSet.getLong("ORGANIZATION_ID");
long rtl_loc_id = resultSet.getLong("RTL_LOC_ID");
long wkstnId = resultSet.getLong("WKSTN_ID");
String sequenceId = resultSet.getString("SEQUENCE_ID");
String sequenceMode = resultSet.getString("SEQUENCE_MODE");
Long sequenceNbr = resultSet.getLong("SEQUENCE_NBR");
Date createDate = resultSet.getDate("CREATE_DATE");
String createUserId = resultSet.getString("CREATE_USER_ID");
Date updateDate = resultSet.getDate("UPDATE_DATE");
String updateUserId = resultSet.getString("UPDATE_USER_ID");
String recordState = resultSet.getString("RECORD_STATE");
return new StoreSequence(organizationId, rtl_loc_id, wkstnId, sequenceId, sequenceMode, sequenceNbr, createDate, createUserId, updateDate, updateUserId, recordState);
}
private StoreSignature mapResultSetToStoreSignature(ResultSet resultSet) throws SQLException {
Long organizationId = resultSet.getLong("ORGANIZATION_ID");
Long rtlLocId = resultSet.getLong("RTL_LOC_ID");
Long wkstnId = resultSet.getLong("WKSTN_ID");
String signatureId = resultSet.getString("SIGNATURE_ID");
String signatureMode = resultSet.getString("SIGNATURE_MODE");
String signatureString = resultSet.getString("SIGNATURE_STRING");
String signatureSource = resultSet.getString("SIGNATURE_SOURCE");
Date createDate = resultSet.getDate("CREATE_DATE");
String createUserId = resultSet.getString("CREATE_USER_ID");
Date updateDate = resultSet.getDate("UPDATE_DATE");
String updateUserId = resultSet.getString("UPDATE_USER_ID");
String recordState = resultSet.getString("RECORD_STATE");
return new StoreSignature(organizationId, rtlLocId, wkstnId, signatureId, signatureMode, signatureString, signatureSource, createDate, createUserId, updateDate, updateUserId, recordState);
}
}

View File

@ -0,0 +1,170 @@
package com.example.services;
import com.example.services.xadmin.log.XadminLog;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Path("/xadmin")
public class XadminService {
private static final Logger logger = LoggerFactory.getLogger(DatabaseConnectXADMIN.class);
@GET
@Path("/log")
@Produces(MediaType.APPLICATION_JSON)
public Response getLogByStoreId(@QueryParam("storeId") Integer storeId,
@QueryParam("wkstnId") Integer wkstnId,
@QueryParam("beginDate") String beginDate,
@QueryParam("endDate") String endDate,
@QueryParam("searchText") String searchText) {
if (beginDate == null || endDate == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"BeginDate and EndDate parameters are required\"}").build();
}
DriverManager.setLoginTimeout(5); // Set timeout to 5 seconds
try (DatabaseConnectXADMIN databaseConnection = new DatabaseConnectXADMIN("dtv")) {
String query = "SELECT" +
" FROM_TZ(cel.CREATE_DATE, 'UTC') " +
" AT TIME ZONE " +
" CASE loc.COUNTRY " +
" WHEN 'CH' THEN 'Europe/Zurich' " +
" WHEN 'NL' THEN 'Europe/Amsterdam' " +
" WHEN 'MC' THEN 'Europe/Monaco' " +
" WHEN 'LU' THEN 'Europe/Luxembourg' " +
" WHEN 'ES' THEN 'Europe/Madrid' " +
" WHEN 'FR' THEN 'Europe/Paris' " +
" WHEN 'US' THEN 'America/New_York' " +
" WHEN 'GB' THEN 'Europe/London' " +
" WHEN 'BE' THEN 'Europe/Brussels' " +
" ELSE 'UTC' " +
" END " +
"AS CREATE_DATE, " +
"cel.CREATE_USER_ID, " +
"cel.BUSINESS_DATE, " +
"cel.RTL_LOC_ID, " +
"cel.RTL_LOC_ID || ' - ' || loc.STORE_NAME AS STORE_NAME, " +
"cel.WKSTN_ID, " +
"cel.LOG_LEVEL, " +
"cel.THREAD_NAME, " +
"cel.LOG_MESSAGE, " +
"CASE WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.app.preflight' THEN 'Pre-flight error' " +
" WHEN cel.LOGGER_CATEGORY LIKE 'dtv.xstore.dataloader%' THEN 'DataLoader' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.sysadmin.data.failover' THEN 'Data-failover' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.order.download.offline' THEN 'Order error' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.state.app.startup' THEN 'Xstore startup' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.state.app.shutdown' THEN 'Xstore shutdown' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.helpdesk.memory' THEN 'Application core' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.helpdesk' THEN 'Application core' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.sysadmin.data.repqueue.errors' THEN 'Replication errors' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.sysadmin.data.repqueue.nofails' THEN 'Replication errors' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.hardware.init' THEN 'Hardware init' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.sensitive-data.logging' THEN 'Sensitive data logging' " +
" WHEN cel.LOGGER_CATEGORY = 'dtv.xstore.uncaught' THEN 'Uncaught exception' " +
"ELSE cel.LOGGER_CATEGORY END as LOGGER_CATEGORY " +
"FROM dtv.CTL_EVENT_LOG cel " +
"JOIN dtv.LOC_RTL_LOC loc ON loc.RTL_LOC_ID = cel.RTL_LOC_ID " +
"WHERE cel.CREATE_DATE BETWEEN " +
"TO_TIMESTAMP(?, 'YYYYMMDD HH24:MI:SS') - INTERVAL '3' HOUR " +
"AND " +
"TO_TIMESTAMP(?, 'YYYYMMDD HH24:MI:SS') + INTERVAL '3' HOUR " +
"AND TO_CHAR(FROM_TZ(cel.CREATE_DATE, 'UTC') AT TIME ZONE " +
"CASE loc.COUNTRY " +
" WHEN 'CH' THEN 'Europe/Zurich' " +
" WHEN 'NL' THEN 'Europe/Amsterdam' " +
" WHEN 'MC' THEN 'Europe/Monaco' " +
" WHEN 'LU' THEN 'Europe/Luxembourg' " +
" WHEN 'ES' THEN 'Europe/Madrid' " +
" WHEN 'FR' THEN 'Europe/Paris' " +
" WHEN 'US' THEN 'America/New_York' " +
" WHEN 'GB' THEN 'Europe/London' " +
" WHEN 'BE' THEN 'Europe/Brussels' " +
" ELSE 'UTC' " +
"END, 'YYYYMMDD HH24:MI:SS') BETWEEN ? AND ? " +
"AND cel.ORGANIZATION_ID = 1 " +
(storeId != null ? "AND cel.RTL_LOC_ID = ? " : "") +
(wkstnId != null ? "AND cel.WKSTN_ID = ? " : "") +
(searchText != null ? "AND LOWER(cel.LOG_MESSAGE) LIKE ? " : "") +
"AND cel.THREAD_NAME IS NOT NULL " +
"ORDER BY cel.CREATE_DATE DESC";
logger.info(query);
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query)) {
statement.setString(1, beginDate);
statement.setString(2, endDate + " 23:59:59");
statement.setString(3, beginDate);
statement.setString(4, endDate + " 23:59:59");
Integer indexParam = 5;
if (storeId != null) {
statement.setInt( indexParam++, storeId);
}
if (wkstnId != null) {
statement.setInt(indexParam++,wkstnId);
}
if(searchText != null) {
statement.setString(indexParam++, "%" + searchText.toLowerCase() + "%");
}
try (ResultSet resultSet = statement.executeQuery()) {
List<XadminLog> xadminLogList = new ArrayList<>();
while (resultSet.next()) {
XadminLog xadminLog = mapResultSetToXadminLog(resultSet);
xadminLogList.add(xadminLog);
}
ObjectMapper objectMapper = new ObjectMapper();
String jsonResponse = objectMapper.writeValueAsString(xadminLogList);
return Response.ok(jsonResponse).build();
}
}
} catch (SQLException e) {
e.printStackTrace();
String errorResponse = "{\"error\":\"" + e.getMessage() + "\"}";
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponse).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();
}
}
public XadminLog mapResultSetToXadminLog(ResultSet resultSet) throws SQLException {
XadminLog xadminlog = new XadminLog();
xadminlog.setCreateDate(resultSet.getDate("CREATE_DATE"));
xadminlog.setCreateUserId(resultSet.getString("CREATE_USER_ID"));
xadminlog.setBusinessDate(resultSet.getDate("BUSINESS_DATE"));
xadminlog.setRtlLocId(resultSet.getInt("RTL_LOC_ID"));
xadminlog.setStoreName(resultSet.getString("STORE_NAME"));
xadminlog.setWkstnId(resultSet.getInt("WKSTN_ID"));
xadminlog.setLogLevel(resultSet.getString("LOG_LEVEL"));
xadminlog.setThreadName(resultSet.getString("THREAD_NAME"));
xadminlog.setLogMessage(resultSet.getString("LOG_MESSAGE"));
xadminlog.setLoggerCategory(resultSet.getString("LOGGER_CATEGORY"));
return xadminlog;
}
}

View File

@ -0,0 +1,206 @@
package com.example.services.flux.bl;
import java.sql.Date;
import java.text.SimpleDateFormat;
public class FluxBlNotSent {
private Integer id_distrib;
private String libelle_dis;
private Integer id_structure;
private String nom_structure;
private String enseigne;
private String marque;
private String code_saison;
private String ref_r;
private String ref_rc;
private String ref_rct;
private String nom_produit;
private Integer id_produit;
private String code_externe;
private Integer id_bon_livraison;
private Date date_bl;
private Integer id_expediteur;
private String expediteur;
private String remarques;
// Default constructor
public FluxBlNotSent() {
// Default constructor implementation
}
// Constructor with parameters
public FluxBlNotSent(Integer idDistrib, String libelleDis, Integer idStructure, String nomStructure,
String enseigne, String marque, String codeSaison, String refR,
String refRc, String refRct, String nomProduit, Integer idProduit,
String codeExterne, Integer idBonLivraison, Date dateBl,
Integer idExpediteur, String expediteur, String remarques) {
this.id_distrib = idDistrib;
this.libelle_dis = libelleDis;
this.id_structure = idStructure;
this.nom_structure = nomStructure;
this.enseigne = enseigne;
this.marque = marque;
this.code_saison = codeSaison;
this.ref_r = refR;
this.ref_rc = refRc;
this.ref_rct = refRct;
this.nom_produit = nomProduit;
this.id_produit = idProduit;
this.code_externe = codeExterne;
this.id_bon_livraison = idBonLivraison;
this.date_bl = dateBl;
this.id_expediteur = idExpediteur;
this.expediteur = expediteur;
this.remarques = remarques;
}
// getters and setters
public Integer getIdDistrib() {
return id_distrib;
}
public void setIdDistrib(Integer idDistrib) {
this.id_distrib = idDistrib;
}
public String getLibelleDis() {
return id_distrib + " - " + libelle_dis;
}
public void setLibelleDis(String libelleDis) {
this.libelle_dis = libelleDis;
}
public Integer getIdStructure() {
return id_structure;
}
public void setIdStructure(Integer idStructure) {
this.id_structure = idStructure;
}
public String getNomStructure() {
return id_structure + " - " + nom_structure;
}
public void setNomStructure(String nom) {
this.nom_structure = nom;
}
public String getEnseigne() {
return enseigne;
}
public void setEnseigne(String enseigne) {
this.enseigne = enseigne;
}
public String getMarque() {
return marque;
}
public void setMarque(String marque) {
this.marque = marque;
}
public String getCodeSaison() {
return code_saison;
}
public void setCodeSaison(String codeSaison) {
this.code_saison = codeSaison;
}
public String getRefR() {
return ref_r;
}
public void setRefR(String refR) {
this.ref_r = refR;
}
public String getRefRc() {
return ref_rc;
}
public void setRefRc(String refRc) {
this.ref_rc = refRc;
}
public String getRefRct() {
return ref_rct;
}
public void setRefRct(String refRct) {
this.ref_rct = refRct;
}
public String getNomProduit() {
return nom_produit;
}
public void setNomProduit(String nomProduit) {
this.nom_produit = nomProduit;
}
public Integer getIdProduit() {
return id_produit;
}
public void setIdProduit(Integer idProduit) {
this.id_produit = idProduit;
}
public String getCodeExterne() {
return code_externe;
}
public void setCodeExterne(String codeExterne) {
this.code_externe = codeExterne;
}
public Integer getIdBonLivraison() {
return id_bon_livraison;
}
public void setIdBonLivraison(Integer idBonLivraison) {
this.id_bon_livraison = idBonLivraison;
}
public String getDateBl() {
if (date_bl != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(date_bl);
} else {
return "";
}
}
public void setDateBl(Date dateBl) {
this.date_bl = dateBl;
}
public Integer getIdExpediteur() {
return id_expediteur;
}
public void setIdExpediteur(Integer idExpediteur) {
this.id_expediteur = idExpediteur;
}
public String getExpediteur() {
return id_expediteur + " - " + expediteur;
}
public void setExpediteur(String expediteur) {
this.expediteur = expediteur;
}
public String getRemarques() {
return remarques;
}
public void setRemarques(String remarques) {
this.remarques = remarques;
}
}

View File

@ -0,0 +1,291 @@
package com.example.services.item;
import java.sql.Date;
import java.text.SimpleDateFormat;
public class Item {
private Long organizationId;
private String itemId;
private String orgCode;
private String orgValue;
private String name;
private String description;
private String merchLevel1;
private String merchLevel2;
private String merchLevel3;
private String merchLevel4;
private Integer listPrice;
private Integer measureReqFlag;
private String itemLevelCode;
private String parentItemId;
private Integer notInventoriedFlag;
private Integer serializedItemFlag;
private String itemTypeCode;
private String dtvClassName;
private String dimensionSystem;
private Integer disallowMatrixDisplayFlag;
private String itemMatrixColor;
private String dimension1;
private String dimension2;
private String dimension3;
private String externalSystem;
private Date createDate;
private String createUserId;
private Date updateDate;
private String updateUserId;
// Constructeur par défaut
public Item() {
// Default constructor required for JSON deserialization
}
// Getters and Setters for all fields
public Long getOrganizationId() {
return organizationId;
}
public void setOrganizationId(Long organizationId) {
this.organizationId = organizationId;
}
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getOrgCode() {
return orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public String getOrgValue() {
return orgValue;
}
public void setOrgValue(String orgValue) {
this.orgValue = orgValue;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getMerchLevel1() {
return merchLevel1;
}
public void setMerchLevel1(String merchLevel1) {
this.merchLevel1 = merchLevel1;
}
public String getMerchLevel2() {
return merchLevel2;
}
public void setMerchLevel2(String merchLevel2) {
this.merchLevel2 = merchLevel2;
}
public String getMerchLevel3() {
return merchLevel3;
}
public void setMerchLevel3(String merchLevel3) {
this.merchLevel3 = merchLevel3;
}
public String getMerchLevel4() {
return merchLevel4;
}
public void setMerchLevel4(String merchLevel4) {
this.merchLevel4 = merchLevel4;
}
public Integer getListPrice() {
return listPrice;
}
public void setListPrice(Integer listPrice) {
this.listPrice = listPrice;
}
public Integer getMeasureReqFlag() {
return measureReqFlag;
}
public void setMeasureReqFlag(Integer measureReqFlag) {
this.measureReqFlag = measureReqFlag;
}
public String getItemLevelCode() {
return itemLevelCode;
}
public void setItemLevelCode(String itemLevelCode) {
this.itemLevelCode = itemLevelCode;
}
public String getParentItemId() {
return parentItemId;
}
public void setParentItemId(String parentItemId) {
this.parentItemId = parentItemId;
}
public Integer getNotInventoriedFlag() {
return notInventoriedFlag;
}
public void setNotInventoriedFlag(Integer notInventoriedFlag) {
this.notInventoriedFlag = notInventoriedFlag;
}
public Integer getSerializedItemFlag() {
return serializedItemFlag;
}
public void setSerializedItemFlag(Integer serializedItemFlag) {
this.serializedItemFlag = serializedItemFlag;
}
public String getItemTypeCode() {
return itemTypeCode;
}
public void setItemTypeCode(String itemTypeCode) {
this.itemTypeCode = itemTypeCode;
}
public String getDtvClassName() {
return dtvClassName;
}
public void setDtvClassName(String dtvClassName) {
this.dtvClassName = dtvClassName;
}
public String getDimensionSystem() {
return dimensionSystem;
}
public void setDimensionSystem(String dimensionSystem) {
this.dimensionSystem = dimensionSystem;
}
public Integer getDisallowMatrixDisplayFlag() {
return disallowMatrixDisplayFlag;
}
public void setDisallowMatrixDisplayFlag(Integer disallowMatrixDisplayFlag) {
this.disallowMatrixDisplayFlag = disallowMatrixDisplayFlag;
}
public String getItemMatrixColor() {
return itemMatrixColor;
}
public void setItemMatrixColor(String itemMatrixColor) {
this.itemMatrixColor = itemMatrixColor;
}
public String getDimension1() {
return dimension1;
}
public void setDimension1(String dimension1) {
this.dimension1 = dimension1;
}
public String getDimension2() {
return dimension2;
}
public void setDimension2(String dimension2) {
this.dimension2 = dimension2;
}
public String getDimension3() {
return dimension3;
}
public void setDimension3(String dimension3) {
this.dimension3 = dimension3;
}
public String getExternalSystem() {
return externalSystem;
}
public void setExternalSystem(String externalSystem) {
this.externalSystem = externalSystem;
}
public String getCreateDate() {
if (createDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(createDate);
} else {
return "";
}
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getCreateUserId() {
if (createUserId == null) {
return "";
}
return createUserId;
}
public void setCreateUserId(String createUserId) {
this.createUserId = createUserId;
}
public String getUpdateDate() {
if (updateDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(updateDate);
} else {
return "";
}
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public String getUpdateUserId() {
if (updateUserId == null) {
return "";
}
return updateUserId;
}
public void setUpdateUserId(String updateUserId) {
this.updateUserId = updateUserId;
}
}

View File

@ -0,0 +1,130 @@
package com.example.services.item;
import java.sql.Date;
import java.text.SimpleDateFormat;
public class ItemOption {
private String itemId;
private String levelCode;
private String levelValue;
private String itemAvailabilityCode;
private String taxGroupId;
private String vendor;
private String seasonCode;
private Date createDate;
private String createUserId;
private Date updateDate;
private String updateUserId;
public ItemOption() {
// Default constructor required for JSON deserialization
}
// Getters and Setters for all fields
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getLevelCode() {
return levelCode;
}
public void setLevelCode(String levelCode) {
this.levelCode = levelCode;
}
public String getLevelValue() {
return levelValue;
}
public void setLevelValue(String levelValue) {
this.levelValue = levelValue;
}
public String getItemAvailabilityCode() {
return itemAvailabilityCode;
}
public void setItemAvailabilityCode(String itemAvailabilityCode) {
this.itemAvailabilityCode = itemAvailabilityCode;
}
public String getTaxGroupId() {
return taxGroupId;
}
public void setTaxGroupId(String taxGroupId) {
this.taxGroupId = taxGroupId;
}
public String getVendor() {
return vendor;
}
public void setVendor(String vendor) {
this.vendor = vendor;
}
public String getSeasonCode() {
return seasonCode;
}
public void setSeasonCode(String seasonCode) {
this.seasonCode = seasonCode;
}
public String getCreateDate() {
if (createDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(createDate);
} else {
return "";
}
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getCreateUserId() {
if (createUserId == null) {
return "";
}
return createUserId;
}
public void setCreateUserId(String createUserId) {
this.createUserId = createUserId;
}
public String getUpdateDate() {
if (updateDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(updateDate);
} else {
return "";
}
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public String getUpdateUserId() {
if (updateUserId == null) {
return "";
}
return updateUserId;
}
public void setUpdateUserId(String updateUserId) {
this.updateUserId = updateUserId;
}
}

View File

@ -0,0 +1,165 @@
package com.example.services.item;
import java.sql.Date;
import java.text.SimpleDateFormat;
public class ItemPrice {
private String itemId;
private String levelCode;
private String levelValue;
private String itmPricePropertyCode;
private Date effectiveDate;
private Date expirationDate;
private Double price;
private Double priceQty;
private String externalId;
private String externalSystem;
private Date createDate;
private String createUserId;
private Date updateDate;
private String updateUserId;
public ItemPrice() {
// Default constructor required for JSON deserialization
}
// Getters and Setters for all fields
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getLevelCode() {
return levelCode;
}
public void setLevelCode(String levelCode) {
this.levelCode = levelCode;
}
public String getLevelValue() {
return levelValue;
}
public void setLevelValue(String levelValue) {
this.levelValue = levelValue;
}
public String getItmPricePropertyCode() {
return itmPricePropertyCode;
}
public void setItmPricePropertyCode(String itmPricePropertyCode) {
this.itmPricePropertyCode = itmPricePropertyCode;
}
public String getEffectiveDate() {
if (effectiveDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(effectiveDate);
} else {
return "";
}
}
public void setEffectiveDate(Date effectiveDate) {
this.effectiveDate = effectiveDate;
}
public String getExpirationDate() {
if (expirationDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(expirationDate);
} else {
return "";
}
}
public void setExpirationDate(Date expirationDate) {
this.expirationDate = expirationDate;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
public Double getPriceQty() {
return priceQty;
}
public void setPriceQty(Double priceQty) {
this.priceQty = priceQty;
}
public String getExternalId() {
return externalId;
}
public void setExternalId(String externalId) {
this.externalId = externalId;
}
public String getExternalSystem() {
return externalSystem;
}
public void setExternalSystem(String externalSystem) {
this.externalSystem = externalSystem;
}
public String getCreateDate() {
if (createDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(createDate);
} else {
return "";
}
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getCreateUserId() {
if (createUserId == null) {
return "";
}
return createUserId;
}
public void setCreateUserId(String createUserId) {
this.createUserId = createUserId;
}
public String getUpdateDate() {
if (updateDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(updateDate);
} else {
return "";
}
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public String getUpdateUserId() {
if (updateUserId == null) {
return "";
}
return updateUserId;
}
public void setUpdateUserId(String updateUserId) {
this.updateUserId = updateUserId;
}
}

View File

@ -0,0 +1,122 @@
package com.example.services.item;
import java.text.SimpleDateFormat;
import java.util.Date;
public class ItemStock {
private String organizationId;
private String rtlLocId;
private String invLocationId;
private String bucketId;
private String itemId;
private int unitCount;
private double inventoryValue;
private Date createDate;
private String createUserId;
private Date updateDate;
private String updateUserId;
public String getOrganizationId() {
return organizationId;
}
public void setOrganizationId(String organizationId) {
this.organizationId = organizationId;
}
public String getRtlLocId() {
return rtlLocId;
}
public void setRtlLocId(String rtlLocId) {
this.rtlLocId = rtlLocId;
}
public String getInvLocationId() {
return invLocationId;
}
public void setInvLocationId(String invLocationId) {
this.invLocationId = invLocationId;
}
public String getBucketId() {
return bucketId;
}
public void setBucketId(String bucketId) {
this.bucketId = bucketId;
}
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public int getUnitCount() {
return unitCount;
}
public void setUnitCount(int unitCount) {
this.unitCount = unitCount;
}
public double getInventoryValue() {
return inventoryValue;
}
public void setInventoryValue(double inventoryValue) {
this.inventoryValue = inventoryValue;
}
public String getCreateDate() {
if (createDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(createDate);
} else {
return "";
}
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getCreateUserId() {
if (createUserId == null) {
return "";
}
return createUserId;
}
public void setCreateUserId(String createUserId) {
this.createUserId = createUserId;
}
public String getUpdateDate() {
if (updateDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(updateDate);
} else {
return "";
}
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public String getUpdateUserId() {
if (updateUserId == null) {
return "";
}
return updateUserId;
}
public void setUpdateUserId(String updateUserId) {
this.updateUserId = updateUserId;
}
}

View File

@ -0,0 +1,58 @@
package com.example.services.store;
import java.sql.Date;
import java.text.SimpleDateFormat;
public class BackOfficeTransaction {
private int backOfficeTransactions;
private Date minBackOfficeTransactionDate;
private Date maxBackOfficeTransactionDate;
// Default constructor
public BackOfficeTransaction() {
// Default constructor required for JSON deserialization
}
// Constructor with parameters
public BackOfficeTransaction(int backOfficeTransactions, Date minbackOfficeTransactionDate, Date maxbackOfficeTransactionDate) {
this.backOfficeTransactions = backOfficeTransactions;
this.minBackOfficeTransactionDate = minbackOfficeTransactionDate;
this.maxBackOfficeTransactionDate = maxbackOfficeTransactionDate;
}
// Getters et setters
public int getBackOfficeTransactions() {
return backOfficeTransactions;
}
public void setBackOfficeTransactions(int backOfficeTransactions) {
this.backOfficeTransactions = backOfficeTransactions;
}
public String getMinBackOfficeTransactionDate() {
if (minBackOfficeTransactionDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(minBackOfficeTransactionDate);
} else {
return "";
}
}
public void setMinBackOfficeTransactionDate(Date minBackOfficeTransactionDate) {
this.minBackOfficeTransactionDate = minBackOfficeTransactionDate;
}
public String getMaxBackOfficeTransactionDate() {
if (maxBackOfficeTransactionDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(maxBackOfficeTransactionDate);
} else {
return "";
}
}
public void setMaxBackOfficeTransactionDate(Date maxBackOfficeTransactionDate) {
this.maxBackOfficeTransactionDate = maxBackOfficeTransactionDate;
}
}

View File

@ -0,0 +1,58 @@
package com.example.services.store;
import java.sql.Date;
import java.text.SimpleDateFormat;
public class PosReplication {
private int pendingReplications;
private Date minPendingReplicationDate;
private Date maxPendingReplicationDate;
// Default constructor
public PosReplication() {
// Default constructor required for JSON deserialization
}
// Constructor with parameters
public PosReplication(int pendingReplications, Date minPendingReplicationDate, Date maxPendingReplicationDate) {
this.pendingReplications = pendingReplications;
this.minPendingReplicationDate = minPendingReplicationDate;
this.maxPendingReplicationDate = maxPendingReplicationDate;
}
// Getters et setters
public int getPendingReplications() {
return pendingReplications;
}
public void setPendingReplications(int pendingReplications) {
this.pendingReplications = pendingReplications;
}
public String getMinPendingReplicationDate() {
if (minPendingReplicationDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(minPendingReplicationDate);
} else {
return "";
}
}
public void setMinReplicationDate(Date minPendingReplicationDate) {
this.minPendingReplicationDate = minPendingReplicationDate;
}
public String getMaxPendingReplicationDate() {
if (maxPendingReplicationDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(maxPendingReplicationDate);
} else {
return "";
}
}
public void setMaxReplicationDate(Date maxPendingReplicationDate) {
this.maxPendingReplicationDate = maxPendingReplicationDate;
}
}

View File

@ -0,0 +1,162 @@
package com.example.services.store;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class Store {
private Integer id_structure;
private String nom;
private String ip_master;
private String telephone;
private String photoLink;
private String enseigne;
private String pays;
private Integer nbcaisses;
private String adresse;
private List<Caisse> caisses;
private Date date_migration;
// Default constructor
public Store() {
// Default constructor required for JSON deserialization
}
// Constructor with parameters
public Store(Integer id_structure, String nom, String telephone, String photoLink, String enseigne, String pays, String caisses, String adresse, Date date_migration) {
this.id_structure = id_structure;
this.nom = nom;
this.telephone = telephone;
this.photoLink = photoLink;
this.enseigne = enseigne;
this.pays = pays;
this.adresse = adresse;
this.date_migration = date_migration;
setCaisses(caisses);
}
public Integer getId_structure() {
return id_structure;
}
public void setId_structure(Integer id_structure) {
this.id_structure = id_structure;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getIp_master() {
if (!this.caisses.isEmpty()) {
return this.caisses.get(0).getIp();
}
return "";
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getPhotoLink() {
return photoLink;
}
public void setPhotoLink(String photoLink) {
this.photoLink = photoLink;
}
public String getEnseigne() {
return enseigne;
}
public void setEnseigne(String enseigne) {
this.enseigne = enseigne;
}
public String getPays() {
return pays;
}
public void setPays(String pays) {
this.pays = pays;
}
public Integer getNbcaisses() {
return this.caisses.size();
}
public void setAdresse(String adresse) {
this.adresse = adresse;
}
public String getAdresse() {
return this.adresse;
}
public List<Caisse> getCaisses() {
return this.caisses;
}
public void setCaisses(String caisses) {
this.caisses = new ArrayList<>();
for (String caisse : caisses.split(",")) {
String[] parts = caisse.split("\\|");
this.caisses.add(new Caisse(Integer.parseInt(parts[0]), parts[1]));
}
Collections.sort(this.caisses, Comparator.comparing(Caisse::getId_caisse));
}
public String getDate_migration() {
if (date_migration != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(date_migration);
} else {
return "";
}
}
public void setDate_migration(Date date_migration) {
this.date_migration = date_migration;
}
public class Caisse {
private Integer id_caisse;
private String ip;
public Caisse(Integer id_caisse, String ip) {
this.id_caisse = id_caisse;
this.ip = ip;
}
public Integer getId_caisse() {
return id_caisse;
}
public void setId_caisse(Integer id_caisse) {
this.id_caisse = id_caisse;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
}
}

View File

@ -0,0 +1,36 @@
package com.example.services.store;
import java.util.ArrayList;
import java.util.List;
public class StoreDetails {
private Store store;
private List<StorePos> pos;
public StoreDetails() {
// Constructeur par défaut nécessaire pour la désérialisation JSON
this.pos = new ArrayList<>();
}
public StoreDetails(Store store, List<StorePos> pos) {
this.store = store;
this.pos = pos != null ? pos : new ArrayList<>();
}
public Store getStore() {
return store;
}
public void setStore(Store store) {
this.store = store;
}
public List<StorePos> getPos() {
return pos;
}
public void setPos(List<StorePos> pos) {
this.pos = pos;
}
}

View File

@ -0,0 +1,138 @@
package com.example.services.store;
import java.sql.Date;
import java.text.SimpleDateFormat;
public class StorePos {
private int workstationId;
private String ip;
private String version;
private Date businessDate;
private String openingDate;
private String closingDate;
private BackOfficeTransaction boTransaction;
private PosReplication replication;
private XstoreTransaction saleTransaction;
private boolean primaryRegister = false;
private boolean fatalError = false;
// Default constructor
public StorePos() {
// Default constructor required for JSON deserialization
}
// Constructor with parameters
public StorePos( int workstationId, String ip, String version, Date businessDate, String openingDate, String closingDate ,BackOfficeTransaction boTransaction, PosReplication replication, XstoreTransaction saleTransaction, boolean primaryRegister, boolean fatalError) {
this.workstationId = workstationId;
this.ip = ip;
this.version = version;
this.businessDate = businessDate;
this.openingDate = openingDate;
this.closingDate = closingDate;
this.boTransaction = boTransaction;
this.replication = replication;
this.saleTransaction = saleTransaction;
this.primaryRegister = primaryRegister;
this.fatalError = fatalError;
}
// Getters et setters
public int getWorkstationId() {
return workstationId;
}
public void setWorkstationId(int workstationId) {
this.workstationId = workstationId;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getBusinessDateS() {
if (businessDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
return dateFormat.format(businessDate);
} else {
return "";
}
}
public Date getBusinessDate() {
return businessDate;
}
public void setBusinessDate(Date businessDate) {
this.businessDate = businessDate;
}
public String getOpeningDate() {
return openingDate;
}
public void setOpeningDate(java.sql.Timestamp openingDate) {
if (openingDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
String strOpeningDate = dateFormat.format(openingDate);
this.openingDate = strOpeningDate;
}
}
public String getClosingDate() {
return closingDate;
}
public void setClosingDate(java.sql.Timestamp closingDate) {
if (closingDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
String strClosingDate = dateFormat.format(closingDate);
this.closingDate = strClosingDate;
}
}
public BackOfficeTransaction getBoTransaction() {
return boTransaction;
}
public void setBoTransaction(BackOfficeTransaction boTransaction) {
this.boTransaction = boTransaction;
}
public PosReplication getReplication() {
return replication;
}
public void setReplication(PosReplication replication) {
this.replication = replication;
}
public XstoreTransaction getSaleTransaction() {
return saleTransaction;
}
public void setSaleTransaction(XstoreTransaction saleTransaction) {
this.saleTransaction = saleTransaction;
}
public boolean isPrimaryRegister() {
return primaryRegister;
}
public void setPrimaryRegister(int primaryRegister) {
this.primaryRegister = (primaryRegister == 1);
}
public boolean isFatalError() {
return fatalError;
}
public void setFatalError(int fatalError) {
this.fatalError = (fatalError > 0);
}
}

View File

@ -0,0 +1,137 @@
package com.example.services.store;
import java.util.Date;
import java.text.SimpleDateFormat;
public class StoreSequence {
private Long organizationId;
private Long rtlLocId;
private Long wkstnId;
private String sequenceId;
private String sequenceMode;
private Long sequenceNbr;
private Date createDate;
private String createUserId;
private Date updateDate;
private String updateUserId;
private String recordState;
// Default constructor
public StoreSequence() {
// Default constructor required for JSON deserialization
}
public StoreSequence(Long organizationId, Long rtlLocId, Long wkstnId, String sequenceId, String sequenceMode, Long sequenceNbr, Date createDate, String createUserId, Date updateDate, String updateUserId, String recordState) {
this.organizationId = organizationId;
this.rtlLocId = rtlLocId;
this.wkstnId = wkstnId;
this.sequenceId = sequenceId;
this.sequenceMode = sequenceMode;
this.sequenceNbr = sequenceNbr;
this.createDate = createDate;
this.createUserId = createUserId;
this.updateDate = updateDate;
this.updateUserId = updateUserId;
this.recordState = recordState;
}
// Getters and Setters for all fields
public Long getOrganizationId() {
return organizationId;
}
public void setOrganizationId(Long organizationId) {
this.organizationId = organizationId;
}
public Long getRtlLocId() {
return rtlLocId;
}
public void setRtlLocId(Long rtlLocId) {
this.rtlLocId = rtlLocId;
}
public Long getWkstnId() {
return wkstnId;
}
public void setWkstnId(Long wkstnId) {
this.wkstnId = wkstnId;
}
public String getSequenceId() {
return sequenceId;
}
public void setSequenceId(String sequenceId) {
this.sequenceId = sequenceId;
}
public String getSequenceMode() {
return sequenceMode;
}
public void setSequenceMode(String sequenceMode) {
this.sequenceMode = sequenceMode;
}
public Long getSequenceNbr() {
return sequenceNbr;
}
public void setSequenceNbr(Long sequenceNbr) {
this.sequenceNbr = sequenceNbr;
}
public String getCreateDate() {
if (createDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(createDate);
} else {
return "";
}
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getCreateUserId() {
return createUserId == null ? "" : createUserId;
}
public void setCreateUserId(String createUserId) {
this.createUserId = createUserId;
}
public String getUpdateDate() {
if (updateDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(updateDate);
} else {
return "";
}
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public String getUpdateUserId() {
return updateUserId == null ? "" : updateUserId;
}
public void setUpdateUserId(String updateUserId) {
this.updateUserId = updateUserId;
}
public String getRecordState() {
return recordState;
}
public void setRecordState(String recordState) {
this.recordState = recordState;
}
}

View File

@ -0,0 +1,155 @@
package com.example.services.store;
import java.util.Date;
import java.text.SimpleDateFormat;
public class StoreSignature {
private Long organizationId;
private Long rtlLocId;
private Long wkstnId;
private String signatureId;
private String signatureMode;
private String signatureString;
private String signatureSource;
private Date createDate;
private String createUserId;
private Date updateDate;
private String updateUserId;
private String recordState;
// Default constructor
public StoreSignature() {
// Default constructor required for JSON deserialization
}
public StoreSignature(Long organizationId, Long rtlLocId, Long wkstnId, String signatureId, String signatureMode, String signatureString, String signatureSource, Date createDate, String createUserId, Date updateDate, String updateUserId, String recordState) {
this.organizationId = organizationId;
this.rtlLocId = rtlLocId;
this.wkstnId = wkstnId;
this.signatureId = signatureId;
this.signatureMode = signatureMode;
this.signatureString = signatureString;
this.signatureSource = signatureSource;
this.createDate = createDate;
this.createUserId = createUserId;
this.updateDate = updateDate;
this.updateUserId = updateUserId;
this.recordState = recordState;
}
// Getters and Setters for all fields
public Long getOrganizationId() {
return organizationId;
}
public void setOrganizationId(Long organizationId) {
this.organizationId = organizationId;
}
public Long getRtlLocId() {
return rtlLocId;
}
public void setRtlLocId(Long rtlLocId) {
this.rtlLocId = rtlLocId;
}
public Long getWkstnId() {
return wkstnId;
}
public void setWkstnId(Long wkstnId) {
this.wkstnId = wkstnId;
}
public String getSignatureId() {
return signatureId;
}
public void setSignatureId(String signatureId) {
this.signatureId = signatureId;
}
public String getSignatureMode() {
return signatureMode;
}
public void setSignatureMode(String signatureMode) {
this.signatureMode = signatureMode;
}
public String getSignatureString() {
if (signatureString != null) {
return signatureString;
} else {
return "";
}
}
public void setSignatureString(String signatureString) {
this.signatureString = signatureString;
}
public String getSignatureSource() {
if (signatureSource != null) {
return signatureSource;
} else {
return "";
}
}
public void setSignatureSource(String signatureSource) {
this.signatureSource = signatureSource;
}
public String getCreateDate() {
if (createDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(createDate);
} else {
return "";
}
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getCreateUserId() {
return createUserId;
}
public void setCreateUserId(String createUserId) {
this.createUserId = createUserId;
}
public String getUpdateDate() {
if (updateDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(updateDate);
} else {
return "";
}
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public String getUpdateUserId() {
return updateUserId;
}
public void setUpdateUserId(String updateUserId) {
this.updateUserId = updateUserId;
}
public String getRecordState() {
return recordState;
}
public void setRecordState(String recordState) {
this.recordState = recordState;
}
}

View File

@ -0,0 +1,147 @@
package com.example.services.store;
import java.sql.Date;
import java.text.SimpleDateFormat;
public class StoreVersion {
private Long organizationId;
private Long seq;
private String baseSchemaVersion;
private String customerSchemaVersion;
private String customer;
private Date baseSchemaDate;
private Date customerSchemaDate;
private Date createDate;
private String createUserId;
private Date updateDate;
private String updateUserId;
// Default constructor
public StoreVersion() {
// Default constructor required for JSON deserialization
}
public StoreVersion(Long organisation_id, Long seq, String base_schema_version, String customer_schema_version, String customer, Date base_schema_date, Date customer_schema_date, Date createDate, String create_user_id, Date update_date, String update_user_id) {
this.organizationId = organisation_id;
this.seq = seq;
this.baseSchemaVersion = base_schema_version;
this.customerSchemaVersion = customer_schema_version;
this.customer = customer;
this.baseSchemaDate = base_schema_date;
this.customerSchemaDate = customer_schema_date;
this.createDate = createDate;
this.createUserId = create_user_id;
this.updateDate = update_date;
this.updateUserId = update_user_id;
};
// Getters and Setters for all fields
public Long getOrganizationId() {
return organizationId;
}
public void setOrganizationId(Long organizationId) {
this.organizationId = organizationId;
}
public Long getSeq() {
return seq;
}
public void setSeq(Long seq) {
this.seq = seq;
}
public String getBaseSchemaVersion() {
return baseSchemaVersion;
}
public void setBaseSchemaVersion(String baseSchemaVersion) {
this.baseSchemaVersion = baseSchemaVersion;
}
public String getCustomerSchemaVersion() {
return customerSchemaVersion;
}
public void setCustomerSchemaVersion(String customerSchemaVersion) {
this.customerSchemaVersion = customerSchemaVersion;
}
public String getCustomer() {
return customer;
}
public void setCustomer(String customer) {
this.customer = customer;
}
public String getBaseSchemaDate() {
if (baseSchemaDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(baseSchemaDate);
} else {
return "";
}
}
public void setBaseSchemaDate(Date baseSchemaDate) {
this.baseSchemaDate = baseSchemaDate;
}
public String getCustomerSchemaDate() {
if (customerSchemaDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(customerSchemaDate);
} else {
return "";
}
}
public void setCustomerSchemaDate(Date customerSchemaDate) {
this.customerSchemaDate = customerSchemaDate;
}
public String getCreateDate() {
if (createDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(createDate);
} else {
return "";
}
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getCreateUserId() {
return createUserId;
}
public void setCreateUserId(String createUserId) {
this.createUserId = createUserId;
}
public String getUpdateDate() {
if (updateDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(updateDate);
} else {
return "";
}
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public String getUpdateUserId() {
return updateUserId;
}
public void setUpdateUserId(String updateUserId) {
this.updateUserId = updateUserId;
}
}

View File

@ -0,0 +1,98 @@
package com.example.services.store;
import java.sql.Date;
import java.text.SimpleDateFormat;
public class XstoreTransaction {
private int count;
private Date minDate;
private Date maxDate;
private String minDateT;
private String minDateH;
private String maxDateT;
private String maxDateH;
// Default constructor
public XstoreTransaction() {
// Default constructor required for JSON deserialization
}
// Constructor with parameters
public XstoreTransaction(int count, Date minDate, Date maxDate) {
this.count = count;
this.minDate = minDate;
this.maxDate = maxDate;
}
// Getters et setters
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public String getMinDate() {
if (minDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(minDate);
} else {
return "";
}
}
public void setMinDate(Date minDate) {
this.minDate = minDate;
}
public String getMaxDate() {
if (maxDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return dateFormat.format(maxDate);
} else {
return "";
}
}
public void setMaxDate(Date maxDate) {
this.maxDate = maxDate;
}
public String getMinDateT() {
if (minDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
return dateFormat.format(minDate);
} else {
return "";
}
}
public String getMinDateH() {
if (minDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
return dateFormat.format(minDate);
} else {
return "";
}
}
public String getMaxDateT() {
if (maxDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
return dateFormat.format(maxDate);
} else {
return "";
}
}
public String getMaxDateH() {
if (maxDate != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
return dateFormat.format(maxDate);
} else {
return "";
}
}
}

View File

@ -0,0 +1,96 @@
package com.example.services.xadmin.log;
import java.util.Date;
public class XadminLog {
private Date businessDate;
private Date createDate;
private String createUserId;
private Integer rtlLocId;
private Integer wkstnId;
private String logLevel;
private String threadName;
private String logMessage;
private String loggerCategory;
private String storeName;
public Date getBusinessDate() {
return businessDate;
}
public void setBusinessDate(Date businessDate) {
this.businessDate = businessDate;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getCreateUserId() {
return createUserId;
}
public void setCreateUserId(String createUserId) {
this.createUserId = createUserId;
}
public Integer getRtlLocId() {
return rtlLocId;
}
public void setRtlLocId(Integer rtlLocId) {
this.rtlLocId = rtlLocId;
}
public Integer getWkstnId() {
return wkstnId;
}
public void setWkstnId(Integer wkstnId) {
this.wkstnId = wkstnId;
}
public String getLogLevel() {
return logLevel;
}
public void setLogLevel(String logLevel) {
this.logLevel = logLevel;
}
public String getThreadName() {
return threadName;
}
public void setThreadName(String threadName) {
this.threadName = threadName;
}
public String getLogMessage() {
return logMessage;
}
public void setLogMessage(String logMessage) {
this.logMessage = logMessage;
}
public String getLoggerCategory() {
return loggerCategory;
}
public void setLoggerCategory(String loggerCategory) {
this.loggerCategory = loggerCategory;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
}

View File

@ -0,0 +1,23 @@
# 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
# 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
# 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
# XSTORE environment settings
xstore.db.url=jdbc:oracle:thin:@HOST:1521/XSTORE
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

View File

@ -0,0 +1,2 @@
# Indicates the current environment (dev, preprod, prod, etc.).
environment=prod

View File

@ -0,0 +1,12 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -15,6 +15,10 @@
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.example.services</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
<param-value>org.glassfish.jersey.jackson.JacksonFeature</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>