@Test public void fetchTagLawJournalEntriesWihoutCorrespondingEntryInDb() { LawJournalEntry dbLawJournalEntry = new LawJournalEntry(2000, 10, 100, "Ustawa 1"); LawJournalEntry tagLawJournalEntry1 = new LawJournalEntry(2003, 13, 203, "Ustawa 2"); LawJournalEntry tagLawJournalEntry2 = new LawJournalEntry(2004, 24, 204, "Ustawa 3"); LawJournalEntry tagLawJournalEntry3 = new LawJournalEntry(2000, 0, 100, "Ustawa 1"); LawJournalEntry tagLawJournalEntry4 = new LawJournalEntry(2003, 0, 203, "Ustawa 2"); lawJournalEntryRepository.save(dbLawJournalEntry); testPersistenceObjectFactory.createReferencedRegulationsTag(3L, "prefix_", dbLawJournalEntry, tagLawJournalEntry1); testPersistenceObjectFactory.createReferencedRegulationsTag(4L, "prefix_", tagLawJournalEntry1); testPersistenceObjectFactory.createReferencedRegulationsTag(5L, "prefix_", tagLawJournalEntry1, tagLawJournalEntry2); testPersistenceObjectFactory.createReferencedRegulationsTag(6L, "prefix_", tagLawJournalEntry3, tagLawJournalEntry4); List<LawJournalEntry> retLawJournalEntries = enrichmentTagLawJournalEntryFetcher.fetchTagLawJournalEntriesWihoutCorrespondingEntryInDb(); assertThat(retLawJournalEntries, containsInAnyOrder(tagLawJournalEntry1, tagLawJournalEntry2)); }
public List<LawJournalEntry> fetchTagLawJournalEntriesWihoutCorrespondingEntryInDb() { String select = "SELECT" + " (tagValue->'journalYear')\\:\\:text journalYear," + " max((tagValue->'journalNo')\\:\\:text) journalNo," + " (tagValue->'journalEntry')\\:\\:text journalEntry," + " max((tagValue->'journalTitle')\\:\\:text) title" + " FROM enrichment_tag tag" + " JOIN json_array_elements(tag.value) tagValue ON" + " NOT EXISTS (SELECT 1 FROM law_journal_entry lje WHERE " + " replace((tagValue->'journalYear')\\:\\:text, '\"', '')\\:\\:int = lje.year AND" + " replace((tagValue->'journalEntry')\\:\\:text, '\"', '')\\:\\:int = lje.entry)" + " WHERE tag.tag_type = '" + EnrichmentTagTypes.REFERENCED_REGULATIONS + "'" + " GROUP BY journalYear, journalEntry;"; Query query = entityManager.createNativeQuery(select); @SuppressWarnings("unchecked") List<Object[]> results = query.getResultList(); return convertToLawJournalEntries(results); }
EnrichmentTagLawJournalEntryFetcher { public List<LawJournalEntry> fetchTagLawJournalEntriesWihoutCorrespondingEntryInDb() { String select = "SELECT" + " (tagValue->'journalYear')\\:\\:text journalYear," + " max((tagValue->'journalNo')\\:\\:text) journalNo," + " (tagValue->'journalEntry')\\:\\:text journalEntry," + " max((tagValue->'journalTitle')\\:\\:text) title" + " FROM enrichment_tag tag" + " JOIN json_array_elements(tag.value) tagValue ON" + " NOT EXISTS (SELECT 1 FROM law_journal_entry lje WHERE " + " replace((tagValue->'journalYear')\\:\\:text, '\"', '')\\:\\:int = lje.year AND" + " replace((tagValue->'journalEntry')\\:\\:text, '\"', '')\\:\\:int = lje.entry)" + " WHERE tag.tag_type = '" + EnrichmentTagTypes.REFERENCED_REGULATIONS + "'" + " GROUP BY journalYear, journalEntry;"; Query query = entityManager.createNativeQuery(select); @SuppressWarnings("unchecked") List<Object[]> results = query.getResultList(); return convertToLawJournalEntries(results); } }
EnrichmentTagLawJournalEntryFetcher { public List<LawJournalEntry> fetchTagLawJournalEntriesWihoutCorrespondingEntryInDb() { String select = "SELECT" + " (tagValue->'journalYear')\\:\\:text journalYear," + " max((tagValue->'journalNo')\\:\\:text) journalNo," + " (tagValue->'journalEntry')\\:\\:text journalEntry," + " max((tagValue->'journalTitle')\\:\\:text) title" + " FROM enrichment_tag tag" + " JOIN json_array_elements(tag.value) tagValue ON" + " NOT EXISTS (SELECT 1 FROM law_journal_entry lje WHERE " + " replace((tagValue->'journalYear')\\:\\:text, '\"', '')\\:\\:int = lje.year AND" + " replace((tagValue->'journalEntry')\\:\\:text, '\"', '')\\:\\:int = lje.entry)" + " WHERE tag.tag_type = '" + EnrichmentTagTypes.REFERENCED_REGULATIONS + "'" + " GROUP BY journalYear, journalEntry;"; Query query = entityManager.createNativeQuery(select); @SuppressWarnings("unchecked") List<Object[]> results = query.getResultList(); return convertToLawJournalEntries(results); }  }
EnrichmentTagLawJournalEntryFetcher { public List<LawJournalEntry> fetchTagLawJournalEntriesWihoutCorrespondingEntryInDb() { String select = "SELECT" + " (tagValue->'journalYear')\\:\\:text journalYear," + " max((tagValue->'journalNo')\\:\\:text) journalNo," + " (tagValue->'journalEntry')\\:\\:text journalEntry," + " max((tagValue->'journalTitle')\\:\\:text) title" + " FROM enrichment_tag tag" + " JOIN json_array_elements(tag.value) tagValue ON" + " NOT EXISTS (SELECT 1 FROM law_journal_entry lje WHERE " + " replace((tagValue->'journalYear')\\:\\:text, '\"', '')\\:\\:int = lje.year AND" + " replace((tagValue->'journalEntry')\\:\\:text, '\"', '')\\:\\:int = lje.entry)" + " WHERE tag.tag_type = '" + EnrichmentTagTypes.REFERENCED_REGULATIONS + "'" + " GROUP BY journalYear, journalEntry;"; Query query = entityManager.createNativeQuery(select); @SuppressWarnings("unchecked") List<Object[]> results = query.getResultList(); return convertToLawJournalEntries(results); }  List<LawJournalEntry> fetchTagLawJournalEntriesWihoutCorrespondingEntryInDb(); }
EnrichmentTagLawJournalEntryFetcher { public List<LawJournalEntry> fetchTagLawJournalEntriesWihoutCorrespondingEntryInDb() { String select = "SELECT" + " (tagValue->'journalYear')\\:\\:text journalYear," + " max((tagValue->'journalNo')\\:\\:text) journalNo," + " (tagValue->'journalEntry')\\:\\:text journalEntry," + " max((tagValue->'journalTitle')\\:\\:text) title" + " FROM enrichment_tag tag" + " JOIN json_array_elements(tag.value) tagValue ON" + " NOT EXISTS (SELECT 1 FROM law_journal_entry lje WHERE " + " replace((tagValue->'journalYear')\\:\\:text, '\"', '')\\:\\:int = lje.year AND" + " replace((tagValue->'journalEntry')\\:\\:text, '\"', '')\\:\\:int = lje.entry)" + " WHERE tag.tag_type = '" + EnrichmentTagTypes.REFERENCED_REGULATIONS + "'" + " GROUP BY journalYear, journalEntry;"; Query query = entityManager.createNativeQuery(select); @SuppressWarnings("unchecked") List<Object[]> results = query.getResultList(); return convertToLawJournalEntries(results); }  List<LawJournalEntry> fetchTagLawJournalEntriesWihoutCorrespondingEntryInDb();  }