Search in sources :

Example 16 with Customer

use of dataaccess.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);
}
Also used : Customer(appsettings.ex1.entity.Customer) CustomerSettings(appsettings.ex1.entity.CustomerSettings) CustomerGrade(appsettings.ex1.entity.CustomerGrade)

Example 17 with Customer

use of dataaccess.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);
}
Also used : Customer(bpm.ex1.entity.Customer) HashMap(java.util.HashMap)

Example 18 with Customer

use of dataaccess.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);
    }
}
Also used : Customer(dataaccess.ex1.entity.Customer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 19 with Customer

use of dataaccess.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);
}
Also used : Customer(dataaccess.ex1.entity.Customer) TransactionalEventListener(org.springframework.transaction.event.TransactionalEventListener) EventListener(org.springframework.context.event.EventListener)

Example 20 with Customer

use of dataaccess.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);
}
Also used : Customer(dataaccess.ex1.entity.Customer) CustomerGradeChange(dataaccess.ex1.entity.CustomerGradeChange)

Aggregations

Customer (ui.ex1.entity.Customer)34 Customer (dataaccess.ex1.entity.Customer)25 BeforeEach (org.junit.jupiter.api.BeforeEach)10 Test (org.junit.jupiter.api.Test)10 Autowired (org.springframework.beans.factory.annotation.Autowired)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)10 CustomerEdit (ui.ex1.screen.entity.customer.CustomerEdit)10 Action (io.jmix.ui.action.Action)8 BaseAction (io.jmix.ui.action.BaseAction)8 io.jmix.ui.screen (io.jmix.ui.screen)8 Named (javax.inject.Named)8 Order (dataaccess.ex1.entity.Order)7 Metadata (io.jmix.core.Metadata)6 ParamsMap (io.jmix.core.common.util.ParamsMap)6 Notifications (io.jmix.ui.Notifications)6 ScreenBuilders (io.jmix.ui.ScreenBuilders)6 DialogAction (io.jmix.ui.action.DialogAction)6 io.jmix.ui.component (io.jmix.ui.component)6 BigDecimal (java.math.BigDecimal)6 TransactionalEventListener (org.springframework.transaction.event.TransactionalEventListener)6