Search in sources :

Example 21 with Customer

use of ui.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 22 with Customer

use of ui.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)

Example 23 with Customer

use of ui.ex1.entity.Customer in project jmix-docs by Haulmont.

the class CustomerService method createCustomer.

// end::transaction-template-inject[]
// tag::transaction-template-without-result[]
public void createCustomer() {
    transactionTemplate.executeWithoutResult(status -> {
        Customer customer = dataManager.create(Customer.class);
        customer.setName("Alice");
        dataManager.save(customer);
    });
}
Also used : Customer(dataaccess.ex1.entity.Customer)

Example 24 with Customer

use of ui.ex1.entity.Customer in project jmix-docs by Haulmont.

the class ActionScreen method onInit.

// end::inject-sayHelloBtn[]
// tag::on-init-start[]
@Subscribe
public void onInit(InitEvent event) {
    // end::on-init-start[]
    // tag::create-action-set[]
    createAction.setOpenMode(OpenMode.DIALOG);
    createAction.setScreenClass(CustomerEdit.class);
    // end::create-action-set[]
    // tag::edit-action-set[]
    editAction.setOpenMode(OpenMode.DIALOG);
    editAction.setScreenClass(CustomerEdit.class);
    // end::edit-action-set[]
    // tag::bulk-action-set[]
    custTableBulk.setOpenMode(OpenMode.THIS_TAB);
    custTableBulk.setIncludeProperties(Arrays.asList("rewardPoints", "email"));
    custTableBulk.setColumnsMode(ColumnsMode.ONE_COLUMN);
    // end::bulk-action-set[]
    // tag::remove-action-set[]
    removeAction.setConfirmation(true);
    removeAction.setConfirmationTitle("Removing customer...");
    removeAction.setConfirmationMessage("Do you really want to remove the customer?");
    // end::remove-action-set[]
    // tag::view-action-set[]
    viewAction.setOpenMode(OpenMode.DIALOG);
    viewAction.setScreenClass(CustomerEdit.class);
    // end::view-action-set[]
    // tag::tagLookup-action-set[]
    tagLookupAction.setOpenMode(OpenMode.DIALOG);
    tagLookupAction.setScreenClass(CustomerBrowse.class);
    // end::tagLookup-action-set[]
    // tag::base-action-button[]
    sayHelloBtn.setAction(new BaseAction("hello") {

        @Override
        public boolean isPrimary() {
            return true;
        }

        @Override
        public void actionPerform(Component component) {
            notifications.create().withCaption("Hello!").withType(Notifications.NotificationType.TRAY).show();
        }
    });
    sayGoodbyeBtn.setAction(new BaseAction("goodbye").withPrimary(true).withHandler(e -> notifications.create().withCaption("Goodbye!").withType(Notifications.NotificationType.TRAY).show()));
// end::base-action-button[]
// tag::on-init-end[]
}
Also used : CollectionLoader(io.jmix.ui.model.CollectionLoader) java.util(java.util) Customer(ui.ex1.entity.Customer) BulkEditors(io.jmix.ui.bulk.BulkEditors) Dialogs(io.jmix.ui.Dialogs) io.jmix.ui.action.list(io.jmix.ui.action.list) TagLookupAction(io.jmix.ui.action.tagpicker.TagLookupAction) Autowired(org.springframework.beans.factory.annotation.Autowired) Metadata(io.jmix.core.Metadata) ParamsMap(io.jmix.core.common.util.ParamsMap) CustomerEdit(ui.ex1.screen.entity.customer.CustomerEdit) ColumnsMode(io.jmix.ui.app.bulk.ColumnsMode) Notifications(io.jmix.ui.Notifications) io.jmix.ui.screen(io.jmix.ui.screen) ScreenBuilders(io.jmix.ui.ScreenBuilders) CustomerBrowse(ui.ex1.screen.entity.customer.CustomerBrowse) RemoveOperation(io.jmix.ui.RemoveOperation) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) Named(javax.inject.Named) MetaProperty(io.jmix.core.metamodel.model.MetaProperty) DialogAction(io.jmix.ui.action.DialogAction) io.jmix.ui.component(io.jmix.ui.component) BaseAction(io.jmix.ui.action.BaseAction)

Example 25 with Customer

use of ui.ex1.entity.Customer in project jmix-docs by Haulmont.

the class DataManagerResourceTest method setUp.

@BeforeEach
void setUp() {
    Customer customer = dataManager.create(Customer.class);
    customer.setName("test-customer-1");
    customer.setConfidentialInfo("111");
    authenticator.withSystem(() -> dataManager.save(customer));
    customerId = customer.getId();
}
Also used : Customer(security.ex1.entity.Customer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

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