コード例 #1
0
      /**
       * @param p le résultat de la pratique
       * @throws JrafDaoException si erreur JRAF
       * @return le coût
       * @throws NumberFormatException si erreur de format
       */
      private Integer getCost(PracticeResultBO p) throws JrafDaoException, NumberFormatException {

        if (!mCache.containsKey(p)) {
          MarkDAOImpl markDAO = MarkDAOImpl.getInstance();
          MeasureDAOImpl measureDAO = MeasureDAOImpl.getInstance();
          int nbcorrections = 0;
          PracticeRuleBO rule =
              (PracticeRuleBO)
                  PracticeRuleAPDAOImpl.getInstance().load(pSession, new Long(p.getRule().getId()));
          // Rulechecking ?
          if ((rule.getFormula() != null)
              && rule.getFormula().getComponentLevel().equals("project")) {
            // Récupération des types de mesure traités par la formule
            AbstractFormulaBO formula = rule.getFormula();
            // Pour chaque type de mesure, on va récupérer le nom de sa classe
            String[] measureKinds = new String[formula.getMeasureKinds().size()];
            formula.getMeasureKinds().toArray(measureKinds);
            for (int i = 0; i < measureKinds.length; i++) {
              Class currentClass =
                  Mapping.getMeasureClass(measureKinds[i] + "." + formula.getComponentLevel());
              if (currentClass.getSuperclass().equals(RuleCheckingTransgressionBO.class)) {
                RuleCheckingTransgressionBO trans =
                    (RuleCheckingTransgressionBO)
                        measureDAO.load(
                            pSession,
                            new Long(Long.parseLong(pProjectId)),
                            new Long(Long.parseLong(pAuditId)),
                            currentClass);
                nbcorrections +=
                    trans.getTotalInfoNumberForCategory(rule.getName())
                        + trans.getTotalWarningNumberForCategory(rule.getName())
                        + trans.getTotalErrorNumberForCategory(rule.getName());
              }
            }
          } else {
            // On récupère les plus mauvais composants pour cette pratiques
            /*
             * We retrieve, for a given practice, the number of technical component which have a worst
             * practice mark than the mark of the same practice at the project level
             */
            nbcorrections = markDAO.countWorstWhere(pSession, new Long(p.getId()), p.getMeanMark());
          }
          mCache.put(p, new Integer(nbcorrections * rule.getEffort()));
        }
        return (Integer) mCache.get(p);
      }
コード例 #2
0
 /**
  * @param pFormulaBO formule
  * @param pFormulaDTO formule
  */
 private void setAttributes(AbstractFormulaBO pFormulaBO, AbstractFormulaDTO pFormulaDTO) {
   pFormulaDTO.setComponentLevel(pFormulaBO.getComponentLevel());
   pFormulaDTO.setTriggerCondition(pFormulaBO.getTriggerCondition());
   pFormulaDTO.setMeasureKinds(pFormulaBO.getMeasureKinds());
 }