Search in sources :

Example 1 with CustomRestriction

use of com.qcadoo.model.api.search.CustomRestriction in project qcadoo by qcadoo.

the class UnitConversionModelServiceImpl method find.

@Override
@Transactional(readOnly = true)
public List<Entity> find(final String unit, final CustomRestriction customRestriction) {
    final CustomRestriction unitMatchingRestriction = new ConversionMatchingUnitRestriction(unit, customRestriction);
    final SearchCriteriaBuilder searchCriteriaBuilder = getDataDefinition().find();
    unitMatchingRestriction.addRestriction(searchCriteriaBuilder);
    return searchCriteriaBuilder.list().getEntities();
}
Also used : SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) CustomRestriction(com.qcadoo.model.api.search.CustomRestriction) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with CustomRestriction

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

the class WagesListsHooks method addDiscriminatorRestrictionToGrid.

public final void addDiscriminatorRestrictionToGrid(final ViewDefinitionState view) {
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    grid.setCustomRestriction(new CustomRestriction() {

        @Override
        public void addRestriction(final SearchCriteriaBuilder searchBuilder) {
            Entity ownerCompany = companyService.getCompany();
            searchBuilder.add(SearchRestrictions.or(SearchRestrictions.belongsTo("workFor", ownerCompany), SearchRestrictions.isNotNull("laborHourlyCost")));
        }
    });
}
Also used : Entity(com.qcadoo.model.api.Entity) SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) GridComponent(com.qcadoo.view.api.components.GridComponent) CustomRestriction(com.qcadoo.model.api.search.CustomRestriction)

Example 3 with CustomRestriction

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

the class ProductService method findPossibleUnitConversions.

private PossibleUnitConversions findPossibleUnitConversions(final String unitName, final Entity productEntity) {
    CustomRestriction belongsToProductRestriction = new CustomRestriction() {

        @Override
        public void addRestriction(final SearchCriteriaBuilder scb) {
            scb.add(SearchRestrictions.belongsTo(UnitConversionItemFieldsB.PRODUCT, productEntity));
        }
    };
    PossibleUnitConversions possibleUnitConversions = unitConversionService.getPossibleConversions(unitName, belongsToProductRestriction);
    if (Objects.isNull(possibleUnitConversions)) {
        possibleUnitConversions = unitConversionService.getPossibleConversions(unitName);
    }
    return possibleUnitConversions;
}
Also used : SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) PossibleUnitConversions(com.qcadoo.model.api.units.PossibleUnitConversions) CustomRestriction(com.qcadoo.model.api.search.CustomRestriction)

Example 4 with CustomRestriction

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

the class PalletNumberHelpersListHooks method addDiscriminatorRestrictionToGrid.

public final void addDiscriminatorRestrictionToGrid(final ViewDefinitionState view) {
    GridComponent palletNumberHelpersGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    palletNumberHelpersGrid.setCustomRestriction(new CustomRestriction() {

        @Override
        public void addRestriction(final SearchCriteriaBuilder searchBuilder) {
            searchBuilder.add(SearchRestrictions.eq(PalletNumberHelperFields.TEMPORARY, false));
        }
    });
}
Also used : SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) GridComponent(com.qcadoo.view.api.components.GridComponent) CustomRestriction(com.qcadoo.model.api.search.CustomRestriction)

Example 5 with CustomRestriction

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

the class DeliveryDetailsHooks method filterStateChangeHistory.

private void filterStateChangeHistory(final ViewDefinitionState view) {
    final GridComponent historyGrid = (GridComponent) view.getComponentByReference(L_LOGGINGS_GRID);
    final CustomRestriction onlySuccessfulRestriction = stateChangeHistoryService.buildStatusRestriction(DeliveryStateChangeFields.STATUS, Lists.newArrayList(StateChangeStatus.SUCCESSFUL.getStringValue()));
    historyGrid.setCustomRestriction(onlySuccessfulRestriction);
}
Also used : GridComponent(com.qcadoo.view.api.components.GridComponent) CustomRestriction(com.qcadoo.model.api.search.CustomRestriction)

Aggregations

CustomRestriction (com.qcadoo.model.api.search.CustomRestriction)16 GridComponent (com.qcadoo.view.api.components.GridComponent)12 SearchCriteriaBuilder (com.qcadoo.model.api.search.SearchCriteriaBuilder)8 Entity (com.qcadoo.model.api.Entity)1 SearchDisjunction (com.qcadoo.model.api.search.SearchDisjunction)1 PossibleUnitConversions (com.qcadoo.model.api.units.PossibleUnitConversions)1 FieldComponent (com.qcadoo.view.api.components.FieldComponent)1 Transactional (org.springframework.transaction.annotation.Transactional)1