@Test public void extractJudges_JudgeAddedTwice() { String janOlkowski = "Jan Olkowski"; String adamNowak = "Adam Nowak"; sJudgment.setChairman(janOlkowski); sJudgment.setJudges(Lists.newArrayList(janOlkowski, janOlkowski, adamNowak, adamNowak)); Judge judgeJanOlkowski = new Judge(janOlkowski, JudgeRole.PRESIDING_JUDGE); Judge judgeNotPresidingJanOlkowski = new Judge(janOlkowski); Judge judgeAdamNowak = new Judge(adamNowak); when(judgeConverter.convertJudge(janOlkowski, Lists.newArrayList(JudgeRole.PRESIDING_JUDGE), correctionList)).thenReturn(judgeJanOlkowski); when(judgeConverter.convertJudge(janOlkowski, correctionList)).thenReturn(judgeNotPresidingJanOlkowski); when(judgeConverter.convertJudge(adamNowak, correctionList)).thenReturn(judgeAdamNowak); List<Judge> judges = sourceCcJudgmentExtractor.extractJudges(sJudgment, correctionList); assertEquals(sJudgment.getJudges().size(), judges.size()); List<Judge> presidingJudges = judges.stream().filter(j->j.getSpecialRoles().contains(JudgeRole.PRESIDING_JUDGE)).collect(Collectors.toList()); assertEquals(1, presidingJudges.size()); assertEquals(sJudgment.getChairman(), presidingJudges.get(0).getName()); List<String> commonJudges = judges.stream().filter(j->j.getSpecialRoles().isEmpty()).map(j->j.getName()).collect(Collectors.toList()); assertEquals(3, commonJudges.size()); assertThat(commonJudges, Matchers.containsInAnyOrder(janOlkowski, adamNowak, adamNowak)); }
@Override public List<Judge> extractJudges(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList) { List<Judge> judges = Lists.newArrayList(); if (StringUtils.isNotBlank(sourceJudgment.getChairman())) { Judge judge = judgeConverter.convertJudge(sourceJudgment.getChairman(), Lists.newArrayList(JudgeRole.PRESIDING_JUDGE), correctionList); if (judge != null) { judges.add(judge); } } if (CollectionUtils.isEmpty(sourceJudgment.getJudges())) { return judges; } boolean chairmanAppeared = false; for (String judgeName : sourceJudgment.getJudges()) { if (StringUtils.equalsIgnoreCase(sourceJudgment.getChairman(), judgeName) && !chairmanAppeared) { chairmanAppeared = true; continue; } Judge judge = judgeConverter.convertJudge(judgeName, correctionList); if (judge != null) { judges.add(judge); } } return judges; }
SourceCcJudgmentExtractor implements JudgmentDataExtractor<CommonCourtJudgment, SourceCcJudgment> { @Override public List<Judge> extractJudges(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList) { List<Judge> judges = Lists.newArrayList(); if (StringUtils.isNotBlank(sourceJudgment.getChairman())) { Judge judge = judgeConverter.convertJudge(sourceJudgment.getChairman(), Lists.newArrayList(JudgeRole.PRESIDING_JUDGE), correctionList); if (judge != null) { judges.add(judge); } } if (CollectionUtils.isEmpty(sourceJudgment.getJudges())) { return judges; } boolean chairmanAppeared = false; for (String judgeName : sourceJudgment.getJudges()) { if (StringUtils.equalsIgnoreCase(sourceJudgment.getChairman(), judgeName) && !chairmanAppeared) { chairmanAppeared = true; continue; } Judge judge = judgeConverter.convertJudge(judgeName, correctionList); if (judge != null) { judges.add(judge); } } return judges; } }
SourceCcJudgmentExtractor implements JudgmentDataExtractor<CommonCourtJudgment, SourceCcJudgment> { @Override public List<Judge> extractJudges(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList) { List<Judge> judges = Lists.newArrayList(); if (StringUtils.isNotBlank(sourceJudgment.getChairman())) { Judge judge = judgeConverter.convertJudge(sourceJudgment.getChairman(), Lists.newArrayList(JudgeRole.PRESIDING_JUDGE), correctionList); if (judge != null) { judges.add(judge); } } if (CollectionUtils.isEmpty(sourceJudgment.getJudges())) { return judges; } boolean chairmanAppeared = false; for (String judgeName : sourceJudgment.getJudges()) { if (StringUtils.equalsIgnoreCase(sourceJudgment.getChairman(), judgeName) && !chairmanAppeared) { chairmanAppeared = true; continue; } Judge judge = judgeConverter.convertJudge(judgeName, correctionList); if (judge != null) { judges.add(judge); } } return judges; }  }
SourceCcJudgmentExtractor implements JudgmentDataExtractor<CommonCourtJudgment, SourceCcJudgment> { @Override public List<Judge> extractJudges(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList) { List<Judge> judges = Lists.newArrayList(); if (StringUtils.isNotBlank(sourceJudgment.getChairman())) { Judge judge = judgeConverter.convertJudge(sourceJudgment.getChairman(), Lists.newArrayList(JudgeRole.PRESIDING_JUDGE), correctionList); if (judge != null) { judges.add(judge); } } if (CollectionUtils.isEmpty(sourceJudgment.getJudges())) { return judges; } boolean chairmanAppeared = false; for (String judgeName : sourceJudgment.getJudges()) { if (StringUtils.equalsIgnoreCase(sourceJudgment.getChairman(), judgeName) && !chairmanAppeared) { chairmanAppeared = true; continue; } Judge judge = judgeConverter.convertJudge(judgeName, correctionList); if (judge != null) { judges.add(judge); } } return judges; }  @Override void convertSpecific(CommonCourtJudgment ccJudgment, SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override CommonCourtJudgment createNewJudgment(); @Override ArrayList<String> extractLegalBases(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override String extractSummary(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override String extractDecision(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override ArrayList<String> extractCourtReporters(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override LocalDate extractJudgmentDate(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override List<CourtCase> extractCourtCases(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override JudgmentTextContent extractTextContent(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override List<JudgmentReferencedRegulation> extractReferencedRegulations(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override SourceCode getSourceCode(); @Override String extractSourceJudgmentId(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override String extractSourceJudgmentUrl(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override String extractPublisher(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override String extractReviser(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override DateTime extractPublicationDate(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override LocalDate extractReceiptDate(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override List<String> extractLowerCourtJudgments(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override MeansOfAppeal extractMeansOfAppeal(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override JudgmentResult extractJudgmentResult(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override List<Judge> extractJudges(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override JudgmentType extractJudgmentType(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Autowired void setCommonCourtRepository(CommonCourtRepository commonCourtRepository); @Autowired void setCcDivisionRepository(CcDivisionRepository ccDivisionRepository); @Autowired void setCcJudgmentKeywordCreator(JudgmentKeywordCreator ccJudgmentKeywordCreator); @Autowired void setLawJournalEntryCreator(LawJournalEntryCreator lawJournalEntryCreator); @Autowired void setLawJournalEntryExtractor(LawJournalEntryExtractor lawJournalEntryExtractor); @Autowired void setJudgeConverter(JudgeConverter judgeConverter); }
SourceCcJudgmentExtractor implements JudgmentDataExtractor<CommonCourtJudgment, SourceCcJudgment> { @Override public List<Judge> extractJudges(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList) { List<Judge> judges = Lists.newArrayList(); if (StringUtils.isNotBlank(sourceJudgment.getChairman())) { Judge judge = judgeConverter.convertJudge(sourceJudgment.getChairman(), Lists.newArrayList(JudgeRole.PRESIDING_JUDGE), correctionList); if (judge != null) { judges.add(judge); } } if (CollectionUtils.isEmpty(sourceJudgment.getJudges())) { return judges; } boolean chairmanAppeared = false; for (String judgeName : sourceJudgment.getJudges()) { if (StringUtils.equalsIgnoreCase(sourceJudgment.getChairman(), judgeName) && !chairmanAppeared) { chairmanAppeared = true; continue; } Judge judge = judgeConverter.convertJudge(judgeName, correctionList); if (judge != null) { judges.add(judge); } } return judges; }  @Override void convertSpecific(CommonCourtJudgment ccJudgment, SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override CommonCourtJudgment createNewJudgment(); @Override ArrayList<String> extractLegalBases(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override String extractSummary(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override String extractDecision(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override ArrayList<String> extractCourtReporters(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override LocalDate extractJudgmentDate(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override List<CourtCase> extractCourtCases(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override JudgmentTextContent extractTextContent(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override List<JudgmentReferencedRegulation> extractReferencedRegulations(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override SourceCode getSourceCode(); @Override String extractSourceJudgmentId(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override String extractSourceJudgmentUrl(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override String extractPublisher(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override String extractReviser(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override DateTime extractPublicationDate(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override LocalDate extractReceiptDate(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override List<String> extractLowerCourtJudgments(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override MeansOfAppeal extractMeansOfAppeal(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override JudgmentResult extractJudgmentResult(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override List<Judge> extractJudges(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Override JudgmentType extractJudgmentType(SourceCcJudgment sourceJudgment, ImportCorrectionList correctionList); @Autowired void setCommonCourtRepository(CommonCourtRepository commonCourtRepository); @Autowired void setCcDivisionRepository(CcDivisionRepository ccDivisionRepository); @Autowired void setCcJudgmentKeywordCreator(JudgmentKeywordCreator ccJudgmentKeywordCreator); @Autowired void setLawJournalEntryCreator(LawJournalEntryCreator lawJournalEntryCreator); @Autowired void setLawJournalEntryExtractor(LawJournalEntryExtractor lawJournalEntryExtractor); @Autowired void setJudgeConverter(JudgeConverter judgeConverter);  }