use of ui.ex1.entity.Customer in project jmix-docs by jmix-framework.
the class CustomerServiceTest method setUp.
@BeforeEach
void setUp() {
customer1 = dataManager.create(Customer.class);
customer1.setName("Alice");
customer1.setEmail("alice@company.com");
customer1.setGrade(CustomerGrade.PLATINUM);
customer2 = dataManager.create(Customer.class);
customer2.setName("Bob");
customer2.setEmail("bob@company.com");
customer2.setGrade(CustomerGrade.GOLD);
dataManager.save(customer1, customer2);
for (int i = 1; i <= 50; i++) {
Customer customer = dataManager.create(Customer.class);
customer.setName("cust-" + Strings.padStart(String.valueOf(i), 2, '0'));
customer.setEmail("cust-" + i + "@mail.com");
customer.setGrade(i > 40 ? CustomerGrade.PLATINUM : (i > 30 ? CustomerGrade.GOLD : CustomerGrade.BRONZE));
dataManager.save(customer);
}
}
use of ui.ex1.entity.Customer in project jmix-docs by jmix-framework.
the class OrderServiceTest method setUp.
@BeforeEach
void setUp() {
Customer customer1 = dataManager.create(Customer.class);
customer1.setName("Alice");
customer1.setEmail("alice@company.com");
Product product1 = dataManager.create(Product.class);
product1.setName("MacBook Pro");
product1.setPrice(BigDecimal.valueOf(2500));
order1 = dataManager.create(Order.class);
order1.setCustomer(customer1);
order1.setDate(LocalDate.now());
order1.setAmount(BigDecimal.valueOf(5000));
OrderLine orderLine1 = dataManager.create(OrderLine.class);
orderLine1.setOrder(order1);
orderLine1.setProduct(product1);
orderLine1.setQuantity(2.0);
dataManager.save(customer1, order1, orderLine1, product1);
}
use of ui.ex1.entity.Customer in project jmix-docs by jmix-framework.
the class OrderService method saveAndReturnNothing.
// end::save-context[]
// tag::save-discard[]
void saveAndReturnNothing(List<Customer> entities) {
SaveContext saveContext = new SaveContext().setDiscardSaved(true);
for (Customer entity : entities) {
saveContext.saving(entity);
}
dataManager.save(saveContext);
}
use of ui.ex1.entity.Customer in project jmix-docs by jmix-framework.
the class CustomerEventListener method onCustomerSaving.
@EventListener
void onCustomerSaving(EntitySavingEvent<Customer> event) {
Customer customer = event.getEntity();
String encrypted = encryptionService.encrypt(customer.getSensitiveData());
customer.setEncryptedData(encrypted);
}
use of ui.ex1.entity.Customer in project jmix-docs by jmix-framework.
the class ActionScreen method onCustomersTableEdit.
// end::edit-action-performed-event[]
// tag::edit-action-performed-event-2[]
@Subscribe("customersTable.edit")
public void onCustomersTableEdit(Action.ActionPerformedEvent event) {
screenBuilders.editor(customersTable).withOpenMode(OpenMode.DIALOG).withScreenClass(CustomerEdit.class).withAfterCloseListener(afterScreenCloseEvent -> {
if (afterScreenCloseEvent.closedWith(StandardOutcome.COMMIT)) {
Customer committedCustomer = (afterScreenCloseEvent.getSource()).getEditedEntity();
System.out.println("Updated " + committedCustomer);
}
}).build().show();
}
Aggregations