use of de.metas.ui.web.view.CreateViewRequest in project metasfresh-webui-api by metasfresh.
the class ADProcessPostProcessService method createViewRequest.
private static final CreateViewRequest createViewRequest(final RecordsToOpen recordsToOpen, final Set<DocumentPath> referencingDocumentPaths, final ViewId parentViewId) {
final List<TableRecordReference> recordRefs = recordsToOpen.getRecords();
if (recordRefs.isEmpty()) {
// shall not happen
return null;
}
// optional
final WindowId windowId_Override = WindowId.fromNullableJson(recordsToOpen.getWindowIdString());
//
// Create view create request builders from current records
final Map<WindowId, CreateViewRequest.Builder> viewRequestBuilders = new HashMap<>();
for (final TableRecordReference recordRef : recordRefs) {
final WindowId recordWindowId = windowId_Override != null ? windowId_Override : WindowId.ofIntOrNull(RecordZoomWindowFinder.findAD_Window_ID(recordRef));
final CreateViewRequest.Builder viewRequestBuilder = viewRequestBuilders.computeIfAbsent(recordWindowId, key -> CreateViewRequest.builder(recordWindowId, JSONViewDataType.grid));
viewRequestBuilder.addFilterOnlyId(recordRef.getRecord_ID());
}
// If there is no view create request builder there stop here (shall not happen)
if (viewRequestBuilders.isEmpty()) {
return null;
}
// Create the view create request from first builder that we have.
if (viewRequestBuilders.size() > 1) {
logger.warn("More than one views to be created found for {}. Creating only the first view.", recordRefs);
}
final CreateViewRequest viewRequest = viewRequestBuilders.values().iterator().next().setReferencingDocumentPaths(referencingDocumentPaths).setParentViewId(parentViewId).build();
return viewRequest;
}
use of de.metas.ui.web.view.CreateViewRequest in project metasfresh-webui-api by metasfresh.
the class ADProcessPostProcessService method createResultAction.
private ResultAction createResultAction(final ProcessInfo processInfo, final ProcessExecutionResult processExecutionResult) {
final File reportTempFile = saveReportToDiskIfAny(processExecutionResult);
final RecordsToOpen recordsToOpen = processExecutionResult.getRecordsToOpen();
// Open report
if (reportTempFile != null) {
return OpenReportAction.builder().filename(processExecutionResult.getReportFilename()).contentType(processExecutionResult.getReportContentType()).tempFile(reportTempFile).build();
} else // Open view
if (recordsToOpen != null && recordsToOpen.getTarget() == OpenTarget.GridView) {
final Set<DocumentPath> referencingDocumentPaths = extractReferencingDocumentPaths(processInfo);
final String parentViewIdStr = processExecutionResult.getWebuiViewId();
final ViewId parentViewId = parentViewIdStr != null ? ViewId.ofViewIdString(parentViewIdStr) : null;
final CreateViewRequest viewRequest = createViewRequest(recordsToOpen, referencingDocumentPaths, parentViewId);
final IView view = viewsRepo.createView(viewRequest);
return OpenViewAction.builder().viewId(view.getViewId()).build();
} else // Open included view
if (processExecutionResult.getWebuiIncludedViewIdToOpen() != null) {
return OpenIncludedViewAction.builder().viewId(ViewId.ofViewIdString(processExecutionResult.getWebuiIncludedViewIdToOpen())).profileId(ViewProfileId.fromJson(processExecutionResult.getWebuiViewProfileId())).build();
} else // Open single document
if (recordsToOpen != null && recordsToOpen.getTarget() == OpenTarget.SingleDocument) {
final DocumentPath documentPath = extractSingleDocumentPath(recordsToOpen);
return OpenSingleDocument.builder().documentPath(documentPath).modal(false).build();
} else // Open single document
if (recordsToOpen != null && recordsToOpen.getTarget() == OpenTarget.SingleDocumentModal) {
final DocumentPath documentPath = extractSingleDocumentPath(recordsToOpen);
return OpenSingleDocument.builder().documentPath(documentPath).modal(true).build();
} else //
// No action
{
return null;
}
}
use of de.metas.ui.web.view.CreateViewRequest in project metasfresh-webui-api by metasfresh.
the class HUEditorViewFactoryTemplate method createView.
@Override
public final HUEditorView createView(final CreateViewRequest request) {
final ViewId viewId = request.getViewId();
//
// Referencing documentPaths and tableName (i.e. from where are we coming, e.g. receipt schedule)
final Set<DocumentPath> referencingDocumentPaths = request.getReferencingDocumentPaths();
final String referencingTableName = extractReferencingTablename(referencingDocumentPaths);
final SqlViewBinding sqlViewBinding = getSqlViewBinding();
//
// HUEditorView rows repository
final HUEditorViewRepository huEditorViewRepository;
{
final WindowId windowId = viewId.getWindowId();
final boolean attributesAlwaysReadonly = rowAttributesAlwaysReadonlyByReferencingTableName.getOrDefault(referencingTableName, Boolean.TRUE);
final SqlHUEditorViewRepositoryBuilder huEditorViewRepositoryBuilder = SqlHUEditorViewRepository.builder().windowId(windowId).rowProcessedPredicate(getRowProcessedPredicate(referencingTableName)).attributesProvider(HUEditorRowAttributesProvider.builder().readonly(attributesAlwaysReadonly).build()).sqlViewBinding(sqlViewBinding);
customizeHUEditorViewRepository(huEditorViewRepositoryBuilder);
huEditorViewRepository = huEditorViewRepositoryBuilder.build();
}
//
// HUEditorView
{
// Filters
// as long as the deprecated getFilterOnlyIds() is around we can't ignore it
@SuppressWarnings("deprecation") final List<DocumentFilter> stickyFilters = extractStickyFilters(request.getStickyFilters(), request.getFilterOnlyIds());
final DocumentFilterDescriptorsProvider filterDescriptors = getViewFilterDescriptors();
final List<DocumentFilter> filters = request.getOrUnwrapFilters(filterDescriptors);
// Start building the HUEditorView
final HUEditorViewBuilder huViewBuilder = HUEditorView.builder().setParentViewId(request.getParentViewId()).setParentRowId(request.getParentRowId()).setViewId(viewId).setViewType(request.getViewType()).setStickyFilters(stickyFilters).setFilters(filters).setFilterDescriptors(filterDescriptors).setReferencingDocumentPaths(referencingTableName, referencingDocumentPaths).orderBys(sqlViewBinding.getDefaultOrderBys()).setActions(request.getActions()).addAdditionalRelatedProcessDescriptors(request.getAdditionalRelatedProcessDescriptors()).setHUEditorViewRepository(huEditorViewRepository).setParameters(request.getParameters());
//
// Call view customizers
getViewCustomizers(referencingTableName).forEach(viewCustomizer -> viewCustomizer.beforeCreate(huViewBuilder));
customizeHUEditorView(huViewBuilder);
return huViewBuilder.build();
}
}
use of de.metas.ui.web.view.CreateViewRequest in project metasfresh-webui-api by metasfresh.
the class PackingHUsViewFactory method createPackingHUsView.
private HUEditorView createPackingHUsView(final PackingHUsViewKey key) {
final IHUQueryBuilder huQuery = createHUQuery(key);
final ViewId packingHUsViewId = key.getPackingHUsViewId();
final ViewId pickingSlotsClearingViewId = key.getPickingSlotsClearingViewId();
final CreateViewRequest request = CreateViewRequest.builder(packingHUsViewId, JSONViewDataType.includedView).setParentViewId(pickingSlotsClearingViewId).addStickyFilters(HUIdsFilterHelper.createFilter(huQuery)).addAdditionalRelatedProcessDescriptor(createProcessDescriptor(WEBUI_PackingHUsView_AddHUsToShipperTransportation.class)).addAdditionalRelatedProcessDescriptor(createProcessDescriptor(WEBUI_PackingHUsView_AddHUsToShipperTransportationShipAndInvoice.class)).setParameter(WEBUI_M_HU_Transform.PARAM_CheckExistingHUsInsideView, true).build();
return huEditorViewFactory.createView(request);
}
use of de.metas.ui.web.view.CreateViewRequest in project metasfresh-webui-api by metasfresh.
the class PickingSlotsClearingViewFactory method createView.
@Override
public PickingSlotsClearingView createView(final CreateViewRequest request) {
request.assertNoParentViewOrRow();
final DocumentFilterDescriptorsProvider filterDescriptors = getFilterDescriptorsProvider();
final CreateViewRequest requestEffective = request.unwrapFiltersAndCopy(filterDescriptors);
final ViewId viewId = ViewId.random(PickingSlotsClearingViewFactory.WINDOW_ID);
final PickingSlotQuery query = createPickingSlotQuery(requestEffective);
return PickingSlotsClearingView.builder().viewId(viewId).rows(() -> pickingSlotRepo.retrievePickingSlotsRows(query)).additionalRelatedProcessDescriptors(createAdditionalRelatedProcessDescriptors()).filterDescriptors(filterDescriptors).filters(requestEffective.getFilters().getFilters()).build();
}
Aggregations