Help with custom DataStore- Removing entity

Hi all,
Please I need your help with removing entity using custom DataStore.

I have followed the sample Jmix (external-data-sample) to replicate same thing for my project.
I am able to perform loading, creating and updating following the sample. I realise that the removing is not working. I also realise that it is not being triggered in the datastore like the others.

See the custom datastore implementation (save method)
This is expected to be triggered for all the CRUD but the Deleting is not being triggered when I click the Remove button to delete an entity. As a result, removing entity is not working.

Please advise what is wrong. It is not working for the Jmix sample project also.(jmix-samples/external-data-sample at main · jmix-framework/jmix-samples · GitHub)

Thanks in advance.

@Override
public Set<?> save(SaveContext context) {
Set savedEntities = context.getEntitiesToSave().stream()
.map(entity → businessPartnerService.save((BusinessPartner) entity))
.collect(Collectors.toSet());

    context.getEntitiesToRemove()
            .forEach(entity -> businessPartnerService.delete((BusinessPartner) entity));
    return savedEntities;
}

Hi,

It seems that standard RemoveAction doesn’t trigger the DataManager and DataStore in case of working with DTO entities. I’ve created an issue for that.

You may write your own remove action handler in the screen. For example, in Project browse of Jmix sample this action handler could look like this:

@UiController("Project.browse")
@UiDescriptor("project-browse.xml")
@LookupComponent("projectsTable")
public class ProjectBrowse extends StandardLookup<Project> {
    @Autowired
    private DataManager dataManager;
    @Autowired
    private GroupTable<Project> projectsTable;
    @Autowired
    private CollectionLoader<Project> projectsDl;

    @Subscribe("projectsTable.remove")
    public void onProjectsTableRemove(Action.ActionPerformedEvent event) {
        Project project = projectsTable.getSingleSelected();
        if (project != null) {
            dataManager.remove(project);
            projectsDl.load();
        }
    }
}

Hi gorbunkov,
Thanks. This works. Please let’s know when the standard RemoveAction is resolved for DTO entities.

Best regards