generated from digitalservicebund/java-application-template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use migration schema for norm abbreviation (#791)
* Use migration schema for norm abbreviation * Use migration schema for norm element * Make norm abbreviation test reliable * Extend migration schema local doc * Remove reactive from most of norm abbr * Add legacy doc_unit_id column in norm reference --- Co-authored-by: Ralph von Petersdorff-Campen <ralph.vonpetersdorffcampen@digitalservice.bund.de>
- Loading branch information
Showing
89 changed files
with
1,359 additions
and
1,601 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...d/digitalservice/ris/caselaw/adapter/database/jpa/DatabaseDocumentCategoryRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package de.bund.digitalservice.ris.caselaw.adapter.database.jpa; | ||
|
||
import java.util.UUID; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface DatabaseDocumentCategoryRepository | ||
extends JpaRepository<DocumentCategoryDTO, UUID> { | ||
|
||
DocumentCategoryDTO findFirstByLabel(String label); | ||
} |
38 changes: 38 additions & 0 deletions
38
.../bund/digitalservice/ris/caselaw/adapter/database/jpa/DatabaseDocumentTypeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package de.bund.digitalservice.ris.caselaw.adapter.database.jpa; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.stereotype.Repository; | ||
|
||
/** */ | ||
@Repository | ||
public interface DatabaseDocumentTypeRepository extends JpaRepository<DocumentTypeDTO, UUID> { | ||
|
||
DocumentTypeDTO findFirstByAbbreviationAndCategory( | ||
String jurisShortcut, DocumentCategoryDTO category); | ||
|
||
List<DocumentTypeDTO> findAllByCategoryOrderByAbbreviationAscLabelAsc( | ||
DocumentCategoryDTO category); | ||
|
||
// see query explanation in CourtRepository, it's almost the same | ||
@Query( | ||
nativeQuery = true, | ||
value = | ||
"WITH label_added AS (SELECT *, " | ||
+ " UPPER(CONCAT(abbreviation, ' ', label)) AS concat" | ||
+ " from incremental_migration.document_type) " | ||
+ "SELECT *," | ||
+ " concat, " | ||
+ " CASE " | ||
+ " WHEN concat LIKE UPPER(:searchStr||'%') THEN 1 " | ||
+ " WHEN concat LIKE UPPER('% '||:searchStr||'%') THEN 2 " | ||
+ " WHEN concat LIKE UPPER('%-'||:searchStr||'%') THEN 2 " | ||
+ " ELSE 3 " | ||
+ " END AS weight " | ||
+ "FROM label_added " | ||
+ "WHERE concat LIKE UPPER('%'||:searchStr||'%') AND document_category_id = :category " | ||
+ "ORDER BY weight, concat") | ||
List<DocumentTypeDTO> findCaselawBySearchStrAndCategory(String searchStr, UUID category); | ||
} |
58 changes: 58 additions & 0 deletions
58
...d/digitalservice/ris/caselaw/adapter/database/jpa/DatabaseNormAbbreviationRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package de.bund.digitalservice.ris.caselaw.adapter.database.jpa; | ||
|
||
import jakarta.transaction.Transactional; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
@Primary | ||
public interface DatabaseNormAbbreviationRepository | ||
extends JpaRepository<NormAbbreviationDTO, UUID> { | ||
|
||
List<NormAbbreviationDTO> findByAbbreviationIgnoreCase(String abbreviation, PageRequest of); | ||
|
||
List<NormAbbreviationDTO> findByAbbreviationStartsWithOrderByAbbreviation( | ||
String query, PageRequest of); | ||
|
||
List<NormAbbreviationDTO> findByOfficialLetterAbbreviationIgnoreCase( | ||
String officialLetterAbbreviation, PageRequest of); | ||
|
||
List<NormAbbreviationDTO> findByAbbreviationStartsWithIgnoreCase( | ||
String abbreviation, PageRequest of); | ||
|
||
List<NormAbbreviationDTO> findByOfficialLetterAbbreviationStartsWithIgnoreCase( | ||
String officialLetterAbbreviation, PageRequest size); | ||
|
||
@Query( | ||
value = | ||
"select" | ||
+ " id," | ||
+ " abbreviation," | ||
+ " decision_date," | ||
+ " document_id," | ||
+ " document_number," | ||
+ " official_letter_abbreviation," | ||
+ " official_long_title," | ||
+ " official_short_title," | ||
+ " source," | ||
+ " region_id," | ||
+ " ts_rank_cd(weighted_vector, to_tsquery('german', '' || :tsQuery || '')) rank" | ||
+ " from norm_abbreviation_search_migration" | ||
+ " where weighted_vector @@ to_tsquery('german', '' || :tsQuery || '')" | ||
+ " order by rank desc" | ||
+ " limit :size" | ||
+ " offset :offset", | ||
nativeQuery = true) | ||
List<NormAbbreviationDTO> findByRankWeightedVector(String tsQuery, Integer size, Integer offset); | ||
|
||
@Transactional | ||
@Modifying | ||
@Query(value = "REFRESH MATERIALIZED VIEW norm_abbreviation_search_migration", nativeQuery = true) | ||
void refreshMaterializedViews(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...bund/digitalservice/ris/caselaw/adapter/database/jpa/DatabaseNormReferenceRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package de.bund.digitalservice.ris.caselaw.adapter.database.jpa; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface DatabaseNormReferenceRepository extends JpaRepository<NormReferenceDTO, UUID> { | ||
List<NormReferenceDTO> findAllByLegacyDocUnitIdOrderById(UUID documentationUnitId); | ||
} |
3 changes: 2 additions & 1 deletion
3
...tabase/jpa/JPADocumentTypeRepository.java → ...atabase/jpa/DatabaseRegionRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
package de.bund.digitalservice.ris.caselaw.adapter.database.jpa; | ||
|
||
import java.util.UUID; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface JPADocumentTypeRepository extends JpaRepository<JPADocumentTypeDTO, Long> {} | ||
public interface DatabaseRegionRepository extends JpaRepository<RegionDTO, UUID> {} |
26 changes: 26 additions & 0 deletions
26
...ain/java/de/bund/digitalservice/ris/caselaw/adapter/database/jpa/DocumentCategoryDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package de.bund.digitalservice.ris.caselaw.adapter.database.jpa; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import java.util.UUID; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
@Entity | ||
@Table(name = "document_category", schema = "incremental_migration") | ||
public class DocumentCategoryDTO { | ||
@Id @GeneratedValue private UUID id; | ||
|
||
@Column private String label; | ||
} |
Oops, something went wrong.