Search in sources :

Example 6 with AddressLabel

use of eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel in project dwoss by gg-net.

the class CustomerAgentIT method makeValidAddressLabel.

public static AddressLabel makeValidAddressLabel() {
    AddressLabel validAddressLabel = new AddressLabel(makeValidCompany(), makeValidContact(), makeValidAddress(), AddressType.INVOICE);
    assertThat(validAddressLabel.getViolationMessage()).as("valid validAddressLabel").isNull();
    return validAddressLabel;
}
Also used : AddressLabel(eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel)

Example 7 with AddressLabel

use of eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel in project dwoss by gg-net.

the class PreferedAddressLabelsController method accept.

@Override
public void accept(Customer inputCustomer) {
    this.customer = inputCustomer;
    invoiceAddressCompanyListView.getItems().addAll(customer.getCompanies());
    invoiceAddressCompanyListView.getItems().forEach(company -> invoiceAddressContactListView.getItems().addAll(company.getContacts()));
    invoiceAddressCompanyListView.getItems().forEach(company -> invoiceAddressAddressListView.getItems().addAll(company.getAddresses()));
    invoiceAddressContactListView.getItems().addAll(customer.getContacts());
    invoiceAddressContactListView.getItems().forEach(contact -> invoiceAddressAddressListView.getItems().addAll(contact.getAddresses()));
    shippingAddressCompanyListView.getItems().addAll(customer.getCompanies());
    shippingAddressCompanyListView.getItems().forEach(company -> shippingAddressContactListView.getItems().addAll(company.getContacts()));
    shippingAddressCompanyListView.getItems().forEach(company -> shippingAddressAddressListView.getItems().addAll(company.getAddresses()));
    shippingAddressContactListView.getItems().addAll(customer.getContacts());
    shippingAddressContactListView.getItems().forEach(contact -> shippingAddressAddressListView.getItems().addAll(contact.getAddresses()));
    if (customer.getAddressLabels().stream().filter(addressLabel -> addressLabel.getType() == AddressType.INVOICE).findFirst().isPresent()) {
        AddressLabel invoiceLabel = customer.getAddressLabels().stream().filter(addressLabel -> addressLabel.getType() == AddressType.INVOICE).findFirst().get();
        invoiceAddressWebView.getEngine().loadContent(invoiceLabel.toHtml());
        if (invoiceLabel.getCompany() != null)
            invoiceAddressCompanyListView.getSelectionModel().select(invoiceLabel.getCompany());
        if (invoiceLabel.getContact() != null)
            invoiceAddressContactListView.getSelectionModel().select(invoiceLabel.getContact());
        invoiceAddressAddressListView.getSelectionModel().select(invoiceLabel.getAddress());
    }
    if (customer.getAddressLabels().stream().filter(addressLabel -> addressLabel.getType() == AddressType.SHIPPING).findFirst().isPresent()) {
        AddressLabel shippingLabel = customer.getAddressLabels().stream().filter(addressLabel -> addressLabel.getType() == AddressType.SHIPPING).findFirst().get();
        shippingAddressWebView.getEngine().loadContent(shippingLabel.toHtml());
        if (shippingLabel.getCompany() != null)
            shippingAddressCompanyListView.getSelectionModel().select(shippingLabel.getCompany());
        if (shippingLabel.getContact() != null)
            shippingAddressContactListView.getSelectionModel().select(shippingLabel.getContact());
        shippingAddressAddressListView.getSelectionModel().select(shippingLabel.getAddress());
    }
}
Also used : AddressLabel(eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel) InvoiceAddressLabelWithNullableShippingAddressLabel(eu.ggnet.dwoss.customer.ui.neo.PreferedAddressLabelsController.InvoiceAddressLabelWithNullableShippingAddressLabel)

Example 8 with AddressLabel

use of eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel in project dwoss by gg-net.

the class CustomerAgentStub method store.

@Override
public Reply<Customer> store(SimpleCustomer simpleCustomer) {
    L.info("Input form Stubs: " + simpleCustomer.toString());
    // convert the SimpleCustomer to a Customer
    boolean bussines = !StringUtils.isBlank(simpleCustomer.getCompanyName());
    Customer c = new Customer();
    Contact cont = new Contact();
    cont.setFirstName(simpleCustomer.getFirstName());
    cont.setLastName(simpleCustomer.getLastName());
    cont.setSex(simpleCustomer.getSex());
    cont.setTitle(simpleCustomer.getTitle());
    // Contact with only one Address
    Address a = new Address();
    a.setCity(simpleCustomer.getCity());
    a.setIsoCountry(new Locale(simpleCustomer.getIsoCountry().toLowerCase(), simpleCustomer.getIsoCountry().toUpperCase()));
    a.setStreet(simpleCustomer.getStreet());
    a.setZipCode(simpleCustomer.getZipCode());
    cont.getAddresses().add(a);
    // one Communication form eatch type email, phone, mobile allowed
    if (simpleCustomer.getEmail() != null) {
        cont.getCommunications().add(new Communication(Type.EMAIL, simpleCustomer.getEmail()));
    }
    if (simpleCustomer.getLandlinePhone() != null) {
        cont.getCommunications().add(new Communication(Type.PHONE, simpleCustomer.getLandlinePhone()));
    }
    if (simpleCustomer.getMobilePhone() != null) {
        cont.getCommunications().add(new Communication(Type.MOBILE, simpleCustomer.getMobilePhone()));
    }
    AddressLabel al;
    if (bussines) {
        Company comp = new Company();
        comp.setName(simpleCustomer.getCompanyName());
        comp.setTaxId(simpleCustomer.getTaxId());
        // The Address of the Company Contact has to match the Company Address
        comp.getAddresses().add(a);
        comp.getContacts().add(cont);
        // build AddressLabel
        al = new AddressLabel(comp, comp.getContacts().get(0), a, AddressType.INVOICE);
        c.getCompanies().add(comp);
    } else {
        c.getContacts().add(cont);
        al = new AddressLabel(null, cont, a, AddressType.INVOICE);
    }
    c.getAddressLabels().add(al);
    c.setSource(simpleCustomer.getSource());
    if (!c.isValid())
        return Reply.failure(c.getViolationMessage());
    return Reply.success(c);
}
Also used : SimpleCustomer(eu.ggnet.dwoss.customer.ee.entity.dto.SimpleCustomer) PicoCustomer(eu.ggnet.dwoss.customer.ee.entity.projection.PicoCustomer) AddressLabel(eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel)

Example 9 with AddressLabel

use of eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel in project dwoss by gg-net.

the class PreferedAddressLabelsController method handleSaveButtonAction.

@FXML
private void handleSaveButtonAction(ActionEvent event) {
    Company invoiceLabelCompany = invoiceAddressCompanyListView.getSelectionModel().getSelectedItem();
    Contact invoiceLabelContact = invoiceAddressContactListView.getSelectionModel().getSelectedItem();
    Address invoiceLabelAddress = invoiceAddressAddressListView.getSelectionModel().getSelectedItem();
    AddressLabel invoiceLabel = new AddressLabel(invoiceLabelCompany, invoiceLabelContact, invoiceLabelAddress, AddressType.INVOICE);
    Address shippingAddress = shippingAddressAddressListView.getSelectionModel().getSelectedItem();
    Company shippingLabelCompany = shippingAddressCompanyListView.getSelectionModel().getSelectedItem();
    Contact shippingLabelContact = shippingAddressContactListView.getSelectionModel().getSelectedItem();
    AddressLabel shippingLabel;
    if (shippingAddress == null || (shippingLabelCompany == null && shippingLabelContact == null))
        shippingLabel = null;
    else
        shippingLabel = new AddressLabel(shippingLabelCompany, invoiceLabelContact, shippingAddress, SHIPPING);
    this.resultAdressLabel = new InvoiceAddressLabelWithNullableShippingAddressLabel(shippingLabel, invoiceLabel);
    Ui.closeWindowOf(saveButton);
}
Also used : AddressLabel(eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel) InvoiceAddressLabelWithNullableShippingAddressLabel(eu.ggnet.dwoss.customer.ui.neo.PreferedAddressLabelsController.InvoiceAddressLabelWithNullableShippingAddressLabel) InvoiceAddressLabelWithNullableShippingAddressLabel(eu.ggnet.dwoss.customer.ui.neo.PreferedAddressLabelsController.InvoiceAddressLabelWithNullableShippingAddressLabel) FXML(javafx.fxml.FXML)

Example 10 with AddressLabel

use of eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel in project dwoss by gg-net.

the class PreferedAddressLabelsController method initialize.

@Override
public void initialize(URL location, ResourceBundle resources) {
    saveButton.setDisable(true);
    invoiceAddressCompanyListView.setCellFactory(cb -> new CompanyListCell());
    invoiceAddressContactListView.setCellFactory(cb -> new ContactListCell());
    invoiceAddressAddressListView.setCellFactory(cb -> new AddressListCell());
    shippingAddressCompanyListView.setCellFactory(cb -> new CompanyListCell());
    shippingAddressContactListView.setCellFactory(cb -> new ContactListCell());
    shippingAddressAddressListView.setCellFactory(cb -> new AddressListCell());
    InvalidationListener invoiceWebViewListener = (Observable observable) -> {
        if (!invoiceAddressAddressListView.getSelectionModel().isEmpty()) {
            AddressLabel addressLabel = new AddressLabel(invoiceAddressCompanyListView.getSelectionModel().getSelectedItem(), invoiceAddressContactListView.getSelectionModel().getSelectedItem(), invoiceAddressAddressListView.getSelectionModel().getSelectedItem(), AddressType.INVOICE);
            invoiceAddressWebView.getEngine().loadContent(addressLabel.toHtml());
        } else
            invoiceAddressWebView.getEngine().loadContent("");
    };
    this.invoiceAddressAddressListView.getSelectionModel().selectedIndexProperty().addListener(invoiceWebViewListener);
    this.invoiceAddressCompanyListView.getSelectionModel().selectedIndexProperty().addListener(invoiceWebViewListener);
    this.invoiceAddressContactListView.getSelectionModel().selectedIndexProperty().addListener(invoiceWebViewListener);
    InvalidationListener shippingWebViewListener = (Observable observable) -> {
        if (!shippingAddressAddressListView.getSelectionModel().isEmpty()) {
            AddressLabel addressLabel = new AddressLabel(shippingAddressCompanyListView.getSelectionModel().getSelectedItem(), shippingAddressContactListView.getSelectionModel().getSelectedItem(), shippingAddressAddressListView.getSelectionModel().getSelectedItem(), AddressType.SHIPPING);
            shippingAddressWebView.getEngine().loadContent(addressLabel.toHtml());
        } else
            shippingAddressWebView.getEngine().loadContent("");
    };
    this.shippingAddressAddressListView.getSelectionModel().selectedIndexProperty().addListener(shippingWebViewListener);
    this.shippingAddressCompanyListView.getSelectionModel().selectedIndexProperty().addListener(shippingWebViewListener);
    this.shippingAddressContactListView.getSelectionModel().selectedIndexProperty().addListener(shippingWebViewListener);
    InvalidationListener saveButtonDisablingListener = (Observable observable) -> {
        boolean isInvoiceAddressValid = (!invoiceAddressAddressListView.getSelectionModel().isEmpty()) && ((!invoiceAddressCompanyListView.getSelectionModel().isEmpty()) || (!invoiceAddressContactListView.getSelectionModel().isEmpty()));
        boolean isShippingAddressValid = (shippingAddressAddressListView.getSelectionModel().isEmpty() && shippingAddressCompanyListView.getSelectionModel().isEmpty() && shippingAddressContactListView.getSelectionModel().isEmpty()) || ((!shippingAddressAddressListView.getSelectionModel().isEmpty()) && (!shippingAddressCompanyListView.getSelectionModel().isEmpty() || !shippingAddressContactListView.getSelectionModel().isEmpty()));
        if (isInvoiceAddressValid && isShippingAddressValid)
            saveButton.setDisable(false);
        else
            saveButton.setDisable(true);
    };
    invoiceAddressCompanyListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
    invoiceAddressContactListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
    invoiceAddressAddressListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
    shippingAddressCompanyListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
    shippingAddressContactListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
    shippingAddressAddressListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
}
Also used : AddressLabel(eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel) InvoiceAddressLabelWithNullableShippingAddressLabel(eu.ggnet.dwoss.customer.ui.neo.PreferedAddressLabelsController.InvoiceAddressLabelWithNullableShippingAddressLabel) InvalidationListener(javafx.beans.InvalidationListener) Observable(javafx.beans.Observable)

Aggregations

AddressLabel (eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel)20 Test (org.junit.Test)7 InvoiceAddressLabelWithNullableShippingAddressLabel (eu.ggnet.dwoss.customer.ui.neo.PreferedAddressLabelsController.InvoiceAddressLabelWithNullableShippingAddressLabel)3 SimpleCustomer (eu.ggnet.dwoss.customer.ee.entity.dto.SimpleCustomer)2 PicoCustomer (eu.ggnet.dwoss.customer.ee.entity.projection.PicoCustomer)2 CustomerGenerator (eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGenerator)1 eu.ggnet.dwoss.customer.ee.entity (eu.ggnet.dwoss.customer.ee.entity)1 Type (eu.ggnet.dwoss.customer.ee.entity.Communication.Type)1 Sex (eu.ggnet.dwoss.customer.ee.entity.Contact.Sex)1 Customer (eu.ggnet.dwoss.customer.ee.entity.Customer)1 CustomerTestUtil (eu.ggnet.dwoss.customer.test.CustomerTestUtil)1 AddressType (eu.ggnet.dwoss.rules.AddressType)1 INVOICE (eu.ggnet.dwoss.rules.AddressType.INVOICE)1 SHIPPING (eu.ggnet.dwoss.rules.AddressType.SHIPPING)1 CustomerFlag (eu.ggnet.dwoss.rules.CustomerFlag)1 Arrays (java.util.Arrays)1 Locale (java.util.Locale)1 GERMANY (java.util.Locale.GERMANY)1 InvalidationListener (javafx.beans.InvalidationListener)1 Observable (javafx.beans.Observable)1