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;
}
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());
}
}
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);
}
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);
}
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);
}
Aggregations