/**
  * Removes the mutations that have a result from the given list of mutations.
  *
  * @param mutations the list of mutations to be filtered.
  */
 private static void filterMutationsWithResult(List<Mutation> mutations) {
   if (mutations != null) {
     // make sure that we have not got any mutations that have already an
     // result
     Session session = HibernateUtil.getSessionFactory().openSession();
     Transaction tx = session.beginTransaction();
     List<Mutation> toRemove = new ArrayList<Mutation>();
     for (Mutation m : mutations) {
       session.load(m, m.getId());
       if (m.getMutationResult() != null) {
         logger.debug("Found mutation that already has a mutation result " + m);
         toRemove.add(m);
       }
     }
     mutations.removeAll(toRemove);
     tx.commit();
     session.close();
   }
 }
  /**
   * Analyzes the mutation results for a project.
   *
   * @param mutationResultAnalyzers the mutationAnalyzers to use
   * @param analyzers
   * @param prefix the prefix for the mutations to analyze
   */
  @SuppressWarnings("unchecked")
  private static void analyzeMutations(List<MutationAnalyzer> analyzers, String prefix) {
    Session session = HibernateUtil.openSession();
    // Session session =
    // HibernateServerUtil.getSessionFactory(Server.KUBRICK).openSession();
    Transaction tx = session.beginTransaction();
    Query query = session.createQuery("FROM Mutation WHERE className LIKE '" + prefix + "%'");
    @SuppressWarnings("unchecked")
    List<Mutation> mutations = query.list();
    HtmlReport report = new HtmlAnalyzer().analyze(mutations);
    StringBuilder sb = new StringBuilder();
    sb.append("--------------------------------------------------------------------------------\n");

    for (MutationAnalyzer mutationAnalyzer : analyzers) {

      String analyzeResult = mutationAnalyzer.analyze(mutations, report);

      String str = "Results from " + mutationAnalyzer.getClass().getName() + "\n";
      report.addSummary(str, analyzeResult);
      sb.append(str);
      sb.append(analyzeResult);
      sb.append(
          "\n--------------------------------------------------------------------------------\n");
    }
    long l = getNumberOfMutationsWithoutResult(session, prefix);
    JavalancheConfiguration javalancheConfiguration =
        ConfigurationLocator.getJavalancheConfiguration();
    System.out.println(
        "Analyzed Results for mutations with prefix: "
            + javalancheConfiguration.getProjectPrefix());
    System.out.println("No results for " + l + " mutations");
    System.out.println(sb.toString());
    report.report();
    tx.commit();
    session.close();
  }