Search in sources :

Example 1 with DefaultCustomerSalesdata

use of eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata in project dwoss by gg-net.

the class RedTapeTryout method main.

public static void main(String[] args) {
    Dl.local().add(RemoteLookup.class, new RemoteLookup() {

        @Override
        public <T> boolean contains(Class<T> clazz) {
            return false;
        }

        @Override
        public <T> T lookup(Class<T> clazz) {
            return null;
        }
    });
    Dl.remote().add(RedTapeAgent.class, new RedTapeAgentStub());
    Dl.remote().add(RedTapeWorker.class, new RedTapeWorkerStub());
    Dl.remote().add(UniversalSearcher.class, new UniversalSearcherStub());
    Dl.remote().add(CustomerService.class, new CustomerServiceStub());
    Dl.remote().add(DocumentSupporter.class, new DocumentSupporter() {

        @Override
        public void mail(Document document, DocumentViewType jtype) throws UserInfoException, RuntimeException {
            System.out.println("Mailing " + document);
        }

        @Override
        public JasperPrint render(Document document, DocumentViewType viewType) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public Dossier briefed(Document detached, String arranger) {
            detached.add(Document.Flag.CUSTOMER_BRIEFED);
            detached.add(Document.Flag.CUSTOMER_EXACTLY_BRIEFED);
            return detached.getDossier();
        }

        @Override
        public FileJacket toXls(String identifier) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    Dl.local().add(Guardian.class, new AbstractGuardian() {

        @Override
        public void login(String user, char[] pass) throws AuthenticationException {
            setRights(new Operator(user, 1, Arrays.asList(AtomicRight.values())));
        }
    });
    Dl.remote().add(StockAgent.class, null);
    Dl.remote().add(UniqueUnitAgent.class, null);
    // Dl.remote().add(LegacyRemoteBridge.class, null);
    Dl.remote().add(ShippingCostService.class, null);
    Mandators mandatorSupporterMock = mock(Mandators.class);
    when(mandatorSupporterMock.loadSalesdata()).thenReturn(new DefaultCustomerSalesdata(ShippingCondition.DEFAULT, PaymentCondition.CUSTOMER, PaymentMethod.DIRECT_DEBIT, Arrays.asList(SalesChannel.CUSTOMER, SalesChannel.RETAILER), null));
    Dl.remote().add(Mandators.class, mandatorSupporterMock);
    CustomerUpi ccos = mock(CustomerUpi.class);
    when(ccos.createCustomer(any())).thenReturn(0L);
    when(ccos.updateCustomer(any(), anyLong())).thenReturn(true);
    Dl.local().add(CustomerUpi.class, ccos);
    UiCore.startSwing(() -> new JLabel("Main Applikation"));
    Ui.exec(() -> {
        Ui.build().swing().show(() -> RedTapeController.build().getView());
    });
}
Also used : Operator(eu.ggnet.dwoss.rights.api.Operator) DocumentViewType(eu.ggnet.dwoss.mandator.api.DocumentViewType) AuthenticationException(eu.ggnet.saft.core.auth.AuthenticationException) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) FileJacket(eu.ggnet.dwoss.util.FileJacket) CustomerUpi(eu.ggnet.dwoss.customer.upi.CustomerUpi) JasperPrint(net.sf.jasperreports.engine.JasperPrint) JLabel(javax.swing.JLabel) DefaultCustomerSalesdata(eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata) AbstractGuardian(eu.ggnet.dwoss.common.AbstractGuardian) RemoteLookup(eu.ggnet.saft.core.cap.RemoteLookup) Mandators(eu.ggnet.dwoss.mandator.Mandators) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) UserInfoException(eu.ggnet.dwoss.util.UserInfoException)

Example 2 with DefaultCustomerSalesdata

use of eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata in project dwoss by gg-net.

the class CustomerHtmlTryout method start.

@Override
public void start(Stage primaryStage) throws Exception {
    CustomerGenerator gen = new CustomerGenerator();
    Customer c1 = gen.makeOldCustomer();
    Customer c2 = gen.makeCustomer();
    DefaultCustomerSalesdata defaults = DefaultCustomerSalesdata.builder().allowedSalesChannels(EnumSet.of(SalesChannel.CUSTOMER)).paymentCondition(PaymentCondition.CUSTOMER).shippingCondition(ShippingCondition.DEALER_ONE).paymentMethod(PaymentMethod.DIRECT_DEBIT).build();
    String MATCHCODE = c1.getMandatorMetadata().stream().map(MandatorMetadata::getMandatorMatchcode).findFirst().orElse("NONE");
    OldCustomer c0 = ConverterUtil.convert(c1, MATCHCODE, defaults);
    WebView view = new WebView();
    view.getEngine().loadContent(Css.toHtml5WithStyle("<h1>OldCustomer.toHtml()</h1>" + c0.toHtmlHighDetailed() + "<hr /><h1>makeOldCustmer : Customer.toHtml(MATCHCODE,defaults)</h1>" + c1.toHtml(MATCHCODE, defaults) + "<hr /><h1>makeOldCustmer : Customer.toHtml()</h1>" + c1.toHtml() + "<hr /><h1>makeCustmer : Customer.toHtml()</h1>" + c2.toHtml()));
    primaryStage.setScene(new Scene(new BorderPane(view)));
    primaryStage.sizeToScene();
    primaryStage.show();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) OldCustomer(eu.ggnet.dwoss.customer.ee.priv.OldCustomer) Customer(eu.ggnet.dwoss.customer.ee.entity.Customer) OldCustomer(eu.ggnet.dwoss.customer.ee.priv.OldCustomer) 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) WebView(javafx.scene.web.WebView) Scene(javafx.scene.Scene)

Example 3 with DefaultCustomerSalesdata

use of eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata 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)

Aggregations

DefaultCustomerSalesdata (eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata)3 CustomerGenerator (eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGenerator)2 MandatorMetadata (eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata)2 AbstractGuardian (eu.ggnet.dwoss.common.AbstractGuardian)1 Customer (eu.ggnet.dwoss.customer.ee.entity.Customer)1 OldCustomer (eu.ggnet.dwoss.customer.ee.priv.OldCustomer)1 CustomerUpi (eu.ggnet.dwoss.customer.upi.CustomerUpi)1 Mandators (eu.ggnet.dwoss.mandator.Mandators)1 DocumentViewType (eu.ggnet.dwoss.mandator.api.DocumentViewType)1 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)1 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)1 Operator (eu.ggnet.dwoss.rights.api.Operator)1 FileJacket (eu.ggnet.dwoss.util.FileJacket)1 UserInfoException (eu.ggnet.dwoss.util.UserInfoException)1 AuthenticationException (eu.ggnet.saft.core.auth.AuthenticationException)1 RemoteLookup (eu.ggnet.saft.core.cap.RemoteLookup)1 InvalidationListener (javafx.beans.InvalidationListener)1 Scene (javafx.scene.Scene)1 BorderPane (javafx.scene.layout.BorderPane)1 WebView (javafx.scene.web.WebView)1