Esempio n. 1
0
  /**
   * Méthode en charge de mettre à jour les lignes de stock à partir des mouvements de stock de type
   * Sortie. La mise à jour concerne la quantité.
   *
   * @param essai Essai.
   * @param pharmacie Pharmacie.
   * @param produit Produit.
   * @param conditionnement Conditionnement.
   * @param mapLines Map des lignes de stock à mettre à jour.
   */
  private void updateFromMvtTypeSortie(
      final MvtStockSearchCriteria critSortie, final Map<String, LigneStock> mapLines) {
    // Récupération des mouvements de type Sortie qui concernant l'essai, la
    // pharmacie, le
    // produit et le conditionnement
    critSortie.setTypesMouvement(TypeMvtStock.ALL_SORTIES);
    critSortie.setActiveOrder("datePeremption");

    final List<MvtStock> sorties = this.mvtStockService.getAll(critSortie);

    // on ne traite pas ici les dispensations globales car elles ne sortent
    // pas du stocks.
    CollectionUtils.filter(
        sorties,
        new Predicate<MvtStock>() {
          @Override
          public boolean evaluate(final MvtStock object) {
            return !object.getType().equals(TypeMvtStock.DOTATION);
          }
        });

    for (final MvtStock mvtStock : sorties) {
      final String key = this.getKeyMvtStock(mvtStock, false);
      if (mapLines.containsKey(key)) {
        final LigneStock ligneStock = mapLines.get(key);
        this.log.debug("Key: " + key + " objec: " + ligneStock);
        // Mise à jour de la quantité réelle en stock
        ligneStock.setQteGlobalStock(ligneStock.getQteGlobalStock() - mvtStock.getQuantite());
      } else {
        this.log.error("Aucun Mvt d'entrée correspondant à la sortie - idMvt " + mvtStock.getId());
      }
    }
  }
 private void removeEmpties(Recipe recipe) {
   filter(
       recipe.getIngredients(),
       new Predicate<Ingredient>() {
         @Override
         public boolean evaluate(Ingredient ingredient) {
           return isNotBlank(ingredient.getName())
               || (ingredient.getQuantity() != null
                   && ingredient.getQuantity().getAmount() != null);
         }
       });
   filter(
       recipe.getSteps(),
       new Predicate<Step>() {
         @Override
         public boolean evaluate(Step step) {
           return isNotBlank(step.getDirections());
         }
       });
 }
Esempio n. 3
0
  private void initLignesStockDispensationNominative(final Sortie sortie) {
    final MvtStock mvt = sortie.getMvtSortie();

    final List<LigneStock> lignesStock =
        this.getAllLignesStock(
            mvt.getEssai(), mvt.getPharmacie(), mvt.getProduit(), mvt.getConditionnement(), false);

    // Filtre des stocks en quarantaine.
    org.apache.commons.collections15.CollectionUtils.filter(
        lignesStock, new NotPredicate<LigneStock>(new LigneStockEnQuarantainePredicate()));

    sortie.setLignesStock(lignesStock);
  }
  @RequestMapping(value = "/map.html")
  public ModelAndView map(
      @RequestParam(value = "q1", required = false) String q1,
      @RequestParam(value = "q2", required = false) String q2,
      @RequestParam(value = "q3", required = false) String q3,
      @RequestParam(value = "if", required = false, defaultValue = UimaUtils.MIMETYPE_STRING)
          String inputFormat,
      @RequestParam(value = "of", required = true, defaultValue = "html") String outputFormat,
      @RequestParam(value = "ofs", required = false, defaultValue = "pretty")
          String outputFormatStyle,
      @RequestParam(value = "sgf", required = false) String[] styGroupFilter,
      @RequestParam(value = "scf", required = false) String[] styCodeFilter) {

    ModelAndView mav = new ModelAndView();
    mav.addObject("operation", "map");
    // validate parameters (at least one of o, q, u or t must
    // be supplied, otherwise show the input form
    mav.addObject("q1", StringUtils.isEmpty(q1) ? "" : q1);
    mav.addObject("q2", StringUtils.isEmpty(q2) ? "" : q2);
    mav.addObject("q3", StringUtils.isEmpty(q3) ? "" : q3);
    String q =
        StringUtils.isNotEmpty(q1)
            ? q1
            : StringUtils.isNotEmpty(q2) ? q2 : StringUtils.isNotEmpty(q3) ? q3 : null;
    if (StringUtils.isEmpty(q)) {
      setViewName(mav, outputFormat, outputFormatStyle);
      return mav;
    }
    try {
      if (NumberUtils.isNumber(q) && StringUtils.length(q) == 7) {
        return show(Integer.valueOf(q));
      } else {
        // show list of concepts
        String text = q;
        if ((q.startsWith("http://") && UimaUtils.MIMETYPE_HTML.equals(inputFormat))) {
          URL u = new URL(q);
          BufferedReader br = new BufferedReader(new InputStreamReader(u.openStream()));
          StringBuilder tbuf = new StringBuilder();
          String line = null;
          while ((line = br.readLine()) != null) {
            tbuf.append(line).append("\n");
          }
          br.close();
          text = tbuf.toString();
        }
        List<ConceptAnnotation> annotations = new ArrayList<ConceptAnnotation>();
        long startTs = System.currentTimeMillis();
        JCas jcas = UimaUtils.runAE(conceptMappingAE, text, inputFormat, null);
        FSIndex fsindex = jcas.getAnnotationIndex(ConceptAnnotation.type);
        for (Iterator<ConceptAnnotation> it = fsindex.iterator(); it.hasNext(); ) {
          ConceptAnnotation annotation = it.next();
          annotations.add(annotation);
        }
        CollectionUtils.filter(annotations, new StyGroupPredicate(styGroupFilter));
        CollectionUtils.filter(annotations, new StyCodePredicate(styCodeFilter));
        annotations = filterSubsumedConcepts(q, annotations);
        if (annotations.size() == 0) {
          mav.addObject("error", "No concepts found");
        } else {
          mav.addObject("text", text);
          mav.addObject("annotations", annotations);
          long endTs = System.currentTimeMillis();
          mav.addObject("elapsed", new Long(endTs - startTs));
        }
        setViewName(mav, outputFormat, outputFormatStyle);
      }
    } catch (Exception e) {
      mav.addObject("error", e.getMessage());
      setViewName(mav, outputFormat, outputFormatStyle);
    }
    return mav;
  }