Exemplo n.º 1
0
 private SearchCriteriaBuilder getSearchCriteriaForResourceForProductAndWarehouse(
     final Entity product, final Entity warehouse) {
   return dataDefinitionService
       .get(
           MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER,
           MaterialFlowResourcesConstants.MODEL_RESOURCE)
       .find()
       .add(SearchRestrictions.belongsTo(ResourceFields.LOCATION, warehouse))
       .add(SearchRestrictions.belongsTo(ResourceFields.PRODUCT, product))
       .add(SearchRestrictions.gt(ResourceFields.AVAILABLE_QUANTITY, BigDecimal.ZERO));
 }
  @Override
  @Transactional
  public Map<String, List<GanttChartItem>> resolve(
      final GanttChartScale scale, final JSONObject context, final Locale locale) {
    List<Entity> orders =
        dataDefinitionService
            .get("orders", "order")
            .find()
            .add(SearchRestrictions.ne("state", "04completed"))
            .add(SearchRestrictions.lt("dateFrom", scale.getDateTo()))
            .add(SearchRestrictions.gt("dateTo", scale.getDateFrom()))
            .list()
            .getEntities();

    List<GanttChartItem> items = new ArrayList<GanttChartItem>();

    for (Entity order : orders) {
      items.add(getItemForOrder(order, scale, locale));
    }

    return Collections.singletonMap("", items);
  }