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();
}
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());
}
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();
}
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;
}
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;
}
Aggregations