use of de.metas.ui.web.window.model.DocumentCollection in project metasfresh-webui-api by metasfresh.
the class DefaultView method getFieldDropdown.
@Override
public LookupValuesList getFieldDropdown(final RowEditingContext ctx, final String fieldName) {
final DocumentId rowId = ctx.getRowId();
final DocumentCollection documentsCollection = ctx.getDocumentsCollection();
final DocumentPath documentPath = getById(rowId).getDocumentPath();
return documentsCollection.forDocumentReadonly(documentPath, document -> document.getFieldLookupValues(fieldName));
}
use of de.metas.ui.web.window.model.DocumentCollection in project metasfresh-webui-api by metasfresh.
the class DefaultView method patchViewRow.
@Override
public void patchViewRow(final RowEditingContext ctx, final List<JSONDocumentChangedEvent> fieldChangeRequests) {
final DocumentId rowId = ctx.getRowId();
final DocumentCollection documentsCollection = ctx.getDocumentsCollection();
final DocumentPath documentPath = getById(rowId).getDocumentPath();
Services.get(ITrxManager.class).runInThreadInheritedTrx(() -> documentsCollection.forDocumentWritable(documentPath, NullDocumentChangesCollector.instance, document -> {
//
// Process changes and the save the document
document.processValueChanges(fieldChangeRequests, ReasonSupplier.NONE);
document.saveIfValidAndHasChanges();
//
// Important: before allowing the document to be stored back in documents collection,
// we need to make sure it's valid and saved.
final DocumentValidStatus validStatus = document.getValidStatus();
if (!validStatus.isValid()) {
throw new AdempiereException(validStatus.getReason());
}
final DocumentSaveStatus saveStatus = document.getSaveStatus();
if (saveStatus.isNotSaved()) {
throw new AdempiereException(saveStatus.getReason());
}
// nothing/not important
return null;
}));
invalidateRowById(rowId);
ViewChangesCollector.getCurrentOrAutoflush().collectRowChanged(this, rowId);
documentsCollection.invalidateRootDocument(documentPath);
}
use of de.metas.ui.web.window.model.DocumentCollection in project metasfresh-webui-api by metasfresh.
the class HUReportProcessInstance method startProcess.
@Override
public synchronized ProcessInstanceResult startProcess(@NonNull final ProcessExecutionContext context) {
final int numberOfCopies = getCopies();
if (numberOfCopies <= 0) {
throw new AdempiereException("@" + PARAM_Copies + "@ > 0");
}
final IViewsRepository viewsRepo = context.getViewsRepo();
final DocumentCollection documentsCollection = context.getDocumentsCollection();
final ViewId viewId = viewRowIdsSelection.getViewId();
final HUEditorView view = HUEditorView.cast(viewsRepo.getView(viewId));
final HUReportExecutorResult reportExecutorResult = HUReportExecutor.newInstance(context.getCtx()).numberOfCopies(numberOfCopies).printPreview(true).executeNow(reportADProcessId, extractHUsToReport(view));
final ADProcessPostProcessService postProcessService = ADProcessPostProcessService.builder().viewsRepo(viewsRepo).documentsCollection(documentsCollection).build();
final ProcessInstanceResult result = postProcessService.postProcess(ADProcessPostProcessRequest.builder().viewId(viewId).processInfo(reportExecutorResult.getProcessInfo()).processExecutionResult(reportExecutorResult.getProcessExecutionResult()).instanceIdOverride(instanceId).build());
return lastExecutionResult = result;
}
use of de.metas.ui.web.window.model.DocumentCollection in project metasfresh-webui-api by metasfresh.
the class DefaultView method getFieldTypeahead.
@Override
public LookupValuesList getFieldTypeahead(final RowEditingContext ctx, final String fieldName, final String query) {
final DocumentId rowId = ctx.getRowId();
final DocumentCollection documentsCollection = ctx.getDocumentsCollection();
final DocumentPath documentPath = getById(rowId).getDocumentPath();
return documentsCollection.forDocumentReadonly(documentPath, document -> document.getFieldLookupValuesForQuery(fieldName, query));
}
Aggregations