Search in sources :

Example 86 with SearchCriteriaBuilder

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

the class AssignmentToShiftDataProvider method findAll.

public List<Entity> findAll(final AssignmentToShiftCriteria criteria, final Optional<SearchProjection> maybeProjection, final Optional<SearchOrder> maybeSearchOrder) {
    SearchCriteriaBuilder scb = createCriteriaBuilder(criteria);
    setProjectionIfPresent(scb, maybeProjection);
    for (SearchOrder searchOrder : maybeSearchOrder.asSet()) {
        scb.addOrder(searchOrder);
    }
    return scb.list().getEntities();
}
Also used : SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) SearchOrder(com.qcadoo.model.api.search.SearchOrder)

Example 87 with SearchCriteriaBuilder

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

the class AssignmentToShiftDataProvider method find.

public Optional<Entity> find(final AssignmentToShiftCriteria criteria, final Optional<SearchProjection> maybeProjection) {
    SearchCriteriaBuilder scb = createCriteriaBuilder(criteria);
    setProjectionIfPresent(scb, maybeProjection);
    return Optional.fromNullable(scb.setMaxResults(1).uniqueResult());
}
Also used : SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder)

Example 88 with SearchCriteriaBuilder

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

the class AssignmentToShiftStatesHelper method findPausedStateChangeEntity.

private Entity findPausedStateChangeEntity(final Entity assignmentToShift) {
    DataDefinition stateChangeDD = dataDefinitionService.get(AssignmentToShiftConstants.PLUGIN_IDENTIFIER, AssignmentToShiftConstants.MODEL_ASSIGNMENT_TO_SHIFT_STATE_CHANGE);
    SearchCriteriaBuilder scb = stateChangeDD.find();
    for (SearchCriterion criterion : getCriteriaToFindWaitingStateChange(assignmentToShift)) {
        scb.add(criterion);
    }
    return scb.setMaxResults(1).uniqueResult();
}
Also used : SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) SearchCriterion(com.qcadoo.model.api.search.SearchCriterion) DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 89 with SearchCriteriaBuilder

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

the class AverageCostService method getStaffAssignmentToShiftDependOnAssignmentToShiftState.

private List<Entity> getStaffAssignmentToShiftDependOnAssignmentToShiftState(final Entity assignmentToShift, final Entity productionLine) {
    List<Entity> staffAssignmentToShifts = new ArrayList<Entity>();
    String state = assignmentToShift.getStringField(AssignmentToShiftFields.STATE);
    SearchCriteriaBuilder searchCriteriaBuilder = assignmentToShift.getHasManyField("staffAssignmentToShifts").find().add(SearchRestrictions.eq("occupationTypeEnum", "01workOnLine")).add(SearchRestrictions.belongsTo(StaffAssignmentToShiftFields.PRODUCTION_LINE, productionLine));
    if (state.equals(AssignmentToShiftState.CORRECTED.getStringValue())) {
        staffAssignmentToShifts = searchCriteriaBuilder.add(SearchRestrictions.eq("state", StaffAssignmentToShiftState.CORRECTED.getStringValue())).list().getEntities();
    } else if (state.equals(AssignmentToShiftState.ACCEPTED.getStringValue()) || state.equals(AssignmentToShiftState.DURING_CORRECTION.getStringValue())) {
        staffAssignmentToShifts = searchCriteriaBuilder.add(SearchRestrictions.eq("state", StaffAssignmentToShiftState.ACCEPTED.getStringValue())).list().getEntities();
    }
    return staffAssignmentToShifts;
}
Also used : Entity(com.qcadoo.model.api.Entity) SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) ArrayList(java.util.ArrayList)

Example 90 with SearchCriteriaBuilder

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

the class AssignmentToShiftDataProvider method createCriteriaBuilder.

public SearchCriteriaBuilder createCriteriaBuilder(final AssignmentToShiftCriteria criteria) {
    SearchCriteriaBuilder scb = getAssignmentDD().find();
    SearchCriteriaBuilder shiftScb = scb.createCriteria(AssignmentToShiftFields.SHIFT, "shift_alias", JoinType.INNER);
    for (SearchCriterion searchCriterion : criteria.getShiftCriteria().asSet()) {
        shiftScb.add(searchCriterion);
    }
    SearchCriteriaBuilder factoryScb = scb.createCriteria(AssignmentToShiftFields.FACTORY, "factory_alias", JoinType.INNER);
    for (SearchCriterion searchCriterion : criteria.getFactoryCriteria().asSet()) {
        factoryScb.add(searchCriterion);
    }
    if (criteria.getCrewCriteria().isPresent()) {
        SearchCriteriaBuilder crewScb = scb.createCriteria(AssignmentToShiftFields.CREW, "crew_alias", JoinType.INNER);
        for (SearchCriterion searchCriterion : criteria.getCrewCriteria().asSet()) {
            crewScb.add(searchCriterion);
        }
    }
    for (SearchCriterion searchCriterion : criteria.getCriteria().asSet()) {
        scb.add(searchCriterion);
    }
    return scb;
}
Also used : SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) SearchCriterion(com.qcadoo.model.api.search.SearchCriterion)

Aggregations

SearchCriteriaBuilder (com.qcadoo.model.api.search.SearchCriteriaBuilder)176 Entity (com.qcadoo.model.api.Entity)82 DataDefinition (com.qcadoo.model.api.DataDefinition)26 Autowired (org.springframework.beans.factory.annotation.Autowired)19 Service (org.springframework.stereotype.Service)19 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)18 EntityList (com.qcadoo.model.api.EntityList)17 SearchRestrictions (com.qcadoo.model.api.search.SearchRestrictions)17 Collectors (java.util.stream.Collectors)17 SearchResult (com.qcadoo.model.api.search.SearchResult)16 SearchCriterion (com.qcadoo.model.api.search.SearchCriterion)14 Objects (java.util.Objects)14 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)11 BigDecimal (java.math.BigDecimal)11 Set (java.util.Set)11 UserFieldsMF (com.qcadoo.mes.materialFlow.constants.UserFieldsMF)10 UserLocationFields (com.qcadoo.mes.materialFlow.constants.UserLocationFields)10 SecurityService (com.qcadoo.security.api.SecurityService)10 QcadooSecurityConstants (com.qcadoo.security.constants.QcadooSecurityConstants)10 CustomRestriction (com.qcadoo.model.api.search.CustomRestriction)8