Skip to content

Commit

Permalink
Merge pull request #259 from arxit-ygr/v2.0-ARXIT
Browse files Browse the repository at this point in the history
V2.0 arxit
  • Loading branch information
yblatti authored Nov 2, 2022
2 parents 6ce4035 + c55db96 commit 291b996
Show file tree
Hide file tree
Showing 3,218 changed files with 14,178 additions and 546,755 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 2 additions & 0 deletions extract-connector-easysdiv4/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target/
/nbproject/
2 changes: 2 additions & 0 deletions extract-connector-easysdiv4/nb-configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ Any value defined here will override the pom.xml file value but is only applicab
-->
<org-netbeans-modules-javascript2-requirejs.enabled>true</org-netbeans-modules-javascript2-requirejs.enabled>
<netbeans.hint.license>gpl30</netbeans.hint.license>
<netbeans.compile.on.save>none</netbeans.compile.on.save>
<netbeans.hint.jdkPlatform>Zulu_17.0.1</netbeans.hint.jdkPlatform>
</properties>
</project-shared-configuration>
85 changes: 68 additions & 17 deletions extract-connector-easysdiv4/pom.xml
Original file line number Diff line number Diff line change
@@ -1,41 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.easysdi</groupId>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-connector-easysdiv4</artifactId>
<version>1.3-RELEASE</version>
<version>2.0-RELEASE</version>
<packaging>jar</packaging>
<pluginRepositories>
<pluginRepository>
<id>maven-snapshots</id>
<url>https://repository.apache.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.5</version>
<version>4.5.13</version>
<exclusions>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>extract-plugin-interface</artifactId>
<version>1.3-RELEASE</version>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-plugin-commoninterface</artifactId>
<version>2.0-RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.5</version>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
Expand All @@ -45,32 +56,69 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.0</version>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.4.0-b180830.0359</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.11</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<java.version>17</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<version>3.3.0</version>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>module-info.class</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -87,15 +135,18 @@
</execution>
</executions>
</plugin>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<!--
<outputDirectory>../extract/src/main/resources/connectors</outputDirectory>
-->
<outputDirectory>../../core/src/main/resources/connectors</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
<name>extract-connector-easysdiv4</name>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.easysdi.extract.connectors.easysdiv4;
package ch.asit_asso.extract.connectors.easysdiv4;

import java.io.IOException;
import java.io.InputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.easysdi.extract.connectors.easysdiv4;
package ch.asit_asso.extract.connectors.easysdiv4;

import java.util.ArrayList;
import java.util.List;
import org.easysdi.extract.connectors.common.IConnectorImportResult;
import org.easysdi.extract.connectors.common.IProduct;
import ch.asit_asso.extract.connectors.common.IConnectorImportResult;
import ch.asit_asso.extract.connectors.common.IProduct;



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,17 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.easysdi.extract.connectors.easysdiv4;
package ch.asit_asso.extract.connectors.easysdiv4;

import ch.asit_asso.extract.connectors.common.IConnector;
import ch.asit_asso.extract.connectors.common.IConnectorImportResult;
import ch.asit_asso.extract.connectors.common.IExportRequest;
import ch.asit_asso.extract.connectors.easysdiv4.utils.RequestUtils;
import ch.asit_asso.extract.connectors.easysdiv4.utils.ZipUtils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -75,21 +53,32 @@
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.easysdi.extract.connectors.common.IConnector;
import org.easysdi.extract.connectors.common.IConnectorImportResult;
import org.easysdi.extract.connectors.common.IExportRequest;
import org.easysdi.extract.connectors.easysdiv4.utils.RequestUtils;
import org.easysdi.extract.connectors.easysdiv4.utils.ZipUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.xpath.*;
import java.io.*;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;



/**
Expand Down Expand Up @@ -399,11 +388,13 @@ private String buildAddressDetailsFromXpath(final Document document, final Strin
final NodeList nodeList = (NodeList) expr.evaluate(document, XPathConstants.NODESET);

if (nodeList != null && nodeList.getLength() > 0) {
final Element tierceAddressNode = (Element) nodeList.item(0);
final NodeList address1Node = tierceAddressNode.getElementsByTagName("sdi:addressstreet1");
final NodeList address2Node = tierceAddressNode.getElementsByTagName("sdi:addressstreet2");
final NodeList zipCodeNode = tierceAddressNode.getElementsByTagName("sdi:zip");
final NodeList localityNode = tierceAddressNode.getElementsByTagName("sdi:locality");
final Element addressNode = (Element) nodeList.item(0);
final NodeList address1Node = addressNode.getElementsByTagName("sdi:addressstreet1");
final NodeList address2Node = addressNode.getElementsByTagName("sdi:addressstreet2");
final NodeList zipCodeNode = addressNode.getElementsByTagName("sdi:zip");
final NodeList localityNode = addressNode.getElementsByTagName("sdi:locality");
final NodeList emailNode = addressNode.getElementsByTagName("sdi:email");
final NodeList phoneNode = addressNode.getElementsByTagName("sdi:phone");

if (address1Node != null && address1Node.getLength() > 0) {
final String address1Text = address1Node.item(0).getTextContent();
Expand Down Expand Up @@ -445,12 +436,30 @@ private String buildAddressDetailsFromXpath(final Document document, final Strin
details.add(String.format("%s %s", zipCodeText, localityText));
}

if (phoneNode != null && phoneNode.getLength() > 0) {
final String phoneText = phoneNode.item(0).getTextContent();
this.logger.debug("Phone node content is {}", phoneText);

if (StringUtils.isNotEmpty(phoneText)) {
details.add(phoneText);
}
}

if (emailNode != null && emailNode.getLength() > 0) {
final String emailText = emailNode.item(0).getTextContent();
this.logger.debug("E-mail node content is {}", emailText);

if (StringUtils.isNotEmpty(emailText)) {
details.add(emailText);
}
}
}

} catch (XPathExpressionException exc) {
this.logger.error("The tiers details could not be retrieved", exc);
this.logger.error("The address details could not be retrieved", exc);
}

this.logger.debug("Address details are:\n{}", StringUtils.join(details, "\r\n"));
return StringUtils.join(details, "\r\n");
}

Expand Down Expand Up @@ -627,13 +636,13 @@ private ExportResult callSetProductService(final Document xmlDocument, final Str
return this.sendExportRequest(targetServer, targetUri, login, password, xmlString,
resultFile);

} catch (Exception exc) {
} catch (Exception exception) {
ExportResult exportResult = new ExportResult();
exportResult.setSuccess(false);
exportResult.setResultCode("-1");
exportResult.setResultMessage(this.messages.getString("exportresult.executing.failed"));
exportResult.setErrorDetails(exc.getMessage());
this.logger.debug("The export orders has failed");
exportResult.setErrorDetails(exception.getMessage());
this.logger.warn("The order export has failed.", exception);

return exportResult;
}
Expand Down Expand Up @@ -1167,8 +1176,11 @@ private ConnectorImportResult addImportedProductsToResult(final String responseS
config.getProperty("getOrders.xpath.clientGuid").replace("<guid>", guid));
final String clientDetails = this.buildAddressDetailsFromXpath(document,
config.getProperty("getOrders.xpath.clientDetails").replace("<guid>", guid));
this.logger.debug("Client details are : {}", clientDetails);
final String tiers = this.getXMLNodeLabelFromXpath(document,
config.getProperty("getOrders.xpath.tiers").replace("<guid>", guid));
final String tiersGuid = this.getXMLNodeLabelFromXpath(document,
config.getProperty("getOrders.xpath.tiersGuid").replace("<guid>", guid));
final String tiersDetails = this.buildAddressDetailsFromXpath(document,
config.getProperty("getOrders.xpath.tiersdetails").replace("<guid>", guid));
final String perimeter = this.getOrderPerimeterFromDocument(document, guid);
Expand Down Expand Up @@ -1204,6 +1216,7 @@ private ConnectorImportResult addImportedProductsToResult(final String responseS
product.setClientGuid(clientGuid);
product.setClientDetails(clientDetails);
product.setTiers(tiers);
product.setTiersGuid(tiersGuid);
product.setTiersDetails(tiersDetails);
product.setPerimeter(perimeter);
product.setSurface(surface);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.easysdi.extract.connectors.easysdiv4;
package ch.asit_asso.extract.connectors.easysdiv4;

import java.util.Calendar;
import org.easysdi.extract.connectors.common.IExportRequest;
import ch.asit_asso.extract.connectors.common.IExportRequest;



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.easysdi.extract.connectors.easysdiv4;
package ch.asit_asso.extract.connectors.easysdiv4;

import org.easysdi.extract.connectors.common.IExportResult;
import ch.asit_asso.extract.connectors.common.IExportResult;



Expand Down
Loading

0 comments on commit 291b996

Please sign in to comment.