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