summaryrefslogtreecommitdiffstats
path: root/Master/Daten- und Systemintegration/camelprototypewsclient/src/main
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/camelprototypewsclient/src/main
downloadStudium-master.tar.gz
Studium-master.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Master/Daten- und Systemintegration/camelprototypewsclient/src/main')
-rw-r--r--Master/Daten- und Systemintegration/camelprototypewsclient/src/main/CamelPrototypeWsClient.java30
-rw-r--r--Master/Daten- und Systemintegration/camelprototypewsclient/src/main/OrderPosAmountEditor.java33
-rw-r--r--Master/Daten- und Systemintegration/camelprototypewsclient/src/main/OrderPosEditor.java27
-rw-r--r--Master/Daten- und Systemintegration/camelprototypewsclient/src/main/OrderPosInputVerifier.java23
-rw-r--r--Master/Daten- und Systemintegration/camelprototypewsclient/src/main/OrderPosTableModel.java110
-rw-r--r--Master/Daten- und Systemintegration/camelprototypewsclient/src/main/WsClientMainFrame.java187
6 files changed, 410 insertions, 0 deletions
diff --git a/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/CamelPrototypeWsClient.java b/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/CamelPrototypeWsClient.java
new file mode 100644
index 0000000..70f922a
--- /dev/null
+++ b/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/CamelPrototypeWsClient.java
@@ -0,0 +1,30 @@
+package main;
+
+import java.rmi.RemoteException;
+
+import javax.xml.rpc.ServiceException;
+
+import de.h_da.fbi.dsi.ws0910.camelprototype.InputNewOrder;
+import de.h_da.fbi.dsi.ws0910.camelprototype.OrderEndpoint;
+import de.h_da.fbi.dsi.ws0910.camelprototype.OrderEndpointServiceLocator;
+import de.h_da.fbi.dsi.ws0910.camelprototype.OrderPosition;
+import de.h_da.fbi.dsi.ws0910.camelprototype.OutputNewOrder;
+
+public class CamelPrototypeWsClient {
+
+ public static void main(String[] args) throws ServiceException, RemoteException {
+ OrderEndpointServiceLocator loc = new OrderEndpointServiceLocator();
+ OrderEndpoint client = loc.getOrderService();
+ InputNewOrder in = new InputNewOrder();
+ in.setCustomerNo("Cust0815");
+ OrderPosition pos1 = new OrderPosition();
+ pos1.setArticleNo("A123");
+ pos1.setArticle("Article One");
+ pos1.setAmount(23);
+ in.setOrderpositions(new OrderPosition[]{pos1});
+ OutputNewOrder out = client.createOrder(in);
+ System.out.println("Orderstatus: "+out.getStatus());
+ System.out.println("Order number: "+out.getMessage());
+ }
+
+}
diff --git a/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/OrderPosAmountEditor.java b/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/OrderPosAmountEditor.java
new file mode 100644
index 0000000..ee7b52a
--- /dev/null
+++ b/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/OrderPosAmountEditor.java
@@ -0,0 +1,33 @@
+package main;
+
+import java.awt.Component;
+
+import javax.swing.DefaultCellEditor;
+import javax.swing.InputVerifier;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+
+public class OrderPosAmountEditor extends DefaultCellEditor {
+
+ private static final long serialVersionUID = 1L;
+ private InputVerifier verifier;
+
+ public OrderPosAmountEditor(JTextField jtf, InputVerifier verifier) {
+ super(jtf);
+ editorComponent.setInputVerifier(verifier);
+ this.verifier = verifier;
+ }
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value,
+ boolean isSelected, int row, int column) {
+ ((JTextField) editorComponent).setText(((Integer) value).toString());
+ return editorComponent;
+ }
+ @Override
+ public boolean stopCellEditing() {
+ if(verifier.verify(editorComponent)) {
+ return super.stopCellEditing();
+ }
+ return false;
+ }
+}
diff --git a/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/OrderPosEditor.java b/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/OrderPosEditor.java
new file mode 100644
index 0000000..501f1db
--- /dev/null
+++ b/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/OrderPosEditor.java
@@ -0,0 +1,27 @@
+package main;
+
+import java.awt.Component;
+
+import javax.swing.AbstractCellEditor;
+import javax.swing.JComponent;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.table.TableCellEditor;
+
+public class OrderPosEditor extends AbstractCellEditor implements TableCellEditor{
+ private JComponent cellEditComponent = new JTextField();
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object getCellEditorValue() {
+ return ( (JTextField) cellEditComponent).getText();
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value,
+ boolean isSelected, int row, int column) {
+ System.out.println("Column: "+column);
+ return cellEditComponent;
+ }
+
+}
diff --git a/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/OrderPosInputVerifier.java b/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/OrderPosInputVerifier.java
new file mode 100644
index 0000000..4e77979
--- /dev/null
+++ b/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/OrderPosInputVerifier.java
@@ -0,0 +1,23 @@
+package main;
+
+import javax.swing.InputVerifier;
+import javax.swing.JComponent;
+import javax.swing.JTextField;
+
+public class OrderPosInputVerifier extends InputVerifier {
+
+ @Override
+ public boolean verify(JComponent input) {
+ boolean isInputValid = false;
+ String inTxt = ((JTextField) input).getText();
+
+ String pattern = "\\d*";
+ if(inTxt.matches(pattern)) {
+ isInputValid = true;
+ } else {
+ isInputValid = false;
+ }
+ return isInputValid;
+ }
+
+}
diff --git a/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/OrderPosTableModel.java b/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/OrderPosTableModel.java
new file mode 100644
index 0000000..ca084c0
--- /dev/null
+++ b/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/OrderPosTableModel.java
@@ -0,0 +1,110 @@
+package main;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.table.AbstractTableModel;
+
+import de.h_da.fbi.dsi.ws0910.camelprototype.OrderPosition;
+
+public class OrderPosTableModel extends AbstractTableModel {
+ private static final long serialVersionUID = 1L;
+
+ private List<OrderPosition> posList;
+
+ public OrderPosTableModel() {
+ super();
+ posList = new ArrayList<OrderPosition>();
+ addPosition();
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 3;
+ }
+
+ @Override
+ public int getRowCount() {
+ return posList.size();
+ }
+
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ OrderPosition actOrderPosition = posList.get(rowIndex);
+ Object res = null;
+ switch(columnIndex) {
+ case 0: res = actOrderPosition.getArticleNo(); break;
+ case 1: res = actOrderPosition.getArticle(); break;
+ case 2: res = actOrderPosition.getAmount(); break;
+ default: res = null;
+ }
+ return res;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ switch(column) {
+ case 0: return "Article No.";
+ case 1: return "Article";
+ case 2: return "Amount";
+ default: return "";
+ }
+ }
+
+ @Override
+ public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+ OrderPosition actOrderPosition = posList.get(rowIndex);
+ String val = (String) aValue;
+ switch(columnIndex) {
+ case 0: actOrderPosition.setArticleNo(val); break;
+ case 1: actOrderPosition.setArticle(val); break;
+ case 2: {
+ int intVal = Integer.parseInt(val);
+ actOrderPosition.setAmount(intVal);
+ break;
+ }
+ }
+ if(validate(actOrderPosition) && (rowIndex == posList.size()-1 )) {
+ addPosition();
+ }
+ fireTableDataChanged();
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return true;
+ }
+ public void addPosition() {
+ posList.add(new OrderPosition("", 0, ""));
+ fireTableDataChanged();
+ }
+ public void clear() {
+ posList.clear();
+ fireTableDataChanged();
+ }
+ public OrderPosition[] getOrderPositions() {
+ List<OrderPosition> res = new ArrayList<OrderPosition>();
+ for(OrderPosition pos : posList) {
+ if(validate(pos)) {
+ res.add(pos);
+ }
+ }
+ return res.toArray(new OrderPosition[res.size()]);
+ }
+ private boolean validate(OrderPosition pos) {
+ if(!pos.getArticleNo().isEmpty()
+ && !pos.getArticle().isEmpty()
+ && (pos.getAmount() > 0) ) {
+ return true;
+ }
+ return false;
+ }
+ public boolean isValid() {
+ for(OrderPosition pos: posList) {
+ if(!validate(pos)) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
diff --git a/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/WsClientMainFrame.java b/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/WsClientMainFrame.java
new file mode 100644
index 0000000..31ca1c2
--- /dev/null
+++ b/Master/Daten- und Systemintegration/camelprototypewsclient/src/main/WsClientMainFrame.java
@@ -0,0 +1,187 @@
+package main;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+import javax.swing.WindowConstants;
+
+import com.jgoodies.forms.layout.CellConstraints;
+import com.jgoodies.forms.layout.FormLayout;
+
+import de.h_da.fbi.dsi.ws0910.camelprototype.InputNewOrder;
+import de.h_da.fbi.dsi.ws0910.camelprototype.OrderEndpoint;
+import de.h_da.fbi.dsi.ws0910.camelprototype.OrderEndpointServiceLocator;
+import de.h_da.fbi.dsi.ws0910.camelprototype.OrderPosition;
+import de.h_da.fbi.dsi.ws0910.camelprototype.OutputNewOrder;
+
+
+/**
+* This code was edited or generated using CloudGarden's Jigloo
+* SWT/Swing GUI Builder, which is free for non-commercial
+* use. If Jigloo is being used commercially (ie, by a corporation,
+* company or business for any purpose whatever) then you
+* should purchase a license for each developer using Jigloo.
+* Please visit www.cloudgarden.com for details.
+* Use of Jigloo implies acceptance of these licensing terms.
+* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
+* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
+* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
+*/
+public class WsClientMainFrame extends javax.swing.JFrame {
+ private static final long serialVersionUID = 1L;
+ private OrderPosTableModel orderPosTableModel;
+ private OrderPosEditor orderPosCellEditor;
+ private JButton submitBtn;
+ private JButton cancelButton;
+ private JTable orderPosTable;
+ private JScrollPane jScrollPane1;
+ private JLabel posLabel;
+ private JTextField custNoField;
+ private JLabel custNoLabel;
+ private JTextField msgField;
+ private JTextField statusField;
+ private JLabel msgLabel;
+ private JLabel statusLabel;
+
+ /**
+ * Auto-generated main method to display this JFrame
+ */
+ public static void main(String[] args) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ WsClientMainFrame inst = new WsClientMainFrame();
+ inst.setLocationRelativeTo(null);
+ inst.setVisible(true);
+ }
+ });
+ }
+
+ public WsClientMainFrame() {
+ super();
+ initGUI();
+ }
+
+ private void initGUI() {
+ try {
+ orderPosTableModel = new OrderPosTableModel();
+ orderPosCellEditor = new OrderPosEditor();
+ FormLayout thisLayout = new FormLayout(
+ "5dlu, 54dlu, 5dlu, 64dlu, 64dlu, 64dlu",
+ "5dlu, max(p;5dlu), 5dlu, 48dlu, 5dlu, max(p;15dlu), 5dlu, 14dlu, 5dlu, max(p;15dlu), 5dlu, max(p;5dlu)");
+ getContentPane().setLayout(thisLayout);
+ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+ this.setTitle("DSI WS09/10 CamelPrototype WS Client");
+ this.setPreferredSize(new java.awt.Dimension(520, 300));
+ {
+ submitBtn = new JButton();
+ getContentPane().add(submitBtn, new CellConstraints("4, 12, 1, 1, default, default"));
+ submitBtn.setText("Submit");
+ submitBtn.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if(orderPosTable.isEditing()) {
+ if(!orderPosTable.getCellEditor().stopCellEditing()) {
+ return;
+ }
+ }
+ if(custNoField.getText().isEmpty()) {
+ statusField.setText("Not OK!");
+ msgField.setText("Customer No. empty!");
+ return;
+ }
+ OrderPosition[] orderPos = orderPosTableModel.getOrderPositions();
+ if(orderPos.length == 0) {
+ statusField.setText("Not OK!");
+ msgField.setText("No valid order positions!");
+ return;
+ }
+ InputNewOrder in = new InputNewOrder();
+ in.setCustomerNo(custNoField.getText());
+ in.setOrderpositions(orderPos);
+ OrderEndpointServiceLocator loc = new OrderEndpointServiceLocator();
+ try {
+ OrderEndpoint client = loc.getOrderService();
+ OutputNewOrder out = client.createOrder(in);
+ String status = "0".equals(out.getStatus())?"OK":"Not OK";
+ statusField.setText(status);
+ msgField.setText("Received Order No.: "+out.getMessage());
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+
+ }
+ });
+ }
+ {
+ cancelButton = new JButton();
+ getContentPane().add(cancelButton, new CellConstraints("6, 12, 1, 1, default, default"));
+ cancelButton.setText("Cancel");
+ cancelButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ orderPosTableModel.clear();
+ custNoField.setText("");
+ statusField.setText("");
+ msgField.setText("");
+ }
+ });
+ }
+ {
+ jScrollPane1 = new JScrollPane();
+ getContentPane().add(jScrollPane1, new CellConstraints("4, 4, 3, 3, default, default"));
+ {
+ orderPosTable = new JTable();
+ jScrollPane1.setViewportView(orderPosTable);
+ orderPosTable.setModel(orderPosTableModel);
+ orderPosTable.setColumnSelectionAllowed(true);
+ orderPosTable.setCellEditor(orderPosCellEditor);
+ orderPosTable.getColumnModel().getColumn(2).setCellEditor(new OrderPosAmountEditor(new JTextField(), new OrderPosInputVerifier()));
+ orderPosTable.getTableHeader().setLocale(new java.util.Locale("de"));
+ }
+ }
+ {
+ statusLabel = new JLabel();
+ getContentPane().add(statusLabel, new CellConstraints("2, 8, 1, 1, default, default"));
+ statusLabel.setText("Status");
+ }
+ {
+ msgLabel = new JLabel();
+ getContentPane().add(msgLabel, new CellConstraints("2, 10, 1, 1, default, default"));
+ msgLabel.setText("Message");
+ }
+ {
+ statusField = new JTextField();
+ getContentPane().add(statusField, new CellConstraints("4, 8, 3, 1, default, default"));
+ statusField.setEditable(false);
+ }
+ {
+ msgField = new JTextField();
+ getContentPane().add(msgField, new CellConstraints("4, 10, 3, 1, default, default"));
+ msgField.setEditable(false);
+ }
+ {
+ custNoLabel = new JLabel();
+ getContentPane().add(custNoLabel, new CellConstraints("2, 2, 1, 1, default, default"));
+ custNoLabel.setText("Customer No.");
+ }
+ {
+ custNoField = new JTextField();
+ getContentPane().add(custNoField, new CellConstraints("4, 2, 1, 1, default, default"));
+ }
+ {
+ posLabel = new JLabel();
+ getContentPane().add(posLabel, new CellConstraints("2, 4, 1, 1, default, top"));
+ posLabel.setText("Order Positions");
+ }
+ pack();
+ this.setSize(540, 300);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}