Search in sources :

Example 6 with IQueryBL

use of org.adempiere.ad.dao.IQueryBL in project metasfresh-webui-api by metasfresh.

the class PickingHURowsRepository method retrievePickingCandidates.

private static List<I_M_Picking_Candidate> retrievePickingCandidates(@NonNull final PickingSlotRepoQuery pickingSlotRowQuery) {
    // configure the query builder
    final IQueryBL queryBL = Services.get(IQueryBL.class);
    final IQueryBuilder<I_M_Picking_Candidate> queryBuilder = queryBL.createQueryBuilder(I_M_Picking_Candidate.class).addOnlyActiveRecordsFilter().addInArrayFilter(I_M_Picking_Candidate.COLUMN_M_ShipmentSchedule_ID, pickingSlotRowQuery.getShipmentScheduleIds());
    switch(pickingSlotRowQuery.getPickingCandidates()) {
        case ONLY_NOT_CLOSED:
            // even if we don't care, we *do not* want to show closed picking candidates
            queryBuilder.addNotEqualsFilter(I_M_Picking_Candidate.COLUMN_Status, X_M_Picking_Candidate.STATUS_CL);
            break;
        case ONLY_NOT_CLOSED_OR_NOT_RACK_SYSTEM:
            final Set<Integer> rackSystemPickingSlotIds = Services.get(IHUPickingSlotDAO.class).retrieveAllPickingSlotIdsWhichAreRackSystems();
            queryBuilder.addCompositeQueryFilter().setJoinOr().addNotEqualsFilter(I_M_Picking_Candidate.COLUMN_Status, X_M_Picking_Candidate.STATUS_CL).addNotInArrayFilter(I_M_Picking_Candidate.COLUMN_M_PickingSlot_ID, rackSystemPickingSlotIds);
            break;
        case ONLY_PROCESSED:
            queryBuilder.addEqualsFilter(I_M_Picking_Candidate.COLUMN_Status, X_M_Picking_Candidate.STATUS_PR);
            break;
        case ONLY_UNPROCESSED:
            queryBuilder.addEqualsFilter(I_M_Picking_Candidate.COLUMN_Status, X_M_Picking_Candidate.STATUS_IP);
            break;
        default:
            Check.errorIf(true, "Query has unexpected pickingCandidates={}; query={}", pickingSlotRowQuery.getPickingCandidates(), pickingSlotRowQuery);
    }
    // 
    // Picking slot Barcode filter
    final String pickingSlotBarcode = pickingSlotRowQuery.getPickingSlotBarcode();
    if (!Check.isEmpty(pickingSlotBarcode, true)) {
        final IPickingSlotDAO pickingSlotDAO = Services.get(IPickingSlotDAO.class);
        final List<Integer> pickingSlotIds = pickingSlotDAO.retrievePickingSlotIds(PickingSlotQuery.builder().barcode(pickingSlotBarcode).build());
        if (pickingSlotIds.isEmpty()) {
            return ImmutableList.of();
        }
        queryBuilder.addInArrayFilter(I_M_Picking_Candidate.COLUMN_M_PickingSlot_ID, pickingSlotIds);
    }
    // 
    // HU filter
    final IQuery<I_M_HU> husQuery = queryBL.createQueryBuilder(I_M_HU.class).addNotEqualsFilter(I_M_HU.COLUMNNAME_HUStatus, // not already shipped (https://github.com/metasfresh/metasfresh-webui-api/issues/647)
    X_M_HU.HUSTATUS_Shipped).create();
    queryBuilder.addInSubQueryFilter(I_M_Picking_Candidate.COLUMN_M_HU_ID, I_M_HU.COLUMN_M_HU_ID, husQuery);
    return queryBuilder.orderBy(I_M_Picking_Candidate.COLUMNNAME_M_Picking_Candidate_ID).create().list();
}
Also used : IQueryBL(org.adempiere.ad.dao.IQueryBL) IHUPickingSlotDAO(de.metas.handlingunits.picking.IHUPickingSlotDAO) I_M_HU(de.metas.handlingunits.model.I_M_HU) IPickingSlotDAO(de.metas.picking.api.IPickingSlotDAO) I_M_Picking_Candidate(de.metas.handlingunits.model.I_M_Picking_Candidate)

Example 7 with IQueryBL

use of org.adempiere.ad.dao.IQueryBL in project metasfresh-webui-api by metasfresh.

the class MaterialCockpitFilters method createInitialQueryBuilder.

private IQueryBuilder<I_MD_Cockpit> createInitialQueryBuilder() {
    final IQueryBL queryBL = Services.get(IQueryBL.class);
    final IQueryBuilder<I_MD_Cockpit> queryBuilder = queryBL.createQueryBuilder(I_MD_Cockpit.class).addOnlyActiveRecordsFilter();
    return queryBuilder;
}
Also used : IQueryBL(org.adempiere.ad.dao.IQueryBL) I_MD_Cockpit(de.metas.material.cockpit.model.I_MD_Cockpit)

Aggregations

IQueryBL (org.adempiere.ad.dao.IQueryBL)7 SqlDocumentFieldDataBindingDescriptor (de.metas.ui.web.window.descriptor.sql.SqlDocumentFieldDataBindingDescriptor)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2 I_M_Product (org.compiere.model.I_M_Product)2 Joiner (com.google.common.base.Joiner)1 Preconditions (com.google.common.base.Preconditions)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Amount (de.metas.currency.Amount)1 ICurrencyDAO (de.metas.currency.ICurrencyDAO)1 I_M_HU (de.metas.handlingunits.model.I_M_HU)1 I_M_Picking_Candidate (de.metas.handlingunits.model.I_M_Picking_Candidate)1 IHUPickingSlotDAO (de.metas.handlingunits.picking.IHUPickingSlotDAO)1 DateTimeTranslatableString (de.metas.i18n.DateTimeTranslatableString)1 IModelTranslationMap (de.metas.i18n.IModelTranslationMap)1 IMsgBL (de.metas.i18n.IMsgBL)1 ITranslatableString (de.metas.i18n.ITranslatableString)1 ImmutableTranslatableString (de.metas.i18n.ImmutableTranslatableString)1 NumberTranslatableString (de.metas.i18n.NumberTranslatableString)1 LogManager (de.metas.logging.LogManager)1