use of eu.ggnet.dwoss.customer.ee.entity.Customer in project dwoss by gg-net.
the class OldCustomerAgentBean method store.
@Override
public OldCustomer store(OldCustomer old) {
if (old == null)
return null;
Customer customer = new Customer();
if (old.getId() > 0)
customer = customerEm.find(Customer.class, (long) old.getId());
mergeFromOld(old, customer, mandator.getMatchCode(), salesData);
if (old.getId() == 0)
customerEm.persist(customer);
return ConverterUtil.convert(customer, mandator.getMatchCode(), salesData);
}
use of eu.ggnet.dwoss.customer.ee.entity.Customer in project dwoss by gg-net.
the class CustomerSearchController method buildContextMenu.
/**
* Build a ContextMenu for ListView of the search results for a better navigation
*
* @return ContextMenu the filled ContextMenu
*/
private ContextMenu buildContextMenu() {
// Create a ContextMenu
ContextMenu contextMenu = new ContextMenu();
MenuItem viewCustomer = new MenuItem("Detailansicht");
MenuItem viewCompleteCustomer = new MenuItem("Detailansicht inc. aller Mandatendetails");
MenuItem editCustomer = new MenuItem("Bearbeiten");
// adding actions to the context menu
viewCustomer.setOnAction((ActionEvent event) -> {
// open toHtml(String matchcode, DefaultCustomerSalesdata defaults)
if (resultListView.getSelectionModel().getSelectedItem() == null)
return;
PicoCustomer selectedCustomer = resultListView.getSelectionModel().getSelectedItem();
Ui.exec(() -> {
Ui.build(statusHbox).title("Kunde mit Mandant").fx().show(() -> Css.toHtml5WithStyle(AGENT.findCustomerAsMandatorHtml(selectedCustomer.getId())), () -> new HtmlPane());
});
});
viewCompleteCustomer.setOnAction((ActionEvent event) -> {
// open toHtml(String salesRow, String comment)
if (resultListView.getSelectionModel().getSelectedItem() == null)
return;
PicoCustomer selectedCustomer = resultListView.getSelectionModel().getSelectedItem();
Ui.exec(() -> {
Ui.build(statusHbox).title("Kunden Ansicht").fx().show(() -> Css.toHtml5WithStyle(AGENT.findCustomerAsHtml(selectedCustomer.getId())), () -> new HtmlPane());
});
});
editCustomer.setOnAction((ActionEvent event) -> {
if (resultListView.getSelectionModel().getSelectedItem() == null)
return;
PicoCustomer picoCustomer = resultListView.getSelectionModel().getSelectedItem();
Ui.exec(() -> {
Customer customer = Ui.progress().call(() -> AGENT.findByIdEager(Customer.class, picoCustomer.getId()));
if (!customer.isValid()) {
Ui.build(resultListView).title("Fehlerhafter Datensatz").alert().message("Kundendaten sind invalid (aktuell normal): " + customer.getViolationMessage()).show(AlertType.WARNING);
} else if (customer.isSimple()) {
L.info("Edit Simple Customer {}", customer.getId());
Optional<CustomerContinue> result = Ui.build(resultListView).fxml().eval(() -> customer, CustomerSimpleController.class).opt();
if (!result.isPresent())
return;
Reply<Customer> reply = Dl.remote().lookup(CustomerAgent.class).store(result.get().simpleCustomer);
if (!Ui.failure().handle(reply))
return;
if (!result.get().continueEnhance)
return;
Ui.build(statusHbox).fxml().eval(() -> reply.getPayload(), CustomerEnhanceController.class).opt().ifPresent(c -> Ui.build(statusHbox).alert("Would store + " + c));
} else if (customer.isBusiness()) {
L.info("Edit (Complex) Customer {}", customer.getId());
Ui.build(statusHbox).fxml().eval(() -> customer, CustomerEnhanceController.class).opt().ifPresent(c -> Ui.build(statusHbox).alert("Would store + " + c));
}
});
});
// add MenuItemes to ContextMenu
contextMenu.getItems().addAll(viewCustomer, viewCompleteCustomer, editCustomer);
return contextMenu;
}
use of eu.ggnet.dwoss.customer.ee.entity.Customer in project dwoss by gg-net.
the class PreferedAddressLabelsTryOut method main.
public static void main(String[] args) {
CustomerGenerator gen = new CustomerGenerator();
JButton close = new JButton("Schliessen");
close.addActionListener(e -> Ui.closeWindowOf(close));
JButton firmenKundenButton = new JButton("Lade FirmenKunde");
firmenKundenButton.addActionListener(ev -> {
Customer customer = gen.makeCustomer();
customer.getContacts().clear();
customer.getCompanies().add(gen.makeCompany());
customer.getCompanies().add(gen.makeCompany());
if (!customer.isValid()) {
Ui.exec(() -> {
Ui.build().alert("customer is invalid" + customer.getViolationMessage());
});
return;
}
Ui.exec(() -> {
Ui.build().fxml().eval(() -> customer, PreferedAddressLabelsController.class);
});
});
JButton endKundenButton = new JButton("Lade Endkunde");
endKundenButton.addActionListener(ev -> {
Customer customer = gen.makeCustomer();
customer.getCompanies().clear();
customer.getContacts().add(gen.makeContact());
customer.getContacts().add(gen.makeContact());
if (!customer.isValid()) {
Ui.exec(() -> {
Ui.build().alert("customer is invalid" + customer.getViolationMessage());
});
return;
}
Ui.exec(() -> {
Ui.build().fxml().eval(() -> customer, PreferedAddressLabelsController.class);
});
});
JPanel p = new JPanel();
p.add(firmenKundenButton);
p.add(endKundenButton);
p.add(close);
UiCore.startSwing(() -> p);
}
use of eu.ggnet.dwoss.customer.ee.entity.Customer in project dwoss by gg-net.
the class CustomerEnhanceTryout method main.
public static void main(String[] args) {
CustomerGenerator gen = new CustomerGenerator();
JButton close = new JButton("Schliessen");
close.addActionListener(e -> Ui.closeWindowOf(close));
JButton firmenKundenButton = new JButton("Lade FirmenKunde");
firmenKundenButton.addActionListener(ev -> {
Customer customer = gen.makeCustomer();
customer.getContacts().clear();
customer.getCompanies().add(gen.makeCompany());
customer.getCompanies().add(gen.makeCompany());
customer.getCompanies().add(gen.makeCompany());
customer.getCompanies().add(gen.makeCompany());
customer.setSource(Source.ONEADO);
customer.setKeyAccounter("Herr Meier");
customer.getFlags().add(CustomerFlag.ITC_CUSTOMER);
customer.getFlags().add(CustomerFlag.CS_UPDATE_CANDIDATE);
customer.getAdditionalCustomerIds().put(ExternalSystem.SAGE, "testsage");
if (customer.getViolationMessage() != null) {
Ui.exec(() -> {
Ui.build().alert("customer is invalid" + customer.getViolationMessage());
});
return;
}
customer.getAddressLabels().add(new AddressLabel(gen.makeCompany(), null, gen.makeAddress(), AddressType.SHIPPING));
Ui.exec(() -> {
Ui.build().fxml().eval(() -> customer, CustomerEnhanceController.class).opt().ifPresent(System.out::println);
});
});
JButton endKundenButton = new JButton("Lade Endkunde");
endKundenButton.addActionListener(ev -> {
Customer customer = gen.makeCustomer();
customer.getCompanies().clear();
customer.getContacts().add(gen.makeContact());
customer.getContacts().add(gen.makeContact());
customer.getContacts().add(gen.makeContact());
customer.getContacts().add(gen.makeContact());
customer.setSource(Source.ONEADO);
customer.getFlags().add(CustomerFlag.ITC_CUSTOMER);
customer.getFlags().add(CustomerFlag.CS_UPDATE_CANDIDATE);
customer.getAdditionalCustomerIds().put(ExternalSystem.SAGE, "testsage");
if (customer.getViolationMessage() != null) {
Ui.exec(() -> {
Ui.build().alert("customer is invalid" + customer.getViolationMessage());
});
return;
}
Ui.exec(() -> {
Ui.build().fxml().eval(() -> customer, CustomerEnhanceController.class).opt().ifPresent(System.out::println);
});
});
JPanel p = new JPanel();
p.add(endKundenButton);
p.add(firmenKundenButton);
p.add(close);
UiCore.startSwing(() -> p);
}
use of eu.ggnet.dwoss.customer.ee.entity.Customer in project dwoss by gg-net.
the class CustomerEoaIT method testPersistence.
@Test
public void testPersistence() throws Exception {
CustomerEao eao = new CustomerEao(em);
utx.begin();
em.joinTransaction();
Customer c = GEN.makeCustomer();
// Make sure no systemcustomer.
c.getFlags().remove(CustomerFlag.SYSTEM_CUSTOMER);
em.persist(c);
utx.commit();
utx.begin();
em.joinTransaction();
assertTrue(eao.findAllSystemCustomerIds().isEmpty());
c = GEN.makeCustomer();
// Make sure it is a systemcustomer.
c.getFlags().add(CustomerFlag.SYSTEM_CUSTOMER);
em.persist(c);
utx.commit();
utx.begin();
em.joinTransaction();
assertEquals(1, eao.findAllSystemCustomerIds().size());
utx.commit();
}
Aggregations