Search in sources :

Example 11 with SearchCriterion

use of com.qcadoo.model.api.search.SearchCriterion in project mes by qcadoo.

the class ChangeoverNormsSearchServiceImpl method getProductionLineRestrictions.

private SearchCriterion getProductionLineRestrictions(final Long productionLineId) {
    SearchCriterion matchProductionLine = eq(LineChangeoverNormsFields.PRODUCTION_LINE + DOT_ID, productionLineId);
    SearchCriterion productionLineIsNull = isNull(LineChangeoverNormsFields.PRODUCTION_LINE);
    return or(matchProductionLine, productionLineIsNull);
}
Also used : SearchCriterion(com.qcadoo.model.api.search.SearchCriterion)

Example 12 with SearchCriterion

use of com.qcadoo.model.api.search.SearchCriterion in project mes by qcadoo.

the class MasterOrderValidators method checkIfEachOrderHasNumberStartingWithMasterOrderNumber.

private boolean checkIfEachOrderHasNumberStartingWithMasterOrderNumber(final Entity masterOrder) {
    String newMasterOrderNumber = masterOrder.getStringField(MasterOrderFields.NUMBER);
    SearchCriterion criteria = not(like(OrderFields.NUMBER, newMasterOrderNumber + "%"));
    Collection<String> unsupportedOrderNumbers = masterOrderOrdersDataProvider.findBelongingOrderNumbers(masterOrder, criteria);
    if (unsupportedOrderNumbers.isEmpty()) {
        return true;
    }
    addUnsupportedOrdersError(masterOrder, MasterOrderFields.NUMBER, "masterOrders.order.number.alreadyExistsOrderWithWrongNumber", unsupportedOrderNumbers);
    return false;
}
Also used : SearchCriterion(com.qcadoo.model.api.search.SearchCriterion)

Example 13 with SearchCriterion

use of com.qcadoo.model.api.search.SearchCriterion in project mes by qcadoo.

the class MasterOrderOrdersDataProvider method sumBelongingOrdersPlannedQuantities.

public BigDecimal sumBelongingOrdersPlannedQuantities(final Entity masterOrder, final Entity product) {
    SearchProjection quantitiesSumProjection = list().add(alias(sum(OrderFields.PLANNED_QUANTITY), QUANTITIES_SUM_ALIAS)).add(rowCount());
    SearchCriterion productCriterion = belongsTo(OrderFields.PRODUCT, product);
    List<Entity> quantitiesSumProjectionResults = findBelongingOrders(masterOrder, quantitiesSumProjection, productCriterion, SearchOrders.desc(QUANTITIES_SUM_ALIAS));
    for (Entity entity : quantitiesSumProjectionResults) {
        return entity.getDecimalField(QUANTITIES_SUM_ALIAS);
    }
    return BigDecimal.ZERO;
}
Also used : Entity(com.qcadoo.model.api.Entity) SearchProjection(com.qcadoo.model.api.search.SearchProjection) SearchCriterion(com.qcadoo.model.api.search.SearchCriterion)

Example 14 with SearchCriterion

use of com.qcadoo.model.api.search.SearchCriterion in project mes by qcadoo.

the class MasterOrderOrdersDataProvider method sumBelongingOrdersDoneQuantities.

public BigDecimal sumBelongingOrdersDoneQuantities(final Entity masterOrder, final Entity product) {
    SearchProjection quantitiesSumProjection = list().add(alias(sum(OrderFields.DONE_QUANTITY), QUANTITIES_SUM_ALIAS)).add(rowCount());
    SearchCriterion productCriterion = belongsTo(OrderFields.PRODUCT, product);
    List<Entity> quantitiesSumProjectionResults = findBelongingOrders(masterOrder, quantitiesSumProjection, productCriterion, SearchOrders.desc(QUANTITIES_SUM_ALIAS));
    for (Entity entity : quantitiesSumProjectionResults) {
        return entity.getDecimalField(QUANTITIES_SUM_ALIAS);
    }
    return BigDecimal.ZERO;
}
Also used : Entity(com.qcadoo.model.api.Entity) SearchProjection(com.qcadoo.model.api.search.SearchProjection) SearchCriterion(com.qcadoo.model.api.search.SearchCriterion)

Example 15 with SearchCriterion

use of com.qcadoo.model.api.search.SearchCriterion in project mes by qcadoo.

the class DispositionOrderPdfService method getDataForStorageLocation.

private String getDataForStorageLocation(Entity position) {
    Entity storageLocation = position.getBelongsToField(PositionFields.STORAGE_LOCATION);
    Entity locationFrom = position.getBelongsToField(PositionFields.DOCUMENT).getBelongsToField(DocumentFields.LOCATION_FROM);
    if (storageLocation == null && locationFrom != null) {
        DataDefinition storageLocationDD = dataDefinitionService.get(MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER, MaterialFlowResourcesConstants.MODEL_STORAGE_LOCATION);
        SearchCriterion criterionLocation = SearchRestrictions.belongsTo(StorageLocationFields.LOCATION, locationFrom);
        SearchCriterion criterionProduct = SearchRestrictions.belongsTo(StorageLocationFields.PRODUCT, position.getBelongsToField(PositionFields.PRODUCT));
        storageLocation = storageLocationDD.find().add(SearchRestrictions.and(criterionLocation, criterionProduct)).uniqueResult();
    }
    return storageLocation == null ? "" : storageLocation.getStringField(StorageLocationFields.NUMBER);
}
Also used : Entity(com.qcadoo.model.api.Entity) SearchCriterion(com.qcadoo.model.api.search.SearchCriterion) DataDefinition(com.qcadoo.model.api.DataDefinition)

Aggregations

SearchCriterion (com.qcadoo.model.api.search.SearchCriterion)41 Entity (com.qcadoo.model.api.Entity)16 Test (org.junit.Test)12 SearchCriteriaBuilder (com.qcadoo.model.api.search.SearchCriteriaBuilder)7 FieldDefinition (com.qcadoo.model.api.FieldDefinition)6 DataDefinition (com.qcadoo.model.api.DataDefinition)4 SearchProjection (com.qcadoo.model.api.search.SearchProjection)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 SearchResult (com.qcadoo.model.api.search.SearchResult)3 BigDecimal (java.math.BigDecimal)2 Date (java.util.Date)2 Before (org.junit.Before)2 Matchers.anyString (org.mockito.Matchers.anyString)2 ImmutableList (com.google.common.collect.ImmutableList)1 BatchNumberUniqueness (com.qcadoo.mes.advancedGenealogy.constants.BatchNumberUniqueness)1 AssignmentToShiftCriteria (com.qcadoo.mes.assignmentToShift.dataProviders.AssignmentToShiftCriteria)1 SearchDisjunction (com.qcadoo.model.api.search.SearchDisjunction)1 SearchOrder (com.qcadoo.model.api.search.SearchOrder)1 ParseException (java.text.ParseException)1 List (java.util.List)1