Search in sources :

Example 1 with DocumentCollection

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));
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection)

Example 2 with DocumentCollection

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);
}
Also used : CCache(org.compiere.util.CCache) DocumentValidStatus(de.metas.ui.web.window.model.DocumentValidStatus) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection) ReasonSupplier(de.metas.ui.web.window.model.IDocumentChangesCollector.ReasonSupplier) BigDecimal(java.math.BigDecimal) Evaluatee(org.compiere.util.Evaluatee) TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) JSONDocumentFilter(de.metas.ui.web.document.filter.json.JSONDocumentFilter) ImmutableSet(com.google.common.collect.ImmutableSet) ITranslatableString(de.metas.i18n.ITranslatableString) NonNull(lombok.NonNull) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) Objects(java.util.Objects) ITrxManager(org.adempiere.ad.trx.api.ITrxManager) Services(org.adempiere.util.Services) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) List(java.util.List) Stream(java.util.stream.Stream) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) ImmutableTranslatableString(de.metas.i18n.ImmutableTranslatableString) LogManager(de.metas.logging.LogManager) Iterables(com.google.common.collect.Iterables) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) Getter(lombok.Getter) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) DocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.DocumentFilterDescriptorsProvider) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SqlOptions(de.metas.ui.web.window.model.sql.SqlOptions) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType) ExtendedMemorizingSupplier(org.adempiere.util.lang.ExtendedMemorizingSupplier) ArrayList(java.util.ArrayList) NullDocumentChangesCollector(de.metas.ui.web.window.model.NullDocumentChangesCollector) LinkedHashMap(java.util.LinkedHashMap) ImmutableList(com.google.common.collect.ImmutableList) Predicates(com.google.common.base.Predicates) DocumentFilter(de.metas.ui.web.document.filter.DocumentFilter) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) DocumentQueryOrderBy(de.metas.ui.web.window.model.DocumentQueryOrderBy) Nullable(javax.annotation.Nullable) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) Logger(org.slf4j.Logger) MoreObjects(com.google.common.base.MoreObjects) DocumentSaveStatus(de.metas.ui.web.window.model.DocumentSaveStatus) NumberUtils(org.adempiere.util.NumberUtils) AdempiereException(org.adempiere.exceptions.AdempiereException) ViewChangesCollector(de.metas.ui.web.view.event.ViewChangesCollector) ITrxManager(org.adempiere.ad.trx.api.ITrxManager) DocumentSaveStatus(de.metas.ui.web.window.model.DocumentSaveStatus) AdempiereException(org.adempiere.exceptions.AdempiereException) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) DocumentValidStatus(de.metas.ui.web.window.model.DocumentValidStatus) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection)

Example 3 with DocumentCollection

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;
}
Also used : ADProcessPostProcessService(de.metas.ui.web.process.adprocess.ADProcessPostProcessService) AdempiereException(org.adempiere.exceptions.AdempiereException) ProcessInstanceResult(de.metas.ui.web.process.ProcessInstanceResult) ViewId(de.metas.ui.web.view.ViewId) HUReportExecutorResult(de.metas.handlingunits.report.HUReportExecutorResult) HUEditorView(de.metas.ui.web.handlingunits.HUEditorView) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection) IViewsRepository(de.metas.ui.web.view.IViewsRepository)

Example 4 with DocumentCollection

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));
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection)

Aggregations

DocumentCollection (de.metas.ui.web.window.model.DocumentCollection)4 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)3 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)3 AdempiereException (org.adempiere.exceptions.AdempiereException)2 MoreObjects (com.google.common.base.MoreObjects)1 Predicates (com.google.common.base.Predicates)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables (com.google.common.collect.Iterables)1 HUReportExecutorResult (de.metas.handlingunits.report.HUReportExecutorResult)1 ITranslatableString (de.metas.i18n.ITranslatableString)1 ImmutableTranslatableString (de.metas.i18n.ImmutableTranslatableString)1 LogManager (de.metas.logging.LogManager)1 DocumentFilter (de.metas.ui.web.document.filter.DocumentFilter)1 DocumentFilterDescriptorsProvider (de.metas.ui.web.document.filter.DocumentFilterDescriptorsProvider)1 JSONDocumentFilter (de.metas.ui.web.document.filter.json.JSONDocumentFilter)1 EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)1 HUEditorView (de.metas.ui.web.handlingunits.HUEditorView)1 ProcessInstanceResult (de.metas.ui.web.process.ProcessInstanceResult)1 ADProcessPostProcessService (de.metas.ui.web.process.adprocess.ADProcessPostProcessService)1