protected String run(
      final String description, final ExecutionYear executionYear, final String contents)
      throws Exception {

    final CardGenerationBatch cardGenerationBatch = findOrCreate(executionYear, description);
    final CardGenerationBatch cardGenerationBatchWithProblems =
        new CardGenerationBatch("Com Problemas", executionYear, true);
    final CardGenerationBatch cardGenerationBatchWithDuplicates =
        new CardGenerationBatch("Duplicados", executionYear, true);

    for (final String fline : contents.split("\n")) {
      if (!fline.isEmpty()) {
        final String identificationId =
            StringUtils.trim(fline.substring(0, 20).trim()).replace(" ", "");
        final String line = normalize(fline.substring(20)) + "\r\n";

        final Person person = findPerson(identificationId, line);
        final CardGenerationEntry cardGenerationEntry;
        if (person == null) {
          cardGenerationEntry = createEntry(cardGenerationBatch, identificationId, line);
          cardGenerationEntry.setCardGenerationBatch(cardGenerationBatchWithProblems);
          new CardGenerationProblem(
              cardGenerationBatchWithProblems, "no.person.found", identificationId, null);
        } else {
          //		    if (!hasMatchingLine(person, line)) {
          cardGenerationEntry = createEntry(cardGenerationBatch, identificationId, line, person);

          if (cardGenerationEntry != null) {
            final Category category = cardGenerationEntry.getCategory();
            if (category == Category.CODE_73
                || category == Category.CODE_82
                || category == Category.CODE_96) {
              final Category categoryForLine = CardGenerationEntry.readCategory(line);
              final String studentLine = createNewLine(person, cardGenerationBatch);
              if (studentLine == null) {
                if (category != Category.CODE_96) {
                  cardGenerationEntry.setCardGenerationBatch(cardGenerationBatchWithProblems);
                  new CardGenerationProblem(
                      cardGenerationBatchWithProblems,
                      "multiple.user.information.type.not.crossed",
                      identificationId,
                      person);
                } else if (hasMatchingLine(person, line, cardGenerationEntry)) {
                  cardGenerationEntry.setCardGenerationBatch(cardGenerationBatchWithDuplicates);
                  new CardGenerationProblem(
                      cardGenerationBatchWithDuplicates,
                      "duplicate.line.from.previous.batch",
                      identificationId,
                      person);
                }
              } else {
                final Category categoryForStudentLine =
                    CardGenerationEntry.readCategory(studentLine);
                final String newLine =
                    merge(line, categoryForLine, studentLine, categoryForStudentLine);
                if (hasMatchingLine(person, newLine, cardGenerationEntry)) {
                  cardGenerationEntry.setCardGenerationBatch(cardGenerationBatchWithDuplicates);
                  new CardGenerationProblem(
                      cardGenerationBatchWithDuplicates,
                      "duplicate.line.from.previous.batch",
                      identificationId,
                      person);
                }
                cardGenerationEntry.setLine(newLine);
              }
            } else if (cardGenerationEntry.getCardGenerationBatch() == cardGenerationBatch
                && person != null
                && person.hasRole(RoleType.STUDENT)) {
              final Category categoryForLine = CardGenerationEntry.readCategory(line);
              final String studentLine = createNewLine(person, cardGenerationBatch);
              if (studentLine == null) {
                if (hasMatchingLine(person, line, cardGenerationEntry)) {
                  cardGenerationEntry.setCardGenerationBatch(cardGenerationBatchWithDuplicates);
                  new CardGenerationProblem(
                      cardGenerationBatchWithDuplicates,
                      "duplicate.line.from.previous.batch",
                      identificationId,
                      person);
                }
                //			    		cardGenerationEntry.setCardGenerationBatch(cardGenerationBatchUnmatched);
                //			    		new CardGenerationProblem(cardGenerationBatchUnmatched,
                // "person.has.student.role.but.cannot.generate.line", identificationId, person);
              } else {
                final Category categoryForStudentLine =
                    CardGenerationEntry.readCategory(studentLine);
                final String newLine =
                    merge(line, categoryForLine, studentLine, categoryForStudentLine);
                if (hasMatchingLine(person, newLine, cardGenerationEntry)) {
                  cardGenerationEntry.setCardGenerationBatch(cardGenerationBatchWithDuplicates);
                  new CardGenerationProblem(
                      cardGenerationBatchWithDuplicates,
                      "duplicate.line.from.previous.batch",
                      identificationId,
                      person);
                }
                cardGenerationEntry.setLine(newLine);
              }
            } else {
              if (hasMatchingLine(person, line, cardGenerationEntry)) {
                cardGenerationEntry.setCardGenerationBatch(cardGenerationBatchWithDuplicates);
                new CardGenerationProblem(
                    cardGenerationBatchWithDuplicates,
                    "duplicate.line.from.previous.batch",
                    identificationId,
                    person);
              }
            }
          }
          //		    }
        }
      }
    }

    result.append("Matched " + matched + "\n");
    result.append("Multiple id matches " + multipleIdMatches + "\n");
    result.append("Multiple name matches " + multipleNameMatches + "\n");
    result.append("Unmatched " + unmatched + "\n");
    result.append("Matched lines " + matchedLines + "\n");
    result.append("New lines " + newLines + "\n");

    System.out.flush();
    System.err.flush();

    return result.toString();
  }