Search in sources :

Example 6 with Customer

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);
}
Also used : Customer(eu.ggnet.dwoss.customer.ee.entity.Customer)

Example 7 with Customer

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;
}
Also used : java.util(java.util) Initializable(javafx.fxml.Initializable) javafx.scene.control(javafx.scene.control) URL(java.net.URL) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) CustomerContinue(eu.ggnet.dwoss.customer.ui.neo.CustomerSimpleController.CustomerContinue) Ui(eu.ggnet.saft.Ui) PicoCustomer(eu.ggnet.dwoss.customer.ee.entity.projection.PicoCustomer) Dl(eu.ggnet.saft.Dl) AlertType(eu.ggnet.saft.core.ui.AlertType) READY(javafx.concurrent.Worker.State.READY) CustomerAgent(eu.ggnet.dwoss.customer.ee.CustomerAgent) KeyCode(javafx.scene.input.KeyCode) HBox(javafx.scene.layout.HBox) Logger(org.slf4j.Logger) Css(eu.ggnet.dwoss.rules.Css) CustomerTaskService(eu.ggnet.dwoss.customer.ui.CustomerTaskService) eu.ggnet.saft.api.ui(eu.ggnet.saft.api.ui) FXML(javafx.fxml.FXML) ActionEvent(javafx.event.ActionEvent) MAX_VALUE(java.lang.Double.MAX_VALUE) SearchField(eu.ggnet.dwoss.customer.ee.entity.Customer.SearchField) FxSaft(eu.ggnet.saft.core.ui.FxSaft) Reply(eu.ggnet.saft.api.Reply) Customer(eu.ggnet.dwoss.customer.ee.entity.Customer) ObservableList(javafx.collections.ObservableList) StringProperty(javafx.beans.property.StringProperty) HtmlPane(eu.ggnet.dwoss.util.HtmlPane) PicoCustomer(eu.ggnet.dwoss.customer.ee.entity.projection.PicoCustomer) Customer(eu.ggnet.dwoss.customer.ee.entity.Customer) ActionEvent(javafx.event.ActionEvent) Reply(eu.ggnet.saft.api.Reply) PicoCustomer(eu.ggnet.dwoss.customer.ee.entity.projection.PicoCustomer) HtmlPane(eu.ggnet.dwoss.util.HtmlPane)

Example 8 with Customer

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);
}
Also used : JPanel(javax.swing.JPanel) Customer(eu.ggnet.dwoss.customer.ee.entity.Customer) JButton(javax.swing.JButton) CustomerGenerator(eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGenerator)

Example 9 with Customer

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);
}
Also used : JPanel(javax.swing.JPanel) Customer(eu.ggnet.dwoss.customer.ee.entity.Customer) AddressLabel(eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel) JButton(javax.swing.JButton) CustomerGenerator(eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGenerator)

Example 10 with Customer

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();
}
Also used : Customer(eu.ggnet.dwoss.customer.ee.entity.Customer) CustomerEao(eu.ggnet.dwoss.customer.ee.eao.CustomerEao) Test(org.junit.Test)

Aggregations

Customer (eu.ggnet.dwoss.customer.ee.entity.Customer)11 OldCustomer (eu.ggnet.dwoss.customer.ee.priv.OldCustomer)5 CustomerGenerator (eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGenerator)3 Test (org.junit.Test)3 MandatorMetadata (eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata)2 UiCustomer (eu.ggnet.dwoss.customer.opi.UiCustomer)2 CustomerAgent (eu.ggnet.dwoss.customer.ee.CustomerAgent)1 CustomerEao (eu.ggnet.dwoss.customer.ee.eao.CustomerEao)1 Communication (eu.ggnet.dwoss.customer.ee.entity.Communication)1 Company (eu.ggnet.dwoss.customer.ee.entity.Company)1 Contact (eu.ggnet.dwoss.customer.ee.entity.Contact)1 SearchField (eu.ggnet.dwoss.customer.ee.entity.Customer.SearchField)1 AddressLabel (eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel)1 PicoCustomer (eu.ggnet.dwoss.customer.ee.entity.projection.PicoCustomer)1 CustomerTaskService (eu.ggnet.dwoss.customer.ui.CustomerTaskService)1 CustomerContinue (eu.ggnet.dwoss.customer.ui.neo.CustomerSimpleController.CustomerContinue)1 DefaultCustomerSalesdata (eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata)1 Css (eu.ggnet.dwoss.rules.Css)1 CustomerFlag (eu.ggnet.dwoss.rules.CustomerFlag)1 HtmlPane (eu.ggnet.dwoss.util.HtmlPane)1