use of datamodel.ex1.entity.Customer in project jmix-docs by Haulmont.
the class CustomerEdit method onInitEntity.
@Subscribe
public void onInitEntity(InitEntityEvent<Customer> event) {
CustomerSettings customerSettings = appSettings.load(CustomerSettings.class);
CustomerGrade defaultGrade = customerSettings.getDefaultGrade();
Customer customer = event.getEntity();
customer.setGrade(defaultGrade);
}
use of datamodel.ex1.entity.Customer in project jmix-docs by Haulmont.
the class CustomerEdit method onCommitAndCloseBtnClick.
// tag::commit[]
@Subscribe("commitAndCloseBtn")
public void onCommitAndCloseBtnClick(Button.ClickEvent event) {
Customer customer = getEditedEntity();
String name = customer.getName();
Map<String, Object> params = new HashMap<>();
// <1>
params.put("customer", customer);
// <2>
params.put("name", name);
// <3>
runtimeService.startProcessInstanceByKey(// <4>
"new-customer", // <5>
params);
}
use of datamodel.ex1.entity.Customer in project jmix-docs by Haulmont.
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 datamodel.ex1.entity.Customer in project jmix-docs by Haulmont.
the class CustomerEventListener method onCustomerLoading.
@EventListener
void onCustomerLoading(EntityLoadingEvent<Customer> event) {
Customer customer = event.getEntity();
String sensitive = encryptionService.decrypt(customer.getEncryptedData());
customer.setSensitiveData(sensitive);
}
use of datamodel.ex1.entity.Customer in project jmix-docs by Haulmont.
the class CustomerEventListener method registerGradeChange.
private void registerGradeChange(Id<Customer> customerId, CustomerGrade oldGrade) {
// <5>
Customer customer = dataManager.load(customerId).one();
CustomerGradeChange gradeChange = dataManager.create(CustomerGradeChange.class);
gradeChange.setCustomer(customer);
gradeChange.setOldGrade(oldGrade);
gradeChange.setNewGrade(customer.getGrade());
dataManager.save(gradeChange);
}
Aggregations