diff options
Diffstat (limited to 'Master/Daten- und Systemintegration/Praktikum/DSI-Praktikum-1_ausgang/WS-Client/src/wsclient')
4 files changed, 497 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 diff --git a/Master/Daten- und Systemintegration/Praktikum/DSI-Praktikum-1_ausgang/WS-Client/src/wsclient/Main.java b/Master/Daten- und Systemintegration/Praktikum/DSI-Praktikum-1_ausgang/WS-Client/src/wsclient/Main.java new file mode 100644 index 0000000..d95fedf --- /dev/null +++ b/Master/Daten- und Systemintegration/Praktikum/DSI-Praktikum-1_ausgang/WS-Client/src/wsclient/Main.java @@ -0,0 +1,25 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package wsclient; + +import javax.swing.JFrame; + +/** + * + * @author Jan + */ +public class Main { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + // TODO code application logic here + JFrame main = new MainWindow(); + main.setVisible(true); + } + +} diff --git a/Master/Daten- und Systemintegration/Praktikum/DSI-Praktikum-1_ausgang/WS-Client/src/wsclient/MainWindow.form b/Master/Daten- und Systemintegration/Praktikum/DSI-Praktikum-1_ausgang/WS-Client/src/wsclient/MainWindow.form new file mode 100644 index 0000000..10aa90e --- /dev/null +++ b/Master/Daten- und Systemintegration/Praktikum/DSI-Praktikum-1_ausgang/WS-Client/src/wsclient/MainWindow.form @@ -0,0 +1,139 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="-2" pref="22" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="32767" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="jSpinnerKundeId" alignment="0" max="32767" attributes="1"/> + <Component id="jSpinnerArtikelId" alignment="0" max="32767" attributes="1"/> + <Component id="jSpinnerArtikelAnzahl" alignment="0" min="-2" pref="95" max="-2" attributes="1"/> + </Group> + <EmptySpace min="-2" pref="18" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jButtonBestellungAbschicken" pref="179" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace min="-2" pref="158" max="-2" attributes="0"/> + <Component id="jLabelOutput" min="-2" pref="293" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="-2" pref="24" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jSpinnerKundeId" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jSpinnerArtikelId" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jSpinnerArtikelAnzahl" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Component id="jButtonBestellungAbschicken" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabelOutput" min="-2" pref="192" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace pref="102" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="text" type="java.lang.String" value="Kunden-Id"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="text" type="java.lang.String" value="Artikel-Id"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="text" type="java.lang.String" value="Anzahl"/> + </Properties> + </Component> + <Component class="javax.swing.JSpinner" name="jSpinnerKundeId"> + <Properties> + <Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor"> + <SpinnerModel initial="0" numberType="java.lang.Long" stepSize="1" type="number"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JSpinner" name="jSpinnerArtikelId"> + <Properties> + <Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor"> + <SpinnerModel initial="0" numberType="java.lang.Long" stepSize="1" type="number"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JSpinner" name="jSpinnerArtikelAnzahl"> + <Properties> + <Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor"> + <SpinnerModel initial="0" numberType="java.lang.Long" stepSize="1" type="number"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jButtonBestellungAbschicken"> + <Properties> + <Property name="text" type="java.lang.String" value="Bestellung abschicken"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonBestellungAbschickenActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabelOutput"> + <Properties> + <Property name="text" type="java.lang.String" value="..."/> + <Property name="verticalAlignment" type="int" value="1"/> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/Master/Daten- und Systemintegration/Praktikum/DSI-Praktikum-1_ausgang/WS-Client/src/wsclient/MainWindow.java b/Master/Daten- und Systemintegration/Praktikum/DSI-Praktikum-1_ausgang/WS-Client/src/wsclient/MainWindow.java new file mode 100644 index 0000000..c05c0ce --- /dev/null +++ b/Master/Daten- und Systemintegration/Praktikum/DSI-Praktikum-1_ausgang/WS-Client/src/wsclient/MainWindow.java @@ -0,0 +1,159 @@ +/* + * MainWindow.java + * + * Created on 8. Juli 2008, 17:02 + */ + +package wsclient; + +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JDialog; +import javax.swing.JOptionPane; + +/** + * + * @author Jan + */ +public class MainWindow extends javax.swing.JFrame { + + /** Creates new form MainWindow */ + public MainWindow() { + initComponents(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jSpinnerKundeId = new javax.swing.JSpinner(); + jSpinnerArtikelId = new javax.swing.JSpinner(); + jSpinnerArtikelAnzahl = new javax.swing.JSpinner(); + jButtonBestellungAbschicken = new javax.swing.JButton(); + jLabelOutput = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jLabel1.setText("Kunden-Id"); + + jLabel2.setText("Artikel-Id"); + + jLabel3.setText("Anzahl"); + + jSpinnerKundeId.setModel(new javax.swing.SpinnerNumberModel(Long.valueOf(0L), null, null, Long.valueOf(1L))); + + jSpinnerArtikelId.setModel(new javax.swing.SpinnerNumberModel(Long.valueOf(0L), null, null, Long.valueOf(1L))); + + jSpinnerArtikelAnzahl.setModel(new javax.swing.SpinnerNumberModel(Long.valueOf(0L), null, null, Long.valueOf(1L))); + + jButtonBestellungAbschicken.setText("Bestellung abschicken"); + jButtonBestellungAbschicken.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButtonBestellungAbschickenActionPerformed(evt); + } + }); + + jLabelOutput.setText("..."); + jLabelOutput.setVerticalAlignment(javax.swing.SwingConstants.TOP); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(22, 22, 22) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3) + .addComponent(jLabel2) + .addComponent(jLabel1)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jSpinnerKundeId) + .addComponent(jSpinnerArtikelId) + .addComponent(jSpinnerArtikelAnzahl, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18)) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jButtonBestellungAbschicken, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))) + .addGap(158, 158, 158) + .addComponent(jLabelOutput, javax.swing.GroupLayout.PREFERRED_SIZE, 293, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(24, 24, 24) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(jSpinnerKundeId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(jSpinnerArtikelId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(jSpinnerArtikelAnzahl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButtonBestellungAbschicken)) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabelOutput, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(102, Short.MAX_VALUE)) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + +private void jButtonBestellungAbschickenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBestellungAbschickenActionPerformed + Bestellung b = new Bestellung(); + + try { + + + String output = b.fuehreBestellungDurch((Long) jSpinnerKundeId.getValue(), (Long) jSpinnerArtikelId.getValue(), (Long) jSpinnerArtikelAnzahl.getValue()); + + jLabelOutput.setText(output); + } catch (Exception ex) { + + JOptionPane.showMessageDialog(rootPane, ex.getMessage(), "Fehler beim Bestellvorgang", JOptionPane.ERROR_MESSAGE); + } +}//GEN-LAST:event_jButtonBestellungAbschickenActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new MainWindow().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButtonBestellungAbschicken; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabelOutput; + private javax.swing.JSpinner jSpinnerArtikelAnzahl; + private javax.swing.JSpinner jSpinnerArtikelId; + private javax.swing.JSpinner jSpinnerKundeId; + // End of variables declaration//GEN-END:variables + +} |
