Search in sources :

Example 1 with IHUQueryBuilder

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);
}
Also used : IHUQueryBuilder(de.metas.handlingunits.IHUQueryBuilder)

Example 2 with IHUQueryBuilder

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();
}
Also used : IHUQueryBuilder(de.metas.handlingunits.IHUQueryBuilder) SqlDocumentFilterConverter(de.metas.ui.web.document.filter.sql.SqlDocumentFilterConverter)

Example 3 with IHUQueryBuilder

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);
}
Also used : IHUQueryBuilder(de.metas.handlingunits.IHUQueryBuilder) ViewId(de.metas.ui.web.view.ViewId) CreateViewRequest(de.metas.ui.web.view.CreateViewRequest) WEBUI_PackingHUsView_AddHUsToShipperTransportationShipAndInvoice(de.metas.ui.web.pickingslotsClearing.process.WEBUI_PackingHUsView_AddHUsToShipperTransportationShipAndInvoice)

Example 4 with IHUQueryBuilder

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;
}
Also used : I_PP_Order_BOMLine(org.eevolution.model.I_PP_Order_BOMLine) IHUPPOrderBL(de.metas.handlingunits.pporder.api.IHUPPOrderBL) Env(org.compiere.util.Env) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.adempiere.util.StringUtils) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType) PPOrderLineRow(de.metas.ui.web.pporder.PPOrderLineRow) ImmutableList(com.google.common.collect.ImmutableList) IView(de.metas.ui.web.view.IView) IHUQueryBuilder(de.metas.handlingunits.IHUQueryBuilder) IProcessPrecondition(de.metas.process.IProcessPrecondition) IADProcessDAO(de.metas.process.IADProcessDAO) IHUPPOrderQtyDAO(de.metas.handlingunits.pporder.api.IHUPPOrderQtyDAO) ViewBasedProcessTemplate(de.metas.ui.web.process.adprocess.ViewBasedProcessTemplate) RelatedProcessDescriptor(de.metas.process.RelatedProcessDescriptor) PPOrderLinesView(de.metas.ui.web.pporder.PPOrderLinesView) SourceHUsService(de.metas.handlingunits.sourcehu.SourceHUsService) HUIdsFilterHelper(de.metas.ui.web.handlingunits.HUIdsFilterHelper) ProcessPreconditionsResolution(de.metas.process.ProcessPreconditionsResolution) Services(org.adempiere.util.Services) List(java.util.List) InterfaceWrapperHelper.load(org.adempiere.model.InterfaceWrapperHelper.load) CreateViewRequest(de.metas.ui.web.view.CreateViewRequest) WEBUI_HU_Constants(de.metas.ui.web.handlingunits.WEBUI_HU_Constants) IViewsRepository(de.metas.ui.web.view.IViewsRepository) ViewId(de.metas.ui.web.view.ViewId) IHUPPOrderBL(de.metas.handlingunits.pporder.api.IHUPPOrderBL) IHUQueryBuilder(de.metas.handlingunits.IHUQueryBuilder) I_PP_Order_BOMLine(org.eevolution.model.I_PP_Order_BOMLine)

Example 5 with IHUQueryBuilder

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;
}
Also used : IHandlingUnitsDAO(de.metas.handlingunits.IHandlingUnitsDAO) IHUQueryBuilder(de.metas.handlingunits.IHUQueryBuilder) Select(de.metas.ui.web.handlingunits.HUEditorRowFilter.Select)

Aggregations

IHUQueryBuilder (de.metas.handlingunits.IHUQueryBuilder)5 CreateViewRequest (de.metas.ui.web.view.CreateViewRequest)2 ViewId (de.metas.ui.web.view.ViewId)2 ImmutableList (com.google.common.collect.ImmutableList)1 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)1 IHUPPOrderBL (de.metas.handlingunits.pporder.api.IHUPPOrderBL)1 IHUPPOrderQtyDAO (de.metas.handlingunits.pporder.api.IHUPPOrderQtyDAO)1 SourceHUsService (de.metas.handlingunits.sourcehu.SourceHUsService)1 IADProcessDAO (de.metas.process.IADProcessDAO)1 IProcessPrecondition (de.metas.process.IProcessPrecondition)1 ProcessPreconditionsResolution (de.metas.process.ProcessPreconditionsResolution)1 RelatedProcessDescriptor (de.metas.process.RelatedProcessDescriptor)1 SqlDocumentFilterConverter (de.metas.ui.web.document.filter.sql.SqlDocumentFilterConverter)1 Select (de.metas.ui.web.handlingunits.HUEditorRowFilter.Select)1 HUIdsFilterHelper (de.metas.ui.web.handlingunits.HUIdsFilterHelper)1 WEBUI_HU_Constants (de.metas.ui.web.handlingunits.WEBUI_HU_Constants)1 WEBUI_PackingHUsView_AddHUsToShipperTransportationShipAndInvoice (de.metas.ui.web.pickingslotsClearing.process.WEBUI_PackingHUsView_AddHUsToShipperTransportationShipAndInvoice)1 PPOrderLineRow (de.metas.ui.web.pporder.PPOrderLineRow)1 PPOrderLinesView (de.metas.ui.web.pporder.PPOrderLinesView)1 ViewBasedProcessTemplate (de.metas.ui.web.process.adprocess.ViewBasedProcessTemplate)1