use of io.jmix.core.SaveContext in project jmix-sneferu by mariodavid.
the class DatabaseCleanup method removeAllEntities.
public <T> void removeAllEntities(Class<T> entityClass) {
SaveContext removeContext = new SaveContext();
systemAuthenticator.withSystem(() -> {
dataManager.load(entityClass).all().list().forEach(removeContext::removing);
dataManager.save(removeContext);
return null;
});
}
use of io.jmix.core.SaveContext in project jmix-sneferu by mariodavid.
the class VisitTestDataCreation method commit.
private int commit(List<Visit> visits) {
SaveContext saveContext = new SaveContext();
visits.forEach(dataManager::save);
dataManager.save(saveContext);
return visits.size();
}
use of io.jmix.core.SaveContext in project jmix-docs by Haulmont.
the class CustomerEventListener method emailCustomerTheirNewGrade.
// end::after-commit[]
private void emailCustomerTheirNewGrade(String customerEmail, CustomerGrade grade) {
SentEmail entity = dataManager.create(SentEmail.class);
entity.setEmailedTo(customerEmail);
// tag::save-after-commit[]
dataManager.save(new SaveContext().saving(entity).setJoinTransaction(false));
// end::save-after-commit[]
}
use of io.jmix.core.SaveContext in project jmix by jmix-framework.
the class DynAttrLifecycleListener method entityReload.
@Override
public void entityReload(DataStoreEntityReloadEvent event) {
LoadContext<?> loadContext = event.getLoadContext();
SaveContext saveContext = event.getSaveContext();
Object entity = saveContext.getEntitiesToSave().stream().filter(e -> Objects.equals(EntityValues.getId(e), loadContext.getId())).findFirst().orElse(null);
DynamicAttributesState state = getExtraState(entity, DynamicAttributesState.class);
if (state != null) {
DynamicAttributes dynamicAttributes = state.getDynamicAttributes();
if (dynamicAttributes != null) {
loadContext.setHint(DynAttrQueryHints.LOAD_DYN_ATTR, true);
}
}
}
use of io.jmix.core.SaveContext in project jmix by jmix-framework.
the class ImapDataProvider method saveAttachments.
public void saveAttachments(ImapMessage msg, Collection<ImapMessageAttachment> attachments) {
SaveContext saveContext = new SaveContext();
FetchPlan fetchPlan = fetchPlanRepository.getFetchPlan(ImapMessageAttachment.class, "imap-msg-attachment-full");
attachments.forEach(attachment -> {
attachment.setImapMessage(msg);
saveContext.saving(attachment, fetchPlan);
});
msg.setAttachmentsLoaded(true);
saveContext.saving(msg, fetchPlanRepository.getFetchPlan(ImapMessage.class, "imap-msg-full"));
dataManager.save(saveContext);
}
Aggregations