use of de.metas.handlingunits.IHUQueryBuilder in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_HU_MoveToDirectWarehouse_Mass method retrieveHUs.
/**
* @return HUs that will be moved
*/
protected Iterator<I_M_HU> retrieveHUs() {
final IHUQueryBuilder huQueryBuilder = handlingUnitsDAO.createHUQueryBuilder().setContext(getCtx(), ITrx.TRXNAME_None);
// Only top level HUs
huQueryBuilder.setOnlyTopLevelHUs();
// Only Active HUs
huQueryBuilder.addHUStatusToInclude(X_M_HU.HUSTATUS_Active);
// Only for preselected warehouse
if (p_M_Warehouse_ID > 0) {
huQueryBuilder.addOnlyInWarehouseId(p_M_Warehouse_ID);
}
// Only for given SQL where clause
if (!Check.isEmpty(p_huWhereClause, true)) {
huQueryBuilder.addFilter(TypedSqlQueryFilter.of(p_huWhereClause));
}
// Fetch the HUs iterator
return huQueryBuilder.createQuery().setOption(IQuery.OPTION_GuaranteedIteratorRequired, // because we might change the hu's locator
true).setOption(IQuery.OPTION_IteratorBufferSize, 1000).iterate(I_M_HU.class);
}
use of de.metas.handlingunits.IHUQueryBuilder in project metasfresh-webui-api by metasfresh.
the class SqlHUEditorViewRepository method retrieveHUIdsEffective.
@Override
public List<Integer> retrieveHUIdsEffective(@NonNull final HUIdsFilterData huIdsFilter, @NonNull final List<DocumentFilter> filters) {
final ImmutableList<Integer> onlyHUIds = extractHUIds(huIdsFilter);
if (filters.isEmpty() && !huIdsFilter.hasInitialHUQuery() && onlyHUIds != null) {
// shortcut: don't bother the DB but return the list of IDs that we already have
return onlyHUIds;
}
// Create HU query
IHUQueryBuilder huQuery = huIdsFilter.getInitialHUQueryOrNull();
if (huQuery == null) {
huQuery = Services.get(IHandlingUnitsDAO.class).createHUQueryBuilder();
}
huQuery.setContext(PlainContextAware.newOutOfTrx());
// Only HUs
if (onlyHUIds != null) {
huQuery.addOnlyHUIds(onlyHUIds);
}
// Exclude HUs
huQuery.addHUIdsToExclude(huIdsFilter.getShallNotHUIds());
// Convert the "filters" to SQL
if (!filters.isEmpty()) {
final SqlDocumentFilterConverter sqlFilterConverter = SqlDocumentFilterConverters.createEntityBindingEffectiveConverter(sqlViewBinding);
huQuery.addFilter(sqlFilterConverter.createQueryFilter(filters, SqlOptions.usingTableAlias(sqlViewBinding.getTableAlias())));
}
return huQuery.createQuery().listIds();
}
use of de.metas.handlingunits.IHUQueryBuilder 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.handlingunits.IHUQueryBuilder in project metasfresh-webui-api by metasfresh.
the class WEBUI_PP_Order_HUEditor_Launcher method retrieveHuIdsToShowInEditor.
private List<Integer> retrieveHuIdsToShowInEditor(final int ppOrderBomLineId) {
final I_PP_Order_BOMLine ppOrderBomLine = load(ppOrderBomLineId, I_PP_Order_BOMLine.class);
final IHUPPOrderBL huppOrderBL = Services.get(IHUPPOrderBL.class);
final IHUQueryBuilder huIdsToAvailableToIssueQuery = huppOrderBL.createHUsAvailableToIssueQuery(ppOrderBomLine);
final List<Integer> availableHUsIDs = huIdsToAvailableToIssueQuery.createQuery().listIds().stream().filter(huId -> !SourceHUsService.get().isHuOrAnyParentSourceHu(huId)).filter(huId -> !Services.get(IHUPPOrderQtyDAO.class).isHuIdIssued(huId)).collect(ImmutableList.toImmutableList());
return availableHUsIDs;
}
use of de.metas.handlingunits.IHUQueryBuilder in project metasfresh-webui-api by metasfresh.
the class HUEditorRowFilters method toHUQueryBuilderPart.
/**
* Convert given filter to {@link IHUQueryBuilder}. All filter options which cannot be converted to {@link IHUQueryBuilder} are ignored.
*/
public static IHUQueryBuilder toHUQueryBuilderPart(final HUEditorRowFilter filter) {
final IHUQueryBuilder huQueryBuilder = Services.get(IHandlingUnitsDAO.class).createHUQueryBuilder();
//
// Filter by row type
// IMPORTANT: don't filter out TUs/CUs because it might be that we are searching for included rows too
// and in case we are filtering them out here the included TUs/CUs won't be found later...
final Select rowType = filter.getSelect();
if (rowType == Select.ALL) {
// nothing
} else if (rowType == Select.ONLY_TOPLEVEL) {
huQueryBuilder.setOnlyTopLevelHUs(true);
} else // else if (rowType == Select.LU)
// else if (rowType == Select.TU)
{
// throw new AdempiereException("Not supported: " + rowType);
}
// Filter by string filter
// final String stringFilter = filter.getUserInputFilter();
// if (!Check.isEmpty(stringFilter, true))
// {
// throw new AdempiereException("String filter not supported: " + stringFilter);
// }
// Exclude M_HU_IDs
huQueryBuilder.addHUIdsToExclude(filter.getExcludeHUIds());
// Include HUStatuses
huQueryBuilder.addHUStatusesToInclude(filter.getOnlyHUStatuses());
// Exclude HUStatuses
huQueryBuilder.addHUStatusesToExclude(filter.getExcludeHUStatuses());
return huQueryBuilder;
}
Aggregations