use of de.metas.ui.web.window.datatypes.DocumentIdsSelection in project metasfresh-webui-api by metasfresh.
the class MD_Cockpit_DocumentDetail_Display method retrieveCockpitRecordIds.
private ImmutableSet<Integer> retrieveCockpitRecordIds() {
final MaterialCockpitView materialCockpitView = (MaterialCockpitView) getView();
final DocumentIdsSelection selectedRowIds = getSelectedRowIds();
final ImmutableSet<Integer> cockpitRowIds = selectedRowIds.stream().map(rowId -> {
return materialCockpitView.getById(rowId);
}).flatMap(row -> {
return row.getAllIncludedCockpitRecordIds().stream();
}).collect(ImmutableSet.toImmutableSet());
return cockpitRowIds;
}
use of de.metas.ui.web.window.datatypes.DocumentIdsSelection in project metasfresh-webui-api by metasfresh.
the class WEBUI_HUsToPick_PickCU method checkPreconditionsApplicable.
@Override
public ProcessPreconditionsResolution checkPreconditionsApplicable() {
final DocumentIdsSelection selectedRowIds = getSelectedRowIds();
if (selectedRowIds.isEmpty()) {
return ProcessPreconditionsResolution.rejectBecauseNoSelection();
} else if (selectedRowIds.isMoreThanOneDocumentId()) {
return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
}
final HUEditorRow huRow = getSingleSelectedRow();
if (!isEligible(huRow)) {
final ITranslatableString reason = Services.get(IMsgBL.class).getTranslatableMsgText(MSG_WEBUI_SELECT_ACTIVE_UNSELECTED_HU);
return ProcessPreconditionsResolution.reject(reason);
}
return ProcessPreconditionsResolution.accept();
}
use of de.metas.ui.web.window.datatypes.DocumentIdsSelection in project metasfresh-webui-api by metasfresh.
the class ViewRestController method getByIds.
@GetMapping("/{viewId}/byIds")
public List<JSONViewRow> getByIds(//
@PathVariable(PARAM_WindowId) final String windowId, //
@PathVariable("viewId") final String viewIdStr, //
@RequestParam("ids") @ApiParam("comma separated IDs") final String idsListStr) {
userSession.assertLoggedIn();
final DocumentIdsSelection rowIds = DocumentIdsSelection.ofCommaSeparatedString(idsListStr);
if (rowIds.isAll()) {
throw new AdempiereException("retrieving ALL rows is not allowed here");
}
final ViewId viewId = ViewId.of(windowId, viewIdStr);
final IView view = viewsRepo.getView(viewId);
final List<? extends IViewRow> result = view.streamByIds(rowIds).collect(ImmutableList.toImmutableList());
final IViewRowOverrides rowOverrides = ViewRowOverridesHelper.getViewRowOverrides(view);
return JSONViewRow.ofViewRows(result, rowOverrides, userSession.getAD_Language());
}
use of de.metas.ui.web.window.datatypes.DocumentIdsSelection in project metasfresh-webui-api by metasfresh.
the class ViewActionDescriptor method toWebuiRelatedProcessDescriptor.
public final WebuiRelatedProcessDescriptor toWebuiRelatedProcessDescriptor(final ViewAsPreconditionsContext viewContext) {
final IView view = viewContext.getView();
final DocumentIdsSelection selectedDocumentIds = viewContext.getSelectedRowIds();
return WebuiRelatedProcessDescriptor.builder().processId(ViewProcessInstancesRepository.buildProcessId(view.getViewId(), actionId)).processCaption(caption).processDescription(description).defaultQuickAction(defaultAction).quickAction(true).preconditionsResolutionSupplier(() -> checkPreconditions(view, selectedDocumentIds)).build();
}
use of de.metas.ui.web.window.datatypes.DocumentIdsSelection in project metasfresh-webui-api by metasfresh.
the class SqlViewKeyColumnNamesMap method getSqlFilterByRowIds.
@Builder(builderMethodName = "prepareSqlFilterByRowIds", builderClassName = "SqlFilterByRowIdsBuilder")
private SqlAndParams getSqlFilterByRowIds(@NonNull final DocumentIdsSelection rowIds, final SqlViewRowIdsConverter rowIdsConverter, final String sqlColumnPrefix, final boolean useKeyColumnName, final boolean embedSqlParams) {
if (rowIds.isEmpty()) {
throw new AdempiereException("rowIds shall not be empty");
}
if (isSingleKey()) {
final String selectionColumnName = useKeyColumnName ? getSingleKeyColumnName() : getSingleWebuiSelectionColumnName();
final String keyColumnName = (sqlColumnPrefix != null ? sqlColumnPrefix : "") + selectionColumnName;
final Set<Integer> recordIds = rowIdsConverter != null ? rowIdsConverter.convertToRecordIds(rowIds) : rowIds.toIntSet();
final List<Object> sqlParams = embedSqlParams ? null : new ArrayList<>();
final String sql = DB.buildSqlList(keyColumnName, recordIds, sqlParams);
return SqlAndParams.of(sql, sqlParams != null ? sqlParams : ImmutableList.of());
} else {
final List<SqlAndParams> sqls = rowIds.toSet().stream().map(rowId -> getSqlFilterByRowId(rowId, sqlColumnPrefix, useKeyColumnName, embedSqlParams)).collect(ImmutableList.toImmutableList());
return SqlAndParams.and(sqls);
}
}
Aggregations