From 205f059ec5df1a24daa87f8563d2bbb99344ecf9 Mon Sep 17 00:00:00 2001 From: tspitzer Date: Tue, 17 Sep 2013 15:38:08 +0200 Subject: g --- Dozentenmodul/src/GUI/AddOS.java | 145 ++++++++++ Dozentenmodul/src/GUI/AddSoftware.java | 145 ++++++++++ Dozentenmodul/src/GUI/EingabeAllgemein.java | 345 ++++++++++++++++++++++++ Dozentenmodul/src/GUI/EingabeSoftwareDaten.java | 298 ++++++++++++++++++++ Dozentenmodul/src/GUI/EingabeSystemDaten.java | 280 +++++++++++++++++++ Dozentenmodul/src/GUI/FTPDownloader.java | 161 +++++++++++ Dozentenmodul/src/GUI/FTPUploader.java | 180 +++++++++++++ Dozentenmodul/src/GUI/FertigStellen.java | 154 +++++++++++ Dozentenmodul/src/GUI/LoginWindow.java | 3 +- Dozentenmodul/src/GUI/getVMwarePlayer.java | 156 +++++++++++ Dozentenmodul/src/GUI/searchRohling.java | 201 ++++++++++++++ Dozentenmodul/src/Jsch/scriptExecutor.java | 63 +++++ Dozentenmodul/src/Models/person.java | 61 +++++ Dozentenmodul/src/Models/vm.java | 69 +++++ Dozentenmodul/src/auth/Ldap.java | 5 +- Dozentenmodul/src/downloader/DownloadTask.java | 105 ++++++++ Dozentenmodul/src/downloader/FTPException.java | 8 + Dozentenmodul/src/downloader/FTPUtility.java | 187 +++++++++++++ Dozentenmodul/src/downloader/UploadTask.java | 91 +++++++ Dozentenmodul/src/downloader/jschtest.java | 84 ++++++ Dozentenmodul/src/sql/sql.java | 179 ++++++++++++ 21 files changed, 2918 insertions(+), 2 deletions(-) create mode 100644 Dozentenmodul/src/GUI/AddOS.java create mode 100644 Dozentenmodul/src/GUI/AddSoftware.java create mode 100644 Dozentenmodul/src/GUI/EingabeAllgemein.java create mode 100644 Dozentenmodul/src/GUI/EingabeSoftwareDaten.java create mode 100644 Dozentenmodul/src/GUI/EingabeSystemDaten.java create mode 100644 Dozentenmodul/src/GUI/FTPDownloader.java create mode 100644 Dozentenmodul/src/GUI/FTPUploader.java create mode 100644 Dozentenmodul/src/GUI/FertigStellen.java create mode 100644 Dozentenmodul/src/GUI/getVMwarePlayer.java create mode 100644 Dozentenmodul/src/GUI/searchRohling.java create mode 100644 Dozentenmodul/src/Jsch/scriptExecutor.java create mode 100644 Dozentenmodul/src/Models/person.java create mode 100644 Dozentenmodul/src/Models/vm.java create mode 100644 Dozentenmodul/src/downloader/DownloadTask.java create mode 100644 Dozentenmodul/src/downloader/FTPException.java create mode 100644 Dozentenmodul/src/downloader/FTPUtility.java create mode 100644 Dozentenmodul/src/downloader/UploadTask.java create mode 100644 Dozentenmodul/src/downloader/jschtest.java create mode 100644 Dozentenmodul/src/sql/sql.java (limited to 'Dozentenmodul/src') diff --git a/Dozentenmodul/src/GUI/AddOS.java b/Dozentenmodul/src/GUI/AddOS.java new file mode 100644 index 00000000..5039a4e1 --- /dev/null +++ b/Dozentenmodul/src/GUI/AddOS.java @@ -0,0 +1,145 @@ +package GUI; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import sql.sql; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; +import javax.swing.JLabel; +import java.awt.Font; +import javax.swing.JTextField; +import javax.swing.JComboBox; +import javax.swing.JCheckBox; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.sql.Connection; +import javax.swing.DefaultComboBoxModel; + +@SuppressWarnings("serial") +public class AddOS extends JDialog { + + private final JPanel contentPanel = new JPanel(); + private JTextField textField; + private JTextField textField_1; + private JTextField textField_2; + @SuppressWarnings("rawtypes") + JComboBox comboBox; + JCheckBox checkBox; + sql sql=new sql(); + /** + * Launch the application. + */ + public static void main(String[] args) { + try { + AddOS dialog = new AddOS(); + dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + dialog.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Create the dialog. + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + public AddOS() { + setTitle("Dozentenmodul"); + setBounds(100, 100, 288, 300); + getContentPane().setLayout(new BorderLayout()); + contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); + getContentPane().add(contentPanel, BorderLayout.CENTER); + contentPanel.setLayout(null); + { + JLabel lblNewLabel = new JLabel("Betriebssystem hinzuf\u00FCgen"); + lblNewLabel.setFont(new Font("Dialog", Font.PLAIN, 14)); + lblNewLabel.setBounds(10, 11, 194, 25); + contentPanel.add(lblNewLabel); + } + { + JLabel lblHersteller = new JLabel("Hersteller:"); + lblHersteller.setBounds(10, 47, 100, 20); + contentPanel.add(lblHersteller); + } + { + textField = new JTextField(); + textField.setBounds(120, 47, 125, 20); + contentPanel.add(textField); + textField.setColumns(10); + } + { + JLabel lblNewLabel_1 = new JLabel("Name:"); + lblNewLabel_1.setBounds(10, 78, 100, 20); + contentPanel.add(lblNewLabel_1); + } + { + textField_1 = new JTextField(); + textField_1.setColumns(10); + textField_1.setBounds(120, 78, 125, 20); + contentPanel.add(textField_1); + } + { + JLabel lblVersion = new JLabel("Version:"); + lblVersion.setBounds(10, 109, 100, 20); + contentPanel.add(lblVersion); + } + { + textField_2 = new JTextField(); + textField_2.setColumns(10); + textField_2.setBounds(120, 109, 125, 20); + contentPanel.add(textField_2); + } + { + JLabel lblArchitektur = new JLabel("Architektur:"); + lblArchitektur.setBounds(10, 140, 100, 20); + contentPanel.add(lblArchitektur); + } + + comboBox = new JComboBox(); + comboBox.setModel(new DefaultComboBoxModel(new String[] {"32-bit", "64-bit"})); + comboBox.setBounds(120, 140, 125, 20); + contentPanel.add(comboBox); + + JLabel lblLizenzpflichtig = new JLabel("Lizenzpflichtig:"); + lblLizenzpflichtig.setBounds(10, 171, 100, 20); + contentPanel.add(lblLizenzpflichtig); + + checkBox = new JCheckBox(""); + checkBox.setBounds(120, 167, 97, 23); + contentPanel.add(checkBox); + { + JPanel buttonPane = new JPanel(); + buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); + getContentPane().add(buttonPane, BorderLayout.SOUTH); + { + JButton okButton = new JButton("OK"); + okButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + int Kosten=0; + if(checkBox.isSelected()==true) + { + Kosten=1; + } + Connection con=sql.getConnection(); + sql.AddOS(con, textField_1.getText().toString(), textField_2.getText().toString(), comboBox.getSelectedItem().toString(), Kosten, textField.getText().toString()); + } + }); + okButton.setActionCommand("OK"); + buttonPane.add(okButton); + getRootPane().setDefaultButton(okButton); + } + { + JButton cancelButton = new JButton("Zur\u00FCck"); + cancelButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + cancelButton.setActionCommand("Cancel"); + buttonPane.add(cancelButton); + } + } + } +} diff --git a/Dozentenmodul/src/GUI/AddSoftware.java b/Dozentenmodul/src/GUI/AddSoftware.java new file mode 100644 index 00000000..c3a41227 --- /dev/null +++ b/Dozentenmodul/src/GUI/AddSoftware.java @@ -0,0 +1,145 @@ +package GUI; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import sql.sql; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; +import javax.swing.JLabel; +import java.awt.Font; +import javax.swing.JTextField; +import javax.swing.JComboBox; +import javax.swing.JCheckBox; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.sql.Connection; +import javax.swing.DefaultComboBoxModel; + +@SuppressWarnings("serial") +public class AddSoftware extends JDialog { + + private final JPanel contentPanel = new JPanel(); + private JTextField textField; + private JTextField textField_1; + private JTextField textField_2; + @SuppressWarnings("rawtypes") + JComboBox comboBox; + JCheckBox checkBox; + sql sql=new sql(); + /** + * Launch the application. + */ + public static void main(String[] args) { + try { + AddSoftware dialog = new AddSoftware(); + dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + dialog.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Create the dialog. + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + public AddSoftware() { + setTitle("Dozentenmodul"); + setBounds(100, 100, 288, 300); + getContentPane().setLayout(new BorderLayout()); + contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); + getContentPane().add(contentPanel, BorderLayout.CENTER); + contentPanel.setLayout(null); + { + JLabel lblNewLabel = new JLabel("Software hinzuf\u00FCgen"); + lblNewLabel.setFont(new Font("Dialog", Font.PLAIN, 14)); + lblNewLabel.setBounds(10, 11, 194, 25); + contentPanel.add(lblNewLabel); + } + { + JLabel lblHersteller = new JLabel("Hersteller:"); + lblHersteller.setBounds(10, 47, 100, 20); + contentPanel.add(lblHersteller); + } + { + textField = new JTextField(); + textField.setBounds(120, 47, 125, 20); + contentPanel.add(textField); + textField.setColumns(10); + } + { + JLabel lblNewLabel_1 = new JLabel("Name:"); + lblNewLabel_1.setBounds(10, 78, 100, 20); + contentPanel.add(lblNewLabel_1); + } + { + textField_1 = new JTextField(); + textField_1.setColumns(10); + textField_1.setBounds(120, 78, 125, 20); + contentPanel.add(textField_1); + } + { + JLabel lblVersion = new JLabel("Version:"); + lblVersion.setBounds(10, 109, 100, 20); + contentPanel.add(lblVersion); + } + { + textField_2 = new JTextField(); + textField_2.setColumns(10); + textField_2.setBounds(120, 109, 125, 20); + contentPanel.add(textField_2); + } + { + JLabel lblArchitektur = new JLabel("Architektur:"); + lblArchitektur.setBounds(10, 140, 100, 20); + contentPanel.add(lblArchitektur); + } + + comboBox = new JComboBox(); + comboBox.setModel(new DefaultComboBoxModel(new String[] {"32-bit", "64-bit"})); + comboBox.setBounds(120, 140, 125, 20); + contentPanel.add(comboBox); + + JLabel lblLizenzpflichtig = new JLabel("Lizenzpflichtig:"); + lblLizenzpflichtig.setBounds(10, 171, 100, 20); + contentPanel.add(lblLizenzpflichtig); + + checkBox = new JCheckBox(""); + checkBox.setBounds(120, 167, 97, 23); + contentPanel.add(checkBox); + { + JPanel buttonPane = new JPanel(); + buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); + getContentPane().add(buttonPane, BorderLayout.SOUTH); + { + JButton okButton = new JButton("OK"); + okButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + int Kosten=0; + if(checkBox.isSelected()==true) + { + Kosten=1; + } + Connection con=sql.getConnection(); + sql.AddSoftware(con, textField_1.getText().toString(), textField_2.getText().toString(), comboBox.getSelectedItem().toString(), Kosten, textField.getText().toString()); + } + }); + okButton.setActionCommand("OK"); + buttonPane.add(okButton); + getRootPane().setDefaultButton(okButton); + } + { + JButton cancelButton = new JButton("Zur\u00FCck"); + cancelButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + cancelButton.setActionCommand("Cancel"); + buttonPane.add(cancelButton); + } + } + } +} diff --git a/Dozentenmodul/src/GUI/EingabeAllgemein.java b/Dozentenmodul/src/GUI/EingabeAllgemein.java new file mode 100644 index 00000000..b28147b7 --- /dev/null +++ b/Dozentenmodul/src/GUI/EingabeAllgemein.java @@ -0,0 +1,345 @@ +package GUI; + + +import java.awt.FlowLayout; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.border.EmptyBorder; +import java.awt.Color; +import javax.swing.JLabel; +import java.awt.Font; +import javax.swing.JTextPane; +import java.awt.SystemColor; +import javax.swing.JTextField; + +import ftp.ftp; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import javax.swing.JCheckBox; +import javax.swing.JSeparator; +import javax.swing.event.ChangeListener; +import javax.swing.event.ChangeEvent; +import javax.swing.JMenuBar; +import javax.swing.JMenu; +import javax.swing.JMenuItem; + +import Models.person; + +@SuppressWarnings("serial") +public class EingabeAllgemein extends JDialog { + + private final JPanel contentPanel = new JPanel(); + String[] result; + ftp f=new ftp(); + private JTextField Vorname_V; + private JTextField Nachname_V; + private JTextField Hochschule_V; + private JTextField EMail_V; + private JTextField Tel_V; + private JTextField Fak_V; + private JTextField Vorname_E; + private JTextField Nachname_E; + private JTextField Hochschule_E; + private JTextField EMail_E; + private JTextField Tel_E; + private JTextField Fak_E; + JCheckBox chckbxDerVerantwortlicheEntspricht; + /** + * Launch the application. + */ + public static void main(String[] args) { + try { + EingabeAllgemein dialog = new EingabeAllgemein(); + dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + dialog.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Create the dialog. + */ + public EingabeAllgemein() { + + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException | UnsupportedLookAndFeelException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + setTitle("Dozentenmodul"); + setBounds(100, 100, 545, 689); + getContentPane().setLayout(null); + { + JPanel panel = new JPanel(); + panel.setBounds(0, 0, 529, 68); + getContentPane().add(panel); + panel.setLayout(null); + { + JLabel lblNewLabel = new JLabel("Eingabe der allgemeinen Daten (Schritt 3 von 6)"); + lblNewLabel.setBounds(10, 11, 509, 22); + panel.add(lblNewLabel); + lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 18)); + } + + JTextPane txtpnBitteWhlenSie = new JTextPane(); + txtpnBitteWhlenSie.setEditable(false); + txtpnBitteWhlenSie.setBackground(SystemColor.menu); + txtpnBitteWhlenSie.setText("Geben Sie hier bitte die Kontaktdaten des Vernatwortlichen und des Erstellers der VMDK ein"); + txtpnBitteWhlenSie.setBounds(10, 36, 509, 42); + panel.add(txtpnBitteWhlenSie); + } + contentPanel.setBounds(10, 91, 509, 483); + contentPanel.setBackground(Color.WHITE); + contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); + getContentPane().add(contentPanel); + contentPanel.setLayout(null); + + JLabel lblNewLabel_1 = new JLabel("Allgemeine Informationen zum Verantwortlichen"); + lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 14)); + lblNewLabel_1.setBounds(10, 0, 338, 25); + contentPanel.add(lblNewLabel_1); + + JLabel lblNewLabel_2 = new JLabel("Vorname: *"); + lblNewLabel_2.setBounds(10, 36, 125, 20); + contentPanel.add(lblNewLabel_2); + + Vorname_V = new JTextField(); + Vorname_V.setBounds(145, 36, 125, 20); + Vorname_V.setText(person.verantowrtlicher.getVorname()); + contentPanel.add(Vorname_V); + Vorname_V.setColumns(10); + + JLabel lblNachname = new JLabel("Nachname: *"); + lblNachname.setBounds(10, 67, 125, 20); + contentPanel.add(lblNachname); + + Nachname_V = new JTextField(); + Nachname_V.setBounds(145, 67, 125, 20); + Nachname_V.setText(person.verantowrtlicher.getName()); + contentPanel.add(Nachname_V); + Nachname_V.setColumns(10); + + JLabel lblHochschule = new JLabel("Hochschule: *"); + lblHochschule.setBounds(10, 98, 125, 20); + contentPanel.add(lblHochschule); + + Hochschule_V = new JTextField(); + Hochschule_V.setColumns(10); + Hochschule_V.setBounds(145, 98, 125, 20); + Hochschule_V.setText(person.verantowrtlicher.getHochschule()); + contentPanel.add(Hochschule_V); + + JLabel lblEmail = new JLabel("E-Mail: *"); + lblEmail.setBounds(10, 129, 125, 20); + contentPanel.add(lblEmail); + + EMail_V = new JTextField(); + EMail_V.setColumns(10); + EMail_V.setBounds(145, 129, 125, 20); + EMail_V.setText(person.verantowrtlicher.getEMail()); + contentPanel.add(EMail_V); + + JLabel lblTelnummer = new JLabel("Tel.-Nummer:"); + lblTelnummer.setBounds(10, 160, 125, 20); + contentPanel.add(lblTelnummer); + + Tel_V = new JTextField(); + Tel_V.setColumns(10); + Tel_V.setBounds(145, 160, 125, 20); + Tel_V.setText(person.verantowrtlicher.getTel()); + contentPanel.add(Tel_V); + + JLabel lblFakultt = new JLabel("Fakult\u00E4t:"); + lblFakultt.setBounds(10, 191, 125, 20); + contentPanel.add(lblFakultt); + + Fak_V = new JTextField(); + Fak_V.setColumns(10); + Fak_V.setBounds(145, 191, 125, 20); + Fak_V.setText(person.verantowrtlicher.getFakultät()); + contentPanel.add(Fak_V); + + chckbxDerVerantwortlicheEntspricht = new JCheckBox("Der Verantwortliche entspricht dem Ersteller"); + chckbxDerVerantwortlicheEntspricht.setSelected(person.verantowrtlicher.isIschecked()); + chckbxDerVerantwortlicheEntspricht.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent arg0) { + if(chckbxDerVerantwortlicheEntspricht.isSelected()==true){ + Nachname_E.setText(Nachname_V.getText()); + Vorname_E.setText(Vorname_V.getText()); + Hochschule_E.setText(Hochschule_V.getText()); + EMail_E.setText(EMail_V.getText()); + Tel_E.setText(Tel_V.getText()); + Fak_E.setText(Fak_V.getText()); + }else{ + Nachname_E.setText(""); + Vorname_E.setText(""); + Hochschule_E.setText(""); + EMail_E.setText(""); + Tel_E.setText(""); + Fak_E.setText(""); + } + } + }); + chckbxDerVerantwortlicheEntspricht.setBackground(Color.WHITE); + chckbxDerVerantwortlicheEntspricht.setBounds(6, 228, 264, 23); + contentPanel.add(chckbxDerVerantwortlicheEntspricht); + + JLabel lblAllgemeineInformationenZum = new JLabel("Allgemeine Informationen zum Ersteller"); + lblAllgemeineInformationenZum.setFont(new Font("Tahoma", Font.PLAIN, 14)); + lblAllgemeineInformationenZum.setBounds(10, 258, 338, 25); + contentPanel.add(lblAllgemeineInformationenZum); + + JLabel label_1 = new JLabel("Vorname: *"); + label_1.setBounds(10, 294, 125, 20); + contentPanel.add(label_1); + + Vorname_E = new JTextField(); + Vorname_E.setColumns(10); + Vorname_E.setBounds(145, 294, 125, 20); + Vorname_E.setText(person.ersteller.getVorname()); + contentPanel.add(Vorname_E); + + JLabel label_2 = new JLabel("Nachname: *"); + label_2.setBounds(10, 325, 125, 20); + contentPanel.add(label_2); + + Nachname_E = new JTextField(); + Nachname_E.setColumns(10); + Nachname_E.setBounds(145, 325, 125, 20); + Nachname_E.setText(person.ersteller.getName()); + contentPanel.add(Nachname_E); + + Hochschule_E = new JTextField(); + Hochschule_E.setColumns(10); + Hochschule_E.setBounds(145, 356, 125, 20); + Hochschule_E.setText(person.ersteller.getHochschule()); + contentPanel.add(Hochschule_E); + + JLabel label_3 = new JLabel("Hochschule: *"); + label_3.setBounds(10, 356, 125, 20); + contentPanel.add(label_3); + + JLabel label_4 = new JLabel("E-Mail: *"); + label_4.setBounds(10, 387, 125, 20); + contentPanel.add(label_4); + + EMail_E = new JTextField(); + EMail_E.setColumns(10); + EMail_E.setBounds(145, 387, 125, 20); + EMail_E.setText(person.ersteller.getEMail()); + contentPanel.add(EMail_E); + + Tel_E = new JTextField(); + Tel_E.setColumns(10); + Tel_E.setBounds(145, 418, 125, 20); + Tel_E.setText(person.ersteller.getTel()); + contentPanel.add(Tel_E); + + JLabel label_5 = new JLabel("Tel.-Nummer:"); + label_5.setBounds(10, 418, 125, 20); + contentPanel.add(label_5); + + JLabel label_6 = new JLabel("Fakult\u00E4t:"); + label_6.setBounds(10, 449, 125, 20); + contentPanel.add(label_6); + + Fak_E = new JTextField(); + Fak_E.setColumns(10); + Fak_E.setText(person.ersteller.getFakultät()); + Fak_E.setBounds(145, 449, 125, 20); + contentPanel.add(Fak_E); + { + JPanel buttonPane = new JPanel(); + buttonPane.setBounds(0, 597, 529, 33); + buttonPane.setBackground(SystemColor.menu); + buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); + getContentPane().add(buttonPane); + { + JButton okButton = new JButton("Zur\u00FCck"); + okButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + person.verantowrtlicher.setVorname(Vorname_V.getText()); + person.verantowrtlicher.setName(Nachname_V.getText()); + person.verantowrtlicher.setEMail(EMail_V.getText()); + person.verantowrtlicher.setFakultät(Fak_V.getText()); + person.verantowrtlicher.setHochschule(Hochschule_V.getText()); + person.verantowrtlicher.setTel(Tel_V.getText()); + person.verantowrtlicher.setIschecked(chckbxDerVerantwortlicheEntspricht.isSelected()); + person.ersteller.setEMail(EMail_E.getText()); + person.ersteller.setFakultät(Fak_E.getText()); + person.ersteller.setHochschule(Hochschule_E.getText()); + person.ersteller.setName(Nachname_E.getText()); + person.ersteller.setVorname(Vorname_V.getText()); + person.ersteller.setTel(Tel_E.getText()); + getVMwarePlayer sr=new getVMwarePlayer(); + sr.setVisible(true); + dispose(); + } + }); + okButton.setActionCommand("OK"); + buttonPane.add(okButton); + getRootPane().setDefaultButton(okButton); + } + { + JButton cancelButton = new JButton("Weiter"); + cancelButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + person.verantowrtlicher.setVorname(Vorname_V.getText()); + person.verantowrtlicher.setName(Nachname_V.getText()); + person.verantowrtlicher.setEMail(EMail_V.getText()); + person.verantowrtlicher.setFakultät(Fak_V.getText()); + person.verantowrtlicher.setHochschule(Hochschule_V.getText()); + person.verantowrtlicher.setTel(Tel_V.getText()); + person.verantowrtlicher.setIschecked(chckbxDerVerantwortlicheEntspricht.isSelected()); + person.ersteller.setEMail(EMail_E.getText()); + person.ersteller.setFakultät(Fak_E.getText()); + person.ersteller.setHochschule(Hochschule_E.getText()); + person.ersteller.setName(Nachname_E.getText()); + person.ersteller.setVorname(Vorname_V.getText()); + person.ersteller.setTel(Tel_E.getText()); + EingabeSystemDaten ea=new EingabeSystemDaten(); + ea.setVisible(true); + dispose(); + } + }); + cancelButton.setActionCommand("Cancel"); + buttonPane.add(cancelButton); + } + } + + JSeparator separator = new JSeparator(); + separator.setBounds(0, 79, 529, 2); + getContentPane().add(separator); + + JSeparator separator_1 = new JSeparator(); + separator_1.setBounds(0, 585, 529, 2); + getContentPane().add(separator_1); + + JMenuBar menuBar = new JMenuBar(); + setJMenuBar(menuBar); + + JMenu mnNewMenu = new JMenu("Suchen"); + menuBar.add(mnNewMenu); + + JMenuItem mntmVlSuche = new JMenuItem("VL Suche"); + mnNewMenu.add(mntmVlSuche); + + JMenu mnNewMenu_1 = new JMenu("Hilfe"); + menuBar.add(mnNewMenu_1); + + JMenuItem mntmFaq = new JMenuItem("FAQ"); + mnNewMenu_1.add(mntmFaq); + + JMenuItem mntmOtrs = new JMenuItem("OTRS"); + mnNewMenu_1.add(mntmOtrs); + + + + } +} diff --git a/Dozentenmodul/src/GUI/EingabeSoftwareDaten.java b/Dozentenmodul/src/GUI/EingabeSoftwareDaten.java new file mode 100644 index 00000000..f99fd88e --- /dev/null +++ b/Dozentenmodul/src/GUI/EingabeSoftwareDaten.java @@ -0,0 +1,298 @@ +package GUI; + +import java.awt.FlowLayout; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.border.EmptyBorder; +import java.awt.Color; +import javax.swing.JLabel; +import java.awt.Font; +import javax.swing.JTextPane; +import java.awt.SystemColor; +import javax.swing.JTextField; +import sql.sql; +import ftp.ftp; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Arrays; +import javax.swing.JSeparator; +import java.awt.List; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import javax.swing.plaf.basic.BasicArrowButton; +import javax.swing.JMenuBar; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import Models.vm; + + +@SuppressWarnings("serial") +public class EingabeSoftwareDaten extends JDialog { + + private final JPanel contentPanel = new JPanel(); + String[] result; + ftp f=new ftp(); + sql sql=new sql(); + private JTextField textField; + List listavailable; + List listchoosed; + + /** + * Launch the application. + */ + public static void main(String[] args) { + try { + EingabeSoftwareDaten dialog = new EingabeSoftwareDaten(); + dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + dialog.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Create the dialog. + */ + @SuppressWarnings({ }) + public EingabeSoftwareDaten() { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException | UnsupportedLookAndFeelException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + setTitle("Dozentenmodul"); + setBounds(100, 100, 603, 722); + getContentPane().setLayout(null); + { + JPanel panel = new JPanel(); + panel.setBounds(0, 0, 529, 71); + getContentPane().add(panel); + panel.setLayout(null); + { + JLabel lblNewLabel = new JLabel("Eingabe der installierten Software (Schritt 5 von 6)"); + lblNewLabel.setBounds(10, 11, 509, 22); + panel.add(lblNewLabel); + lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 18)); + } + + JTextPane txtpnBitteWhlenSie = new JTextPane(); + txtpnBitteWhlenSie.setEditable(false); + txtpnBitteWhlenSie.setBackground(SystemColor.menu); + txtpnBitteWhlenSie.setText("Bitte geben Sie nun die in Ihrem System installierte Software an."); + txtpnBitteWhlenSie.setBounds(10, 36, 509, 42); + panel.add(txtpnBitteWhlenSie); + } + contentPanel.setBounds(10, 95, 567, 512); + contentPanel.setBackground(Color.WHITE); + contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); + getContentPane().add(contentPanel); + contentPanel.setLayout(null); + + JLabel lblSysteminformationen = new JLabel("Verf\u00FCgbare Software"); + lblSysteminformationen.setFont(new Font("Tahoma", Font.PLAIN, 14)); + lblSysteminformationen.setBounds(10, 11, 162, 14); + contentPanel.add(lblSysteminformationen); + + + JLabel lblAusgewhlteSoftware = new JLabel("Ausgew\u00E4hlte Software"); + lblAusgewhlteSoftware.setFont(new Font("Tahoma", Font.PLAIN, 14)); + lblAusgewhlteSoftware.setBounds(306, 11, 162, 14); + contentPanel.add(lblAusgewhlteSoftware); + + + + textField = new JTextField(); + textField.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + + + Connection con=sql.getConnection(); + ResultSet rs=sql.getSoftwareByName(con, textField.getText().toString()); + listavailable.removeAll(); + try { + while(rs.next()) + { + listavailable.add(rs.getString("SW")); + } + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + }); + + textField.setBounds(10, 36, 244, 20); + contentPanel.add(textField); + textField.setColumns(10); + + JButton btnSoftwareHinzufgen = new JButton("Software hinzuf\u00FCgen"); + btnSoftwareHinzufgen.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + AddSoftware as=new AddSoftware(); + as.setVisible(true); + } + }); + btnSoftwareHinzufgen.setBounds(10, 483, 162, 23); + contentPanel.add(btnSoftwareHinzufgen); + + listavailable = new List(); + Connection con=sql.getConnection(); + ResultSet he=sql.getAllHersteller(con); + + try { + while(he.next()) + { + + ResultSet sw=sql.getAllSoftware(con, he.getString("Name")); + + while(sw.next()) + { + + listavailable.add(he.getString("Name")+" "+sw.getString("Produktname")+" "+sw.getString("Version")+" "+sw.getString("Architektur")); + } + } + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + listavailable.setMultipleMode(true); + listavailable.setBounds(10, 62, 244, 415); + contentPanel.add(listavailable); + + listchoosed = new List(); + if(vm.vl.getSoftware()!=null) + { + for(int i=0;i { + + private static final int BUFFER_SIZE = 4096; + + private String host; + private int port; + private String username; + private String password; + + private String downloadPath; + private String saveDir; + + @SuppressWarnings("unused") + private FTPDownloader gui; + + public DownloadTask(String host, int port, String username, + String password, String downloadPath, String saveDir, + FTPDownloader gui) { + this.host = host; + this.port = port; + this.username = username; + this.password = password; + this.downloadPath = downloadPath; + this.saveDir = saveDir; + this.gui = gui; + + } + + /** + * Executed in background thread + */ + @Override + protected Void doInBackground() throws Exception { + FTPUtility util = new FTPUtility(host, port, username, password); + try { + util.connect(); + + byte[] buffer = new byte[BUFFER_SIZE]; + int bytesRead = -1; + long totalBytesRead = 0; + int percentCompleted = 0; + + long fileSize = util.getFileSize(downloadPath); + //gui.setFileSize(fileSize); + + String fileName = new File(downloadPath).getName(); + + File downloadFile = new File(saveDir + File.separator + fileName); + FileOutputStream outputStream = new FileOutputStream(downloadFile); + + util.downloadFile(downloadPath); + InputStream inputStream = util.getInputStream(); + + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + totalBytesRead += bytesRead; + //System.out.println(totalBytesRead); + percentCompleted = (int) (totalBytesRead * 100 / fileSize); + setProgress(percentCompleted); + + } + + outputStream.close(); + + util.finish(); + } catch (FTPException ex) { + JOptionPane.showMessageDialog(null, "Error downloading file: " + ex.getMessage(), + "Error", JOptionPane.ERROR_MESSAGE); + ex.printStackTrace(); + setProgress(0); + cancel(true); + } finally { + util.disconnect(); + } + + return null; + } + + /** + * Executed in Swing's event dispatching thread + */ + @Override + protected void done() { + if (!isCancelled()) { + JOptionPane.showMessageDialog(null, + "File has been downloaded successfully!", "Message", + JOptionPane.INFORMATION_MESSAGE); + } + } +} \ No newline at end of file diff --git a/Dozentenmodul/src/downloader/FTPException.java b/Dozentenmodul/src/downloader/FTPException.java new file mode 100644 index 00000000..33ba32be --- /dev/null +++ b/Dozentenmodul/src/downloader/FTPException.java @@ -0,0 +1,8 @@ +package downloader; + +@SuppressWarnings("serial") +public class FTPException extends Exception { + public FTPException(String message) { + super(message); + } +} \ No newline at end of file diff --git a/Dozentenmodul/src/downloader/FTPUtility.java b/Dozentenmodul/src/downloader/FTPUtility.java new file mode 100644 index 00000000..dd0bd9ed --- /dev/null +++ b/Dozentenmodul/src/downloader/FTPUtility.java @@ -0,0 +1,187 @@ +package downloader; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import org.apache.commons.net.ftp.FTP; +import org.apache.commons.net.ftp.FTPClient; +import org.apache.commons.net.ftp.FTPFile; +import org.apache.commons.net.ftp.FTPReply; + +/** + * A utility class that provides functionality for downloading files from a FTP + * server. + * + * @author www.codejava.net + * + */ +public class FTPUtility { + + // FTP server information + private String host; + private int port; + private String username; + private String password; + + private FTPClient ftpClient = new FTPClient(); + private int replyCode; + + private InputStream inputStream; + private OutputStream outputStream; + + public FTPUtility(String host, int port, String user, String pass) { + this.host = host; + this.port = port; + this.username = user; + this.password = pass; + } + + /** + * Connect and login to the server. + * + * @throws FTPException + */ + public void connect() throws FTPException { + try { + ftpClient.connect(host, port); + replyCode = ftpClient.getReplyCode(); + if (!FTPReply.isPositiveCompletion(replyCode)) { + throw new FTPException("FTP serve refused connection."); + } + + boolean logged = ftpClient.login(username, password); + if (!logged) { + // failed to login + ftpClient.disconnect(); + throw new FTPException("Could not login to the server."); + } + + ftpClient.enterLocalPassiveMode(); + + } catch (IOException ex) { + throw new FTPException("I/O error: " + ex.getMessage()); + } + } + + /** + * Gets size (in bytes) of the file on the server. + * + * @param filePath + * Path of the file on server + * @return file size in bytes + * @throws FTPException + */ + public long getFileSize(String filePath) throws FTPException { + try { + FTPFile file = ftpClient.mlistFile(filePath); + if (file == null) { + throw new FTPException("The file may not exist on the server!"); + } + return file.getSize(); + } catch (IOException ex) { + throw new FTPException("Could not determine size of the file: " + + ex.getMessage()); + } + } + + /** + * Start downloading a file from the server + * + * @param downloadPath + * Full path of the file on the server + * @throws FTPException + * if client-server communication error occurred + */ + public void downloadFile(String downloadPath) throws FTPException { + try { + + boolean success = ftpClient.setFileType(FTP.BINARY_FILE_TYPE); + if (!success) { + throw new FTPException("Could not set binary file type."); + } + + inputStream = ftpClient.retrieveFileStream(downloadPath); + + if (inputStream == null) { + throw new FTPException( + "Could not open input stream. The file may not exist on the server."); + } + } catch (IOException ex) { + throw new FTPException("Error downloading file: " + ex.getMessage()); + } + } + + + /** + * Start uploading a file to the server + * @param uploadFile the file to be uploaded + * @param destDir destination directory on the server + * where the file is stored + * @throws FTPException if client-server communication error occurred + */ + public void uploadFile(File uploadFile, String destDir) throws FTPException { + try { + boolean success = ftpClient.changeWorkingDirectory(destDir); + if (!success) { + throw new FTPException("Could not change working directory to " + + destDir + ". The directory may not exist."); + } + + success = ftpClient.setFileType(FTP.BINARY_FILE_TYPE); + if (!success) { + throw new FTPException("Could not set binary file type."); + } + + outputStream = ftpClient.storeFileStream(uploadFile.getName()); + + } catch (IOException ex) { + throw new FTPException("Error uploading file: " + ex.getMessage()); + } + } + + /** + * Write an array of bytes to the output stream. + */ + public void writeFileBytes(byte[] bytes, int offset, int length) + throws IOException { + outputStream.write(bytes, offset, length); + } + + /** + * Complete the download operation. + */ + public void finish() throws IOException { + inputStream.close(); + ftpClient.completePendingCommand(); + } + + /** + * Log out and disconnect from the server + */ + public void disconnect() throws FTPException { + if (ftpClient.isConnected()) { + try { + if (!ftpClient.logout()) { + throw new FTPException("Could not log out from the server"); + } + ftpClient.disconnect(); + } catch (IOException ex) { + throw new FTPException("Error disconnect from the server: " + + ex.getMessage()); + } + } + } + + /** + * Return InputStream of the remote file on the server. + */ + public InputStream getInputStream() { + return inputStream; + } + + public OutputStream getOutputStream() { + return outputStream; + } +} \ No newline at end of file diff --git a/Dozentenmodul/src/downloader/UploadTask.java b/Dozentenmodul/src/downloader/UploadTask.java new file mode 100644 index 00000000..691a31bb --- /dev/null +++ b/Dozentenmodul/src/downloader/UploadTask.java @@ -0,0 +1,91 @@ +package downloader; + +import java.io.File; +import java.io.FileInputStream; + +import javax.swing.JOptionPane; +import javax.swing.SwingWorker; + +/** + * Executes the file upload in a background thread and updates progress to + * listeners that implement the java.beans.PropertyChangeListener interface. + * @author www.codejava.net + * + */ +public class UploadTask extends SwingWorker { + private static final int BUFFER_SIZE = 4096; + + private String host; + private int port; + private String username; + private String password; + + private String destDir; + private File uploadFile; + + public UploadTask(String host, int port, String username, String password, + String destDir, File uploadFile) { + this.host = host; + this.port = port; + this.username = username; + this.password = password; + this.destDir = destDir; + this.uploadFile = uploadFile; + } + + /** + * Executed in background thread + */ + @Override + protected Void doInBackground() throws Exception { + FTPUtility util = new FTPUtility(host, port, username, password); + try { + util.connect(); + util.uploadFile(uploadFile, destDir); + + FileInputStream inputStream = new FileInputStream(uploadFile); + byte[] buffer = new byte[BUFFER_SIZE]; + int bytesRead = -1; + long totalBytesRead = 0; + int percentCompleted = 0; + long fileSize = uploadFile.length(); + long start=System.nanoTime(); + final double NANOS_PER_SECOND = 1000000000.0; + final double BYTES_PER_MIB = 1024*1024; + while ((bytesRead = inputStream.read(buffer)) != -1) { + util.writeFileBytes(buffer, 0, bytesRead); + totalBytesRead += bytesRead; + percentCompleted = (int) (totalBytesRead * 100 / fileSize); + double speed = NANOS_PER_SECOND / BYTES_PER_MIB * totalBytesRead / (System.nanoTime() - start + 1); + setProgress(percentCompleted); + firePropertyChange("speed", 0, speed); + } + + inputStream.close(); + + util.finish(); + } catch (FTPException ex) { + JOptionPane.showMessageDialog(null, "Error uploading file: " + ex.getMessage(), + "Error", JOptionPane.ERROR_MESSAGE); + ex.printStackTrace(); + setProgress(0); + cancel(true); + } finally { + util.disconnect(); + } + + return null; + } + + /** + * Executed in Swing's event dispatching thread + */ + @Override + protected void done() { + if (!isCancelled()) { + JOptionPane.showMessageDialog(null, + "File has been uploaded successfully!", "Message", + JOptionPane.INFORMATION_MESSAGE); + } + } +} \ No newline at end of file diff --git a/Dozentenmodul/src/downloader/jschtest.java b/Dozentenmodul/src/downloader/jschtest.java new file mode 100644 index 00000000..83be7e03 --- /dev/null +++ b/Dozentenmodul/src/downloader/jschtest.java @@ -0,0 +1,84 @@ +package downloader; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.Properties; + +import com.jcraft.jsch.ChannelSftp; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.JSchException; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.SftpException; +import com.jcraft.jsch.UserInfo; + +public class jschtest { + + /** + * @param args + */ + public static void main(String[] args) { + File testfile=new File("C:\\Users\\tspitzer\\Documents\\201301_ws_win7_OPT_Apps_NC_Off2010.zip"); + try { + sftpFile(testfile, "fr-bwlehrpool-rw-admin" , "fefobu36", "bwsonas.lsdf.kit.edu", "/.mounts/bwlehrpool"); + } catch (FileNotFoundException | JSchException | SftpException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.out.println("Fertig"); + + } + + private static void sftpFile(File localFile, String username, String password, String hostname, String remoteDirectory) + throws JSchException, SftpException, FileNotFoundException { + + JSch jsch = new JSch(); + String filename = localFile.getName(); + Session session = jsch.getSession(username, hostname, 22); + session.setUserInfo(new HardcodedUserInfo(password)); + Properties config = new Properties(); + config.setProperty("StrictHostKeyChecking", "no"); + session.setConfig(config); + session.connect(); + ChannelSftp channel = (ChannelSftp)session.openChannel("sftp"); + channel.connect(); + channel.cd(remoteDirectory); + channel.put(new FileInputStream(localFile), filename); + channel.disconnect(); + session.disconnect(); + } + + private static class HardcodedUserInfo implements UserInfo { + + private final String password; + + private HardcodedUserInfo(String password) { + this.password = password; + } + + public String getPassphrase() { + return null; + } + + public String getPassword() { + return password; + } + + public boolean promptPassword(String s) { + return true; + } + + public boolean promptPassphrase(String s) { + return true; + } + + public boolean promptYesNo(String s) { + return true; + } + + public void showMessage(String s) { + System.out.println("message = " + s); + } + } + +} diff --git a/Dozentenmodul/src/sql/sql.java b/Dozentenmodul/src/sql/sql.java new file mode 100644 index 00000000..dade6b1e --- /dev/null +++ b/Dozentenmodul/src/sql/sql.java @@ -0,0 +1,179 @@ +package sql; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + + +public class sql { + + //Erstellt eine Verbindung zu einer Datenbank + public Connection getConnection() + { + try { + Class.forName("com.mysql.jdbc.Driver").newInstance(); + } catch (InstantiationException | IllegalAccessException + | ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + try { + Connection con=DriverManager.getConnection("jdbc:mysql://127.0.0.1/bwLehrpool?user=root&password=root"); + return con; + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + //Liefert alle vorhandenen Betriebssysteme zurück + public ResultSet getAllOS(Connection con) + { + Statement stm; + try { + stm = con.createStatement(); + return stm.executeQuery("SELECT distinct Produktname, Version, Architektur FROM bwlehrpool.betriebssystem order by Produktname asc;"); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + //Fügt ein Betriebssystem in die Datenbank ein + public int AddOS(Connection con, String name, String Version, String Architektur,int Kosten, String Hersteller) + { + Statement stm; + try { + stm=con.createStatement(); + + int pk_Hersteller=HerstellerExists(con, Hersteller); + + if(pk_Hersteller==-1) + { + addHersteller(con, Hersteller); + } + int ret=stm.executeUpdate("INSERT INTO `bwlehrpool`.`betriebssystem`(`Produktname`,`Version`,`Architektur`,`IstKostenlos`,`SWHersteller_pk`)VALUES('"+name+"','"+Version+"','"+Architektur+"',"+Kosten+","+pk_Hersteller+");"); + return ret; + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return -1; + + } + + //Überprüft ob der angegebene Hersteller bereits exisitert + public int HerstellerExists(Connection con, String Hersteller) + { + int pk_Hersteller=-1; + try { + ResultSet rs=getAllHersteller(con); + while(rs.next()) + { + if(rs.getString("Name").equals(Hersteller)) + { + pk_Hersteller=Integer.parseInt(rs.getString("pk")); + } + } + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return pk_Hersteller; + } + + //Liefert alle vorhandenen Hersteller zurück + public ResultSet getAllHersteller(Connection con) + { + try { + Statement stm=con.createStatement(); + return stm.executeQuery("SELECT pk,Name FROM bwLehrpool.SWHersteller order by Name asc;"); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + //Fügt einen Hersteller in die Datenbank ein + public int addHersteller(Connection con, String Name){ + Statement stm; + int ret=-1; + try { + stm=con.createStatement(); + ret=stm.executeUpdate("INSERT INTO `bwlehrpool`.`swhersteller`(`Name`)VALUES('"+Name+"');"); + con.commit(); + } catch (SQLException e) { + // TODO Auto-generated catch block + + e.printStackTrace(); + } + return ret; + } + + //Liefert sämtliche in der Datenbank vorhandene Software zurück + public ResultSet getAllSoftware(Connection con, String Hersteller) + { + + try { + Statement stm=con.createStatement(); + + return stm.executeQuery("SELECT s.pk,s.Produktname, s.Version, s.Architektur FROM bwLehrpool.Software s left join bwLehrpool.SWHersteller h on s.SWHersteller_pk=h.pk where Name like '"+Hersteller+"' order by s.Produktname;"); + + + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + return null; + + } + + //Gibt die Software abhängig vom gesuchten Namen zurück + public ResultSet getSoftwareByName(Connection con, String Name) + { + + try { + Statement stm=con.createStatement(); + + return stm.executeQuery("SELECT concat(h.Name,' ',s.Produktname,' ',s.Version,' ',s.Architektur) as SW FROM bwLehrpool.Software s left join bwLehrpool.SWHersteller h on s.SWHersteller_pk=h.pk where concat(h.Name,' ',s.Produktname,' ',s.Version,' ',s.Architektur) like '%"+Name+"%' order by s.Produktname;"); + + + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + return null; + + } + + //Fügt eine Software in die Datenbank ein + public int AddSoftware(Connection con, String name, String Version, String Architektur,int Kosten, String Hersteller) + { + Statement stm; + try { + stm=con.createStatement(); + + int pk_Hersteller=HerstellerExists(con, Hersteller); + + if(pk_Hersteller==-1) + { + addHersteller(con, Hersteller); + } + int ret=stm.executeUpdate("INSERT INTO `bwlehrpool`.`software`(`Produktname`,`Version`,`Architektur`,`IstKostenlos`,`SWHersteller_pk`)VALUES('"+name+"','"+Version+"','"+Architektur+"',"+Kosten+","+pk_Hersteller+");"); + return ret; + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return -1; + + } + +} -- cgit v1.2.3-55-g7522