Search in sources :

Example 6 with MandatorMetadata

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

the class MandatorMetaDataController method initialize.

@Override
public void initialize(URL location, ResourceBundle resources) {
    CustomerGenerator gen = new CustomerGenerator();
    MandatorMetadata m = gen.makeMandatorMetadata();
    defaultCustomerSalesdata = new DefaultCustomerSalesdata(m.getShippingCondition(), m.getPaymentCondition(), m.getPaymentMethod(), m.getAllowedSalesChannels(), new ArrayList(m.getAllowedSalesChannels()));
    this.setDefaultValues(defaultCustomerSalesdata);
    saveButton.setDisable(true);
    shippingConditionComboBox.getItems().setAll(ShippingCondition.values());
    paymentConditionComboBox.getItems().setAll(PaymentCondition.values());
    paymentMethodComboBox.getItems().setAll(PaymentMethod.values());
    shippingConditionComboBox.setConverter(new StringConverter<ShippingCondition>() {

        @Override
        public ShippingCondition fromString(String string) {
            throw new UnsupportedOperationException("fromString is not supported");
        }

        @Override
        public String toString(ShippingCondition myClassinstance) {
            return myClassinstance.toString();
        }
    });
    paymentConditionComboBox.setConverter(new StringConverter<PaymentCondition>() {

        @Override
        public PaymentCondition fromString(String string) {
            throw new UnsupportedOperationException("fromString is not supported");
        }

        @Override
        public String toString(PaymentCondition myClassinstance) {
            return myClassinstance.getNote();
        }
    });
    paymentMethodComboBox.setConverter(new StringConverter<PaymentMethod>() {

        @Override
        public PaymentMethod fromString(String string) {
            throw new UnsupportedOperationException("fromString is not supported");
        }

        @Override
        public String toString(PaymentMethod myClassinstance) {
            return myClassinstance.getNote();
        }
    });
    paymentConditionComboBox.setCellFactory(new Callback<ListView<PaymentCondition>, ListCell<PaymentCondition>>() {

        @Override
        public ListCell<PaymentCondition> call(ListView<PaymentCondition> l) {
            return new ListCell<PaymentCondition>() {

                @Override
                public String toString() {
                    return this.toString();
                }

                @Override
                protected void updateItem(PaymentCondition item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item == null || empty) {
                        setGraphic(null);
                    } else {
                        setText(item.getNote());
                    }
                }
            };
        }
    });
    paymentMethodComboBox.setCellFactory((ListView<PaymentMethod> l) -> new ListCell<PaymentMethod>() {

        @Override
        protected void updateItem(PaymentMethod item, boolean empty) {
            super.updateItem(item, empty);
            if (item == null || empty) {
                setGraphic(null);
            } else {
                setText(item.getNote());
            }
        }
    });
    InvalidationListener saveButtonDisablingListener = new InvalidationListener() {

        @Override
        public void invalidated(javafx.beans.Observable observable) {
            if (shippingConditionComboBox.getSelectionModel().isEmpty() && paymentConditionComboBox.getSelectionModel().isEmpty() && paymentMethodComboBox.getSelectionModel().isEmpty() && allowedSalesChannelCheckBoxList.stream().noneMatch(CheckBox::isSelected))
                saveButton.setDisable(true);
            else
                saveButton.setDisable(false);
        }
    };
    shippingConditionComboBox.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
    paymentConditionComboBox.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
    paymentMethodComboBox.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
    allowedSalesChannelCheckBoxList.forEach(e -> e.selectedProperty().addListener(saveButtonDisablingListener));
}
Also used : MandatorMetadata(eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata) DefaultCustomerSalesdata(eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata) CustomerGenerator(eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGenerator) InvalidationListener(javafx.beans.InvalidationListener)

Example 7 with MandatorMetadata

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

the class MandatorMetaDataTryOut method randomTryOut.

private static void randomTryOut() {
    CustomerGenerator gen = new CustomerGenerator();
    MandatorMetadata mData = gen.makeMandatorMetadata();
    Ui.exec(() -> {
        Ui.build().fxml().eval(() -> mData, MandatorMetaDataController.class);
    });
}
Also used : MandatorMetadata(eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata) CustomerGenerator(eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGenerator)

Example 8 with MandatorMetadata

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

the class MandatorMetadataTest method testGetViolationMessagesNonValidPaymentCondition.

@Test
public void testGetViolationMessagesNonValidPaymentCondition() {
    MandatorMetadata makeInValidMandatorMetadata = makeValidMandatorMetadata();
    makeInValidMandatorMetadata.setPaymentCondition(null);
    assertThat(makeInValidMandatorMetadata.getViolationMessage()).as("MandatorMetadata without PaymentCondition").isNotBlank();
}
Also used : MandatorMetadata(eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata) Test(org.junit.Test)

Example 9 with MandatorMetadata

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

the class MandatorMetadataTest method testGetViolationMessagesNonSalesChannels.

@Test
public void testGetViolationMessagesNonSalesChannels() {
    MandatorMetadata makeInValidMandatorMetadata = makeValidMandatorMetadata();
    makeInValidMandatorMetadata.clearSalesChannels();
    assertThat(makeInValidMandatorMetadata.getViolationMessage()).as("MandatorMetadata without Allowed Sales Channels").isNotBlank();
}
Also used : MandatorMetadata(eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata) Test(org.junit.Test)

Example 10 with MandatorMetadata

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

the class MandatorMetadataTest method testGetViolationMessages.

@Test
public void testGetViolationMessages() {
    MandatorMetadata makeValidMandatorMetadata = makeValidMandatorMetadata();
    assertThat(makeValidMandatorMetadata.getViolationMessage()).as("MandatorMetadata with valid values").isNull();
}
Also used : MandatorMetadata(eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata) Test(org.junit.Test)

Aggregations

MandatorMetadata (eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata)10 Test (org.junit.Test)6 CustomerGenerator (eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGenerator)3 Customer (eu.ggnet.dwoss.customer.ee.entity.Customer)2 DefaultCustomerSalesdata (eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata)2 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 OldCustomer (eu.ggnet.dwoss.customer.ee.priv.OldCustomer)1 InvalidationListener (javafx.beans.InvalidationListener)1 Scene (javafx.scene.Scene)1 BorderPane (javafx.scene.layout.BorderPane)1 WebView (javafx.scene.web.WebView)1