use of org.adempiere.ad.element.api.AdWindowId in project metasfresh-webui-api by metasfresh.
the class CableSalesOrderLineQuickInputDescriptorFactory method getMatchingKeys.
@Override
public Set<MatchingKey> getMatchingKeys() {
final IADWindowDAO windowDAO = Services.get(IADWindowDAO.class);
final AdWindowId salesOrderWindowId = windowDAO.getAdWindowId(I_C_OrderLine.Table_Name, SOTrx.SALES, WINDOW_ID_SalesOrder_DEFAULT);
final AdWindowId purchaseOrderWindowId = windowDAO.getAdWindowId(I_C_OrderLine.Table_Name, SOTrx.PURCHASE, WINDOW_ID_PurchaseOrder_DEFAULT);
return ImmutableSet.of(MatchingKey.includedDocument(DocumentType.Window, salesOrderWindowId.getRepoId(), I_C_OrderLine.Table_Name), MatchingKey.includedDocument(DocumentType.Window, purchaseOrderWindowId.getRepoId(), I_C_OrderLine.Table_Name));
}
use of org.adempiere.ad.element.api.AdWindowId in project metasfresh-webui-api by metasfresh.
the class DocumentCollection method getWindowId.
public WindowId getWindowId(@NonNull final DocumentZoomIntoInfo zoomIntoInfo) {
if (zoomIntoInfo.getWindowId() != null) {
return zoomIntoInfo.getWindowId();
}
final RecordZoomWindowFinder zoomWindowFinder;
if (zoomIntoInfo.isRecordIdPresent()) {
zoomWindowFinder = RecordZoomWindowFinder.newInstance(zoomIntoInfo.getTableName(), zoomIntoInfo.getRecordId());
} else {
zoomWindowFinder = RecordZoomWindowFinder.newInstance(zoomIntoInfo.getTableName());
}
final AdWindowId zoomInto_adWindowId = zoomWindowFinder.findAdWindowId().orElse(null);
if (zoomInto_adWindowId == null) {
throw new EntityNotFoundException("No windowId found").setParameter("zoomIntoInfo", zoomIntoInfo);
}
return WindowId.of(zoomInto_adWindowId);
}
use of org.adempiere.ad.element.api.AdWindowId in project metasfresh-webui-api by metasfresh.
the class DataEntryTabLoaderTest method createDataEntryTabLoader.
private static DataEntryTabLoader createDataEntryTabLoader() {
final WindowId windowId = WindowId.of(5);
final DataEntryWebuiTools dataEntryWebuiTools = new DataEntryWebuiTools(new UserRepository());
final JSONDataEntryRecordMapper jsonDataEntryRecordMapper = new JSONDataEntryRecordMapper();
final DataEntryRecordRepository dataEntryRecordRepository = new DataEntryRecordRepository(jsonDataEntryRecordMapper);
final DataEntrySubTabBindingDescriptorBuilder //
dataEntrySubTabBindingDescriptorBuilder = new DataEntrySubTabBindingDescriptorBuilder(dataEntryRecordRepository, dataEntryWebuiTools);
return DataEntryTabLoader.builder().filterDescriptorsProvidersService(new DocumentFilterDescriptorsProvidersService(ImmutableList.of())).windowId(windowId).adWindowId(windowId.toAdWindowIdOrNull()).dataEntrySubTabBindingDescriptorBuilder(dataEntrySubTabBindingDescriptorBuilder).build();
}
use of org.adempiere.ad.element.api.AdWindowId in project metasfresh-webui-api by metasfresh.
the class ADProcessDescriptorsFactory method streamDocumentRelatedProcesses.
public Stream<WebuiRelatedProcessDescriptor> streamDocumentRelatedProcesses(@NonNull final WebuiPreconditionsContext preconditionsContext, @NonNull final IUserRolePermissions userRolePermissions) {
final String tableName = preconditionsContext.getTableName();
final int adTableId = !Check.isEmpty(tableName) ? adTableDAO.retrieveTableId(tableName) : -1;
final AdWindowId adWindowId = preconditionsContext.getAdWindowId();
final AdTabId adTabId = preconditionsContext.getAdTabId();
final Stream<RelatedProcessDescriptor> relatedProcessDescriptors;
{
final Stream<RelatedProcessDescriptor> tableRelatedProcessDescriptors = adProcessDAO.retrieveRelatedProcessDescriptors(adTableId, adWindowId, adTabId).stream();
final Stream<RelatedProcessDescriptor> additionalRelatedProcessDescriptors = preconditionsContext.getAdditionalRelatedProcessDescriptors().stream();
relatedProcessDescriptors = Stream.concat(additionalRelatedProcessDescriptors, tableRelatedProcessDescriptors).collect(GuavaCollectors.distinctBy(RelatedProcessDescriptor::getProcessId));
}
return relatedProcessDescriptors.filter(relatedProcess -> isEligible(relatedProcess, preconditionsContext, userRolePermissions)).map(relatedProcess -> toWebuiRelatedProcessDescriptor(relatedProcess, preconditionsContext));
}
use of org.adempiere.ad.element.api.AdWindowId in project metasfresh-webui-api by metasfresh.
the class ADProcessInstancesRepository method createProcessInfo.
private ProcessInfo createProcessInfo(@NonNull final CreateProcessInstanceRequest request) {
final DocumentPath singleDocumentPath = request.getSingleDocumentPath();
final String tableName;
final int recordId;
final String sqlWhereClause;
final AdWindowId adWindowId;
// View
if (request.getViewRowIdsSelection() != null) {
final ViewRowIdsSelection viewRowIdsSelection = request.getViewRowIdsSelection();
final ViewId viewId = viewRowIdsSelection.getViewId();
final IView view = viewsRepo.getView(viewId);
final DocumentIdsSelection viewDocumentIds = viewRowIdsSelection.getRowIds();
adWindowId = viewId.getWindowId().toAdWindowIdOrNull();
if (viewDocumentIds.isSingleDocumentId()) {
final DocumentId viewSingleDocumentId = viewDocumentIds.getSingleDocumentId();
final TableRecordReference recordRef = view.getTableRecordReferenceOrNull(viewSingleDocumentId);
if (recordRef != null) {
tableName = recordRef.getTableName();
recordId = recordRef.getRecord_ID();
} else {
tableName = view.getTableNameOrNull(viewSingleDocumentId);
recordId = -1;
}
} else {
tableName = view.getTableNameOrNull(null);
recordId = -1;
}
final boolean emptyTableName = Check.isEmpty(tableName);
if (viewDocumentIds.isEmpty() || emptyTableName) {
// Note: in the case of material cockpit, there is no single tableName to be returned by view.getTableNameOrNull,
// so we do have selected rows, but no table name, which is OK
sqlWhereClause = null;
} else {
sqlWhereClause = view.getSqlWhereClause(viewDocumentIds, SqlOptions.usingTableName(tableName));
}
} else // Single document call
if (singleDocumentPath != null) {
final DocumentEntityDescriptor entityDescriptor = documentDescriptorFactory.getDocumentEntityDescriptor(singleDocumentPath);
adWindowId = singleDocumentPath.getWindowId().toAdWindowIdOrNull();
tableName = entityDescriptor.getTableNameOrNull();
final DocumentId documentId;
if (singleDocumentPath.isRootDocument()) {
documentId = singleDocumentPath.getDocumentId();
} else {
documentId = singleDocumentPath.getSingleRowId();
}
if (documentId.isInt()) {
recordId = documentId.toInt();
} else {
recordId = -1;
}
sqlWhereClause = entityDescriptor.getDataBinding(SqlDocumentEntityDataBindingDescriptor.class).getSqlWhereClauseById(documentId);
} else //
// From menu
{
tableName = null;
recordId = -1;
sqlWhereClause = null;
adWindowId = null;
}
//
final Set<TableRecordReference> selectedIncludedRecords = request.getSelectedIncludedDocumentPaths().stream().map(documentDescriptorFactory::getTableRecordReference).collect(ImmutableSet.toImmutableSet());
final ProcessInfoBuilder processInfoBuilder = ProcessInfo.builder().setCtx(Env.getCtx()).setCreateTemporaryCtx().setAD_Process_ID(request.getProcessIdAsInt()).setAdWindowId(adWindowId).setRecord(tableName, recordId).setSelectedIncludedRecords(selectedIncludedRecords).setWhereClause(sqlWhereClause);
//
// View related internal parameters
addViewInternalParameters(request, processInfoBuilder);
return processInfoBuilder.build();
}
Aggregations