use of com.qcadoo.model.api.search.SearchResult in project mes by qcadoo.
the class DocumentPdf method addContent.
@Override
protected String addContent(Document document, Map<String, Object> model, Locale locale, PdfWriter writer) throws DocumentException, IOException {
this.locale = locale;
String documentTitle = translationService.translate("warehouseMinimalState.report.title", locale);
String documentAuthor = translationService.translate("qcadooReport.commons.generatedBy.label", locale);
pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, new Date());
DataDefinition warehouseMinimumStateDD = dataDefinitionService.get(WarehouseMinimalStateConstants.PLUGIN_IDENTIFIER, WarehouseMinimalStateConstants.MODEL_WAREHOUSE_MINIMUM_STATE);
SearchResult searchResult = warehouseMinimumStateDD.find().add(SearchRestrictions.gt("minimumState", BigDecimal.ZERO)).list();
List<Entity> warehouseMinimumStates = searchResult.getEntities();
fillWarehousesLists(warehouseMinimumStates);
addWarehouseTables(document);
return "raport";
}
use of com.qcadoo.model.api.search.SearchResult in project mes by qcadoo.
the class WorkPlansServiceImpl method getSelectedOrders.
@Override
public final List<Entity> getSelectedOrders(final Set<Long> selectedOrderIds) {
List<Entity> orders = Lists.newArrayList();
if (selectedOrderIds.isEmpty()) {
return orders;
}
SearchCriteriaBuilder criteria = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER).find();
criteria.add(SearchRestrictions.in("id", selectedOrderIds));
SearchResult result = criteria.list();
if (result.getTotalNumberOfEntities() == 0) {
return orders;
}
orders.addAll(result.getEntities());
return orders;
}
use of com.qcadoo.model.api.search.SearchResult in project mes by qcadoo.
the class OrderDetailsHooks method hasAnyTechnologies.
private boolean hasAnyTechnologies(final Entity product) {
SearchCriteriaBuilder searchCriteria = getTechnologyDD().find().add(SearchRestrictions.belongsTo(TechnologyFields.PRODUCT, product)).setMaxResults(1);
SearchResult searchResult = searchCriteria.list();
return (searchResult.getTotalNumberOfEntities() > 0);
}
use of com.qcadoo.model.api.search.SearchResult in project qcadoo by qcadoo.
the class HqlIntegrationTest method shouldFindByQueryWithDistinct.
@Test
public void shouldFindByQueryWithDistinct() throws Exception {
// given
DataDefinition productDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_PRODUCT);
productDao.save(createProduct("asd", "asd"));
productDao.save(createProduct("asd", "asd"));
productDao.save(createProduct("bsd", "bsd"));
// when
SearchResult result = productDao.find("select distinct p.name from #products_product p order by p.name desc)").list();
// then
assertEquals(2, result.getTotalNumberOfEntities());
assertEquals("bsd", result.getEntities().get(0).getField("0"));
assertEquals("asd", result.getEntities().get(1).getField("0"));
}
use of com.qcadoo.model.api.search.SearchResult in project qcadoo by qcadoo.
the class UniqueValidator method call.
@Override
public boolean call(final Entity entity, final Object oldValue, final Object newValue) {
if (entity.getField(fieldDefinition.getName()) == null) {
return true;
}
SearchCriteriaBuilder searchCriteriaBuilder = dataDefinition.find().add(uniqueCriterionFor(entity)).setMaxResults(1);
if (entity.getId() != null) {
searchCriteriaBuilder.add(SearchRestrictions.idNe(entity.getId()));
}
SearchResult results = searchCriteriaBuilder.list();
if (results.getTotalNumberOfEntities() == 0) {
return true;
} else {
entity.addError(fieldDefinition, errorMessage);
return false;
}
}
Aggregations