62 lines
4.5 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="de"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>getContact.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">backend</a> &gt; <a href="index.source.html" class="el_package">com.workbenchclassic</a> &gt; <span class="el_source">getContact.java</span></div><h1>getContact.java</h1><pre class="source lang-java linenums">package com.workbenchclassic;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.json.JSONException;
import org.json.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.JsonProcessingException;
@Path(&quot;/getContact&quot;)
<span class="nc" id="L21">public class getContact {</span>
<span class="nc" id="L22"> private static final DBService DB_SERVICE = new DBService(&quot;dsMesMiiNJTA&quot;);</span>
<span class="nc" id="L23"> private static final ObjectMapper MAPPER = new ObjectMapper();</span>
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response getUserResponse(String jsonBody) {
String station;
try {
<span class="nc" id="L31"> JSONObject json = new JSONObject(jsonBody);</span>
<span class="nc" id="L32"> station = json.getString(&quot;station&quot;);</span>
<span class="nc" id="L33"> } catch (JSONException e) {</span>
<span class="nc" id="L34"> return Response.status(Response.Status.BAD_REQUEST)</span>
<span class="nc" id="L35"> .entity(&quot;{\&quot;error\&quot;:\&quot;Missing or invalid 'station' parameter\&quot;}&quot;)</span>
<span class="nc" id="L36"> .build();</span>
<span class="nc" id="L37"> }</span>
<span class="nc" id="L39"> String query = &quot;select gad.artikel, gad.artbez, chst.cust_herst_nr as contact_code , chst.name as contact_name, gah.artikel as part_ext, gah.artbez as art_bez_ext, chst.ishersteller as IS_MANUFACTURER, chst.iskunde as IS_CUSTOMER, chst.islieferant as IS_SUPPLIER &quot;</span>
+
&quot;from glo.adis gad join glo.adis_herst gah on gah.object_id = gad.object_id join ml.cust_herst chst on chst.cust_herst_id = gah.herst_id &quot;
+
&quot;where werk_id in (SELECT werk_id FROM bde.kast WHERE kap_nr = '&quot; + station + &quot;')&quot;;
List&lt;Map&lt;String, Object&gt;&gt; rows;
try {
<span class="nc" id="L47"> rows = DB_SERVICE.dbConnectAndGetRows(query);</span>
<span class="nc" id="L48"> return Response.ok(MAPPER.writeValueAsString(rows)).build();</span>
<span class="nc" id="L49"> } catch (SQLException e) {</span>
<span class="nc" id="L50"> String errJson = String.format(&quot;{\&quot;error\&quot;:\&quot;DB error: %s\&quot;}&quot;, e.getMessage());</span>
<span class="nc" id="L51"> return Response.status(Response.Status.INTERNAL_SERVER_ERROR)</span>
<span class="nc" id="L52"> .entity(errJson)</span>
<span class="nc" id="L53"> .build();</span>
<span class="nc" id="L54"> } catch (JsonProcessingException e) {</span>
<span class="nc" id="L55"> String errJson = String.format(&quot;{\&quot;error\&quot;:\&quot;JSON processing error: %s\&quot;}&quot;, e.getMessage());</span>
<span class="nc" id="L56"> return Response.status(Response.Status.INTERNAL_SERVER_ERROR)</span>
<span class="nc" id="L57"> .entity(errJson)</span>
<span class="nc" id="L58"> .build();</span>
}
}
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.4.201905082037</span></div></body></html>