@Test public void translateSingle_SUPREME_COURT_defective_court_chamber() { SolrDocument doc = new SolrDocument(); doc.addField("databaseId", 1l); doc.addField("scCourtChamber", "11"); JudgmentSearchResult result = resultsTranslator.translateSingle(doc); assertEquals(0, result.getScCourtChambers().size()); }
@Override public JudgmentSearchResult translateSingle(SolrDocument document) { JudgmentSearchResult result = new JudgmentSearchResult(); Long databaseId = fieldFetcher.fetchLongValue(document, JudgmentIndexField.DATABASE_ID); result.setId(databaseId); List<String> caseNumbers = fieldFetcher.fetchValues(document, JudgmentIndexField.CASE_NUMBER); result.setCaseNumbers(caseNumbers); String judgmentTypeString = fieldFetcher.fetchValue(document, JudgmentIndexField.JUDGMENT_TYPE); if (judgmentTypeString != null) { JudgmentType judgmentType = JudgmentType.valueOf(judgmentTypeString); result.setJudgmentType(judgmentType); } LocalDate judgmentDate = fieldFetcher.fetchDateValue(document, JudgmentIndexField.JUDGMENT_DATE); result.setJudgmentDate(judgmentDate); Long referencingCount = fieldFetcher.fetchLongValue(document, JudgmentIndexField.REFERENCING_JUDGMENTS_COUNT); if (referencingCount != null) { result.setReferencingCount(referencingCount); } BigDecimal maxMoneyAmount = fieldFetcher.fetchCurrencyValue(document, JudgmentIndexField.MAXIMUM_MONEY_AMOUNT); if (maxMoneyAmount != null) { result.setMaxMoneyAmount(maxMoneyAmount); } String courtTypeString = fieldFetcher.fetchValue(document, JudgmentIndexField.COURT_TYPE); if (courtTypeString != null) { CourtType courtType = CourtType.valueOf(courtTypeString); result.setCourtType(courtType); } translateCommonCourt(document, result); translateSupremeCourt(document, result); List<JudgeResult> judges = Lists.newArrayList(); List<Pair<String, List<JudgeRole>>> judgesWithRoleAttributes = fieldFetcher.fetchValuesWithEnumedAttributes(document, JudgmentIndexField.JUDGE, JudgeRole.class); judgesWithRoleAttributes.forEach(p -> judges.add(new JudgeResult(p.getLeft(), p.getRight().toArray(new JudgeRole[0])))); result.setJudges(judges); List<String> keywords = fieldFetcher.fetchValues(document, JudgmentIndexField.KEYWORD); result.setKeywords(keywords); String content = fieldFetcher.fetchValue(document, JudgmentIndexField.CONTENT); result.setContent(content); return result; }
JudgmentSearchResultTranslator implements SearchResultTranslator<JudgmentSearchResult> { @Override public JudgmentSearchResult translateSingle(SolrDocument document) { JudgmentSearchResult result = new JudgmentSearchResult(); Long databaseId = fieldFetcher.fetchLongValue(document, JudgmentIndexField.DATABASE_ID); result.setId(databaseId); List<String> caseNumbers = fieldFetcher.fetchValues(document, JudgmentIndexField.CASE_NUMBER); result.setCaseNumbers(caseNumbers); String judgmentTypeString = fieldFetcher.fetchValue(document, JudgmentIndexField.JUDGMENT_TYPE); if (judgmentTypeString != null) { JudgmentType judgmentType = JudgmentType.valueOf(judgmentTypeString); result.setJudgmentType(judgmentType); } LocalDate judgmentDate = fieldFetcher.fetchDateValue(document, JudgmentIndexField.JUDGMENT_DATE); result.setJudgmentDate(judgmentDate); Long referencingCount = fieldFetcher.fetchLongValue(document, JudgmentIndexField.REFERENCING_JUDGMENTS_COUNT); if (referencingCount != null) { result.setReferencingCount(referencingCount); } BigDecimal maxMoneyAmount = fieldFetcher.fetchCurrencyValue(document, JudgmentIndexField.MAXIMUM_MONEY_AMOUNT); if (maxMoneyAmount != null) { result.setMaxMoneyAmount(maxMoneyAmount); } String courtTypeString = fieldFetcher.fetchValue(document, JudgmentIndexField.COURT_TYPE); if (courtTypeString != null) { CourtType courtType = CourtType.valueOf(courtTypeString); result.setCourtType(courtType); } translateCommonCourt(document, result); translateSupremeCourt(document, result); List<JudgeResult> judges = Lists.newArrayList(); List<Pair<String, List<JudgeRole>>> judgesWithRoleAttributes = fieldFetcher.fetchValuesWithEnumedAttributes(document, JudgmentIndexField.JUDGE, JudgeRole.class); judgesWithRoleAttributes.forEach(p -> judges.add(new JudgeResult(p.getLeft(), p.getRight().toArray(new JudgeRole[0])))); result.setJudges(judges); List<String> keywords = fieldFetcher.fetchValues(document, JudgmentIndexField.KEYWORD); result.setKeywords(keywords); String content = fieldFetcher.fetchValue(document, JudgmentIndexField.CONTENT); result.setContent(content); return result; } }
JudgmentSearchResultTranslator implements SearchResultTranslator<JudgmentSearchResult> { @Override public JudgmentSearchResult translateSingle(SolrDocument document) { JudgmentSearchResult result = new JudgmentSearchResult(); Long databaseId = fieldFetcher.fetchLongValue(document, JudgmentIndexField.DATABASE_ID); result.setId(databaseId); List<String> caseNumbers = fieldFetcher.fetchValues(document, JudgmentIndexField.CASE_NUMBER); result.setCaseNumbers(caseNumbers); String judgmentTypeString = fieldFetcher.fetchValue(document, JudgmentIndexField.JUDGMENT_TYPE); if (judgmentTypeString != null) { JudgmentType judgmentType = JudgmentType.valueOf(judgmentTypeString); result.setJudgmentType(judgmentType); } LocalDate judgmentDate = fieldFetcher.fetchDateValue(document, JudgmentIndexField.JUDGMENT_DATE); result.setJudgmentDate(judgmentDate); Long referencingCount = fieldFetcher.fetchLongValue(document, JudgmentIndexField.REFERENCING_JUDGMENTS_COUNT); if (referencingCount != null) { result.setReferencingCount(referencingCount); } BigDecimal maxMoneyAmount = fieldFetcher.fetchCurrencyValue(document, JudgmentIndexField.MAXIMUM_MONEY_AMOUNT); if (maxMoneyAmount != null) { result.setMaxMoneyAmount(maxMoneyAmount); } String courtTypeString = fieldFetcher.fetchValue(document, JudgmentIndexField.COURT_TYPE); if (courtTypeString != null) { CourtType courtType = CourtType.valueOf(courtTypeString); result.setCourtType(courtType); } translateCommonCourt(document, result); translateSupremeCourt(document, result); List<JudgeResult> judges = Lists.newArrayList(); List<Pair<String, List<JudgeRole>>> judgesWithRoleAttributes = fieldFetcher.fetchValuesWithEnumedAttributes(document, JudgmentIndexField.JUDGE, JudgeRole.class); judgesWithRoleAttributes.forEach(p -> judges.add(new JudgeResult(p.getLeft(), p.getRight().toArray(new JudgeRole[0])))); result.setJudges(judges); List<String> keywords = fieldFetcher.fetchValues(document, JudgmentIndexField.KEYWORD); result.setKeywords(keywords); String content = fieldFetcher.fetchValue(document, JudgmentIndexField.CONTENT); result.setContent(content); return result; }  }
JudgmentSearchResultTranslator implements SearchResultTranslator<JudgmentSearchResult> { @Override public JudgmentSearchResult translateSingle(SolrDocument document) { JudgmentSearchResult result = new JudgmentSearchResult(); Long databaseId = fieldFetcher.fetchLongValue(document, JudgmentIndexField.DATABASE_ID); result.setId(databaseId); List<String> caseNumbers = fieldFetcher.fetchValues(document, JudgmentIndexField.CASE_NUMBER); result.setCaseNumbers(caseNumbers); String judgmentTypeString = fieldFetcher.fetchValue(document, JudgmentIndexField.JUDGMENT_TYPE); if (judgmentTypeString != null) { JudgmentType judgmentType = JudgmentType.valueOf(judgmentTypeString); result.setJudgmentType(judgmentType); } LocalDate judgmentDate = fieldFetcher.fetchDateValue(document, JudgmentIndexField.JUDGMENT_DATE); result.setJudgmentDate(judgmentDate); Long referencingCount = fieldFetcher.fetchLongValue(document, JudgmentIndexField.REFERENCING_JUDGMENTS_COUNT); if (referencingCount != null) { result.setReferencingCount(referencingCount); } BigDecimal maxMoneyAmount = fieldFetcher.fetchCurrencyValue(document, JudgmentIndexField.MAXIMUM_MONEY_AMOUNT); if (maxMoneyAmount != null) { result.setMaxMoneyAmount(maxMoneyAmount); } String courtTypeString = fieldFetcher.fetchValue(document, JudgmentIndexField.COURT_TYPE); if (courtTypeString != null) { CourtType courtType = CourtType.valueOf(courtTypeString); result.setCourtType(courtType); } translateCommonCourt(document, result); translateSupremeCourt(document, result); List<JudgeResult> judges = Lists.newArrayList(); List<Pair<String, List<JudgeRole>>> judgesWithRoleAttributes = fieldFetcher.fetchValuesWithEnumedAttributes(document, JudgmentIndexField.JUDGE, JudgeRole.class); judgesWithRoleAttributes.forEach(p -> judges.add(new JudgeResult(p.getLeft(), p.getRight().toArray(new JudgeRole[0])))); result.setJudges(judges); List<String> keywords = fieldFetcher.fetchValues(document, JudgmentIndexField.KEYWORD); result.setKeywords(keywords); String content = fieldFetcher.fetchValue(document, JudgmentIndexField.CONTENT); result.setContent(content); return result; }  @Override JudgmentSearchResult translateSingle(SolrDocument document); @Override void applyHighlighting(Map<String, List<String>> documentHighlighting, JudgmentSearchResult result); @Autowired void setFieldFetcher(SolrFieldFetcher<JudgmentIndexField> fieldFetcher); @Autowired void setHighlightFragmentsMerger(
            SolrHighlightFragmentsMerger<JudgmentIndexField> highlightFragmentsMerger); }
JudgmentSearchResultTranslator implements SearchResultTranslator<JudgmentSearchResult> { @Override public JudgmentSearchResult translateSingle(SolrDocument document) { JudgmentSearchResult result = new JudgmentSearchResult(); Long databaseId = fieldFetcher.fetchLongValue(document, JudgmentIndexField.DATABASE_ID); result.setId(databaseId); List<String> caseNumbers = fieldFetcher.fetchValues(document, JudgmentIndexField.CASE_NUMBER); result.setCaseNumbers(caseNumbers); String judgmentTypeString = fieldFetcher.fetchValue(document, JudgmentIndexField.JUDGMENT_TYPE); if (judgmentTypeString != null) { JudgmentType judgmentType = JudgmentType.valueOf(judgmentTypeString); result.setJudgmentType(judgmentType); } LocalDate judgmentDate = fieldFetcher.fetchDateValue(document, JudgmentIndexField.JUDGMENT_DATE); result.setJudgmentDate(judgmentDate); Long referencingCount = fieldFetcher.fetchLongValue(document, JudgmentIndexField.REFERENCING_JUDGMENTS_COUNT); if (referencingCount != null) { result.setReferencingCount(referencingCount); } BigDecimal maxMoneyAmount = fieldFetcher.fetchCurrencyValue(document, JudgmentIndexField.MAXIMUM_MONEY_AMOUNT); if (maxMoneyAmount != null) { result.setMaxMoneyAmount(maxMoneyAmount); } String courtTypeString = fieldFetcher.fetchValue(document, JudgmentIndexField.COURT_TYPE); if (courtTypeString != null) { CourtType courtType = CourtType.valueOf(courtTypeString); result.setCourtType(courtType); } translateCommonCourt(document, result); translateSupremeCourt(document, result); List<JudgeResult> judges = Lists.newArrayList(); List<Pair<String, List<JudgeRole>>> judgesWithRoleAttributes = fieldFetcher.fetchValuesWithEnumedAttributes(document, JudgmentIndexField.JUDGE, JudgeRole.class); judgesWithRoleAttributes.forEach(p -> judges.add(new JudgeResult(p.getLeft(), p.getRight().toArray(new JudgeRole[0])))); result.setJudges(judges); List<String> keywords = fieldFetcher.fetchValues(document, JudgmentIndexField.KEYWORD); result.setKeywords(keywords); String content = fieldFetcher.fetchValue(document, JudgmentIndexField.CONTENT); result.setContent(content); return result; }  @Override JudgmentSearchResult translateSingle(SolrDocument document); @Override void applyHighlighting(Map<String, List<String>> documentHighlighting, JudgmentSearchResult result); @Autowired void setFieldFetcher(SolrFieldFetcher<JudgmentIndexField> fieldFetcher); @Autowired void setHighlightFragmentsMerger(
            SolrHighlightFragmentsMerger<JudgmentIndexField> highlightFragmentsMerger);  }