@Override public void onReceive(Object work) throws Exception { System.out.println("Starting multi step work on thread " + Thread.currentThread().getName()); WorkOrder nextStep = null; if (work instanceof WorkOrder) { // if(workOrder != null){ // Logger.error("Received second work order : " + work); // throw new IllegalStateException("Received second work order : " + work); // } customer = getSender(); workOrder = (WorkOrder) work; this.workOrderUuid = workOrder.getUuid(); // System.out.println("just set work order uuid : " + this.workOrderUuid); // System.out.println("Performing work : " + workOrder.getWorkType()); nextStep = processWorkOrder(workOrder); if (nextStep != null) { Asyncleton.getInstance().getMaster(nextStep.getWorkType()).tell(nextStep, customer); } } else if (work instanceof WorkResult) { WorkResult workResult = (WorkResult) work; processWorkResult(workResult); // doNextStep(); } else { Logger.error("got unknown work in Multi Step worker : " + work); } }
private void customerNameChooserActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_customerNameChooserActionPerformed String name = (String) customerNameChooser.getSelectedItem(); Customer c = null; customersWos = new ArrayList<>(); for (Customer cu : customerList) { if (cu.getCustomerID().equals(customerMap.get(name))) { c = cu; currentCustomer = c; } } for (Vehicle v : vehicleList) { if (v.getCustomerID().equals(c)) { makeField1.setText(v.getMake()); modelField1.setText(v.getModel()); yearComboBox1.addItem(v.getYear()); vinField1.setText(v.getVin()); licenseField1.setText(v.getLicencePlate()); } } woComboBox1.removeAllItems(); woComboBox2.removeAllItems(); CustomerIDField.setText(c.getCustomerID().toString()); for (WorkOrder wo : workOrderList) { if (wo.getVehicleID().getCustomerID().equals(c)) { woComboBox1.addItem(wo.getOrderNo()); woComboBox2.addItem(wo.getOrderNo()); customersWos.add(wo); } } } // GEN-LAST:event_customerNameChooserActionPerformed
private void woComboBox2ActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_woComboBox2ActionPerformed Integer woNum = (Integer) woComboBox2.getSelectedItem(); for (WorkOrder wo : workOrderList) { if (wo.getOrderNo().equals(woNum)) { empIdField2.setText(wo.getEmpID().getEmployeeID().toString()); } } } // GEN-LAST:event_woComboBox2ActionPerformed
private void finishBtnActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_finishBtnActionPerformed if (mileageField.getText().isEmpty()) { JOptionPane.showMessageDialog(this, "Mileage must be filled in"); return; } Invoice invoice = new Invoice(); invoice.setCustomerID(currentCustomer); Integer mileage = 0; try { mileage = Integer.parseInt(mileageField.getText()); } catch (NumberFormatException e) { JOptionPane.showMessageDialog(this, "Incorrect format for mileage"); return; } invoice.setMileageOut(mileage); invoice.setPayment(false); Date date = new Date( datePicker.getModel().getYear() - 1900, datePicker.getModel().getMonth(), datePicker.getModel().getDay()); ArrayList<WorkOrder> temp = new ArrayList<>(); for (WorkOrder w : customersWos) { if (((Integer) woComboBox1.getSelectedItem()).equals(w.getOrderNo())) { w.setEndTime(date); temp.add(w); invoice.setWorkOrderList(temp); } } MainWindow.em.getTransaction().begin(); MainWindow.em.persist(invoice); MainWindow.em.flush(); MainWindow.em.refresh(invoice); for (WorkOrder wo : temp) { wo.setInvoiceNo(invoice); MainWindow.em.persist(wo); MainWindow.em.flush(); MainWindow.em.refresh(wo); } MainWindow.em.getTransaction().commit(); JOptionPane.showMessageDialog( this, "Invoice successfully created.", "Success", JOptionPane.INFORMATION_MESSAGE); this.setVisible(false); parent.setInvoiceTable(); } // GEN-LAST:event_finishBtnActionPerformed
private void populate() { EntityManager em = MainWindow.em; TypedQuery<WorkOrder> query = em.createNamedQuery("WorkOrder.findAll", WorkOrder.class); workOrderList = query.getResultList(); for (WorkOrder wo : workOrderList) { customerList.add(wo.getVehicleID().getCustomerID()); vehicleList.add(wo.getVehicleID()); String names = wo.getVehicleID().getCustomerID().getFName() + " " + wo.getVehicleID().getCustomerID().getLName(); customerMap.put(names, wo.getVehicleID().getCustomerID().getCustomerID()); if (((DefaultComboBoxModel) customerNameChooser.getModel()).getIndexOf(names) == -1) // Check if the customer already has a work order. customerNameChooser.addItem(names); } }
/** * This Method returns the WorkOrder Object for the passed in workorderId * * @param workOrderId - WorkOrder Id Foreign Key of WRK_ORDR_DETS table * @return WorkOrder Object - WorkOrder Object for the passed workorderId */ public WorkOrder getWorkOrderInfo(long workorderId) throws RemoteException { WorkOrder wrkordr = new WorkOrder(conn); return wrkordr.getWorkOrder(workorderId); }