summaryrefslogtreecommitdiffstats
path: root/Master/Daten- und Systemintegration/Praktikum/DSI-Praktikum-1_ausgang/WS-Client/src/wsclient/Bestellung.java
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Master/Daten- und Systemintegration/Praktikum/DSI-Praktikum-1_ausgang/WS-Client/src/wsclient/Bestellung.java
downloadStudium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.gz
Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Master/Daten- und Systemintegration/Praktikum/DSI-Praktikum-1_ausgang/WS-Client/src/wsclient/Bestellung.java')
-rw-r--r--Master/Daten- und Systemintegration/Praktikum/DSI-Praktikum-1_ausgang/WS-Client/src/wsclient/Bestellung.java174
1 files changed, 174 insertions, 0 deletions
diff --git a/Master/Daten- und Systemintegration/Praktikum/DSI-Praktikum-1_ausgang/WS-Client/src/wsclient/Bestellung.java b/Master/Daten- und Systemintegration/Praktikum/DSI-Praktikum-1_ausgang/WS-Client/src/wsclient/Bestellung.java
new file mode 100644
index 0000000..d2902d7
--- /dev/null
+++ b/Master/Daten- und Systemintegration/Praktikum/DSI-Praktikum-1_ausgang/WS-Client/src/wsclient/Bestellung.java
@@ -0,0 +1,174 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package wsclient;
+
+/*
+ * TODO: nach der Generierung der Webservice-Clients bitte Kommentar entfernen
+ *
+import beans.artikelmanager.*;
+*/
+
+
+/**
+ *
+ * @author Jan
+ */
+public class Bestellung {
+
+
+ /**
+ * fuehrt eine Bestellung durch
+ *
+ * @param kundenId Die ID des Kunden
+ * @param artikelId Die ID des Artikels
+ * @param artikelAnzahl Die Anzahl der Artikel
+ * @return String Report ueber die Bestellung
+ * @throws java.lang.Exception
+ */
+ public String fuehreBestellungDurch(long kundenId, long artikelId, long artikelAnzahl) throws Exception {
+ if(validiereBestellung(artikelId, artikelAnzahl, kundenId) != true) {
+ throw new Exception("Bestellung nicht valide");
+ }
+ beans.artikelmanager.Artikel artikel = holeArtikelDaten(artikelId);
+
+ if(pruefeVerfuegbarkeit(artikelId, artikelAnzahl)!=true) {
+ long mindestMenge = holeMindestmengeFuerArtikel(artikelId);
+ long imLager = artikel.getAnzahl();
+ long anzahlNachbestellen = artikelAnzahl - imLager + mindestMenge;
+ bestelleNach(artikelId, anzahlNachbestellen);
+ System.out.println(String.format("Reordeing %d pieces of %d", anzahlNachbestellen,artikelId));
+ }
+ bucheAus(artikelId, artikelAnzahl);
+ double preisNetto = berechneGesamtpreis(artikelAnzahl, artikel.getPreis());
+ double mwst = berechneMehrwertSteuer(preisNetto);
+ String output = erstelleReport(kundenId, artikelAnzahl, artikel, preisNetto, mwst);
+ return output;
+ //throw new Exception("noch nicht implementiert!");
+ }
+
+
+
+
+/**
+ * Die folgenden Methoden koennen zum wrappen der Webservice-Aufrufe verwendet werden
+ * mittels erstelleReport kann ein Report generiert werden,
+ * den fuehreBestellungenDurch zurueckgeben kann
+ */
+
+ private boolean validiereBestellung(long artikelId, long anzahl, long kundenId) throws Exception {
+ try { // Call Web Service Operation
+ beans.bestell.BestellBeanService service = new beans.bestell.BestellBeanService();
+ beans.bestell.BestellBean port = service.getBestellBeanPort();
+ boolean result = port.validiereBestellung(artikelId, anzahl, kundenId);
+ System.out.println("Result = "+result);
+ return result;
+ } catch (Exception ex) {
+ throw new Exception("Error validating order with BestellBeanService",ex);
+ }
+ }
+
+ private beans.artikelmanager.Artikel holeArtikelDaten(long artikelId) throws beans.artikelmanager.UnbekanntesEntityException_Exception, Exception {
+ try { // Call Web Service Operation
+ beans.artikelmanager.ArtikelManagerBeanService service = new beans.artikelmanager.ArtikelManagerBeanService();
+ beans.artikelmanager.ArtikelManagerBean port = service.getArtikelManagerBeanPort();
+ beans.artikelmanager.Artikel result = port.readArtikel(artikelId);
+ System.out.println("Result = "+result);
+ return result;
+ } catch (Exception ex) {
+ throw new Exception("Error fetching Artikel from ArtikelManagerBeanService", ex);
+ }
+ }
+
+ private boolean pruefeVerfuegbarkeit(long artikelId, long anzahl) throws Exception {
+ try { // Call Web Service Operation
+ beans.lager.LagerBeanService service = new beans.lager.LagerBeanService();
+ beans.lager.LagerBean port = service.getLagerBeanPort();
+ boolean result = port.pruefeVerfuegbarkeit(artikelId, anzahl);
+ System.out.println("Result = "+result);
+ return result;
+ } catch (Exception ex) {
+ throw new Exception("Error fetching availability from LagerBeanService", ex);
+ }
+
+ }
+
+ private void bestelleNach(long artikelId, long anzahl) throws beans.lieferant.IllegalerWertException_Exception, beans.lieferant.UnbekanntesEntityException_Exception, Exception {
+ try { // Call Web Service Operation
+ beans.lieferant.LieferantBeanService service = new beans.lieferant.LieferantBeanService();
+ beans.lieferant.LieferantBean port = service.getLieferantBeanPort();
+ port.bestelleNach(artikelId, anzahl);
+ } catch (Exception ex) {
+ throw new Exception("Error calling bestelleNach Service Method of LieferantBeanService",ex);
+ }
+
+ }
+
+ private void bucheAus(long artikelId, long anzahl) throws beans.lager.IllegalerWertException_Exception, beans.lager.UnbekanntesEntityException_Exception, Exception {
+ try { // Call Web Service Operation
+ beans.lager.LagerBeanService service = new beans.lager.LagerBeanService();
+ beans.lager.LagerBean port = service.getLagerBeanPort();
+ port.bucheArtikelAus(artikelId, anzahl);
+ } catch (Exception ex) {
+ throw new Exception("Error calling bucheAus Service Method of LagerBeanService", ex);
+ }
+
+ }
+
+ private double berechneGesamtpreis(long anzahl, double preis) throws Exception {
+ try { // Call Web Service Operation
+ beans.bestell.BestellBeanService service = new beans.bestell.BestellBeanService();
+ beans.bestell.BestellBean port = service.getBestellBeanPort();
+ double result = port.berechneGesamtpreis(anzahl, preis);
+ System.out.println("Result = "+result);
+ return result;
+ } catch (Exception ex) {
+ throw new Exception("Error calling berechneGesamtpreis Service Method of BestellBeanService", ex);
+ }
+
+ }
+
+ private double berechneMehrwertSteuer(double preis) throws Exception {
+ try { // Call Web Service Operation
+ beans.bestell.BestellBeanService service = new beans.bestell.BestellBeanService();
+ beans.bestell.BestellBean port = service.getBestellBeanPort();
+ double result = port.berechneMehrwertSteuer(preis);
+ System.out.println("Result = "+result);
+ return result;
+ } catch (Exception ex) {
+ throw new Exception("Error calling berechneMehrwertSteuer Service Method of BestellBeanService", ex);
+ }
+
+ }
+
+ private long holeMindestmengeFuerArtikel(long artikelId) throws Exception {
+ try { // Call Web Service Operation
+ ws.MindestMengeService service = new ws.MindestMengeService();
+ ws.MindestMenge port = service.getMindestMengePort();
+ long result = port.holeMindestmengeFuerArtikel(artikelId);
+ System.out.println("Result = "+result);
+ return result;
+ } catch (Exception ex) {
+ throw new Exception("Error calling holeMindestmengeFuerArtikel Service Method of MindestMengeService", ex);
+ }
+
+ }
+
+ private String erstelleReport(long kundenId, long artikelAnzahl, beans.artikelmanager.Artikel artikel, double preisOhneMwSt , double MwSt){
+ String output = "";
+
+ output += "<html>";
+ output += "<h2>Bestellung</h2>";
+
+ output += "Kunden-Nr: " + kundenId + "<p>";
+ output += "Artikel" + "<p>";
+ output += " Artikel-Nr: " + artikel.getId() + " Bezeichnung: " + artikel.getBezeichnung() + "<p>";
+ output += "Bestellmenge: " + artikelAnzahl + "<p>";
+ output += "Preis: " + String.format("%.2f", preisOhneMwSt) + "€ + " + String.format("%.2f", MwSt) + "€ MwSt = " + String.format("%.2f" ,(preisOhneMwSt + MwSt)) + "€" + "<p>";
+ output += "</html>";
+
+ return output;
+ }
+
+} \ No newline at end of file