forked from ZFIN/zfin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZFIN-9407: Use
unaccent
postgresql function to allow searches for a…
…uthors with accented letters. (ZFIN#1221) * Use `unaccent` postgresql function to allow searches for authors with accented letters. * Use sets to avoid boilerplate duplication checks * add to 1163/db.changelog.master.xml
- Loading branch information
1 parent
ab03257
commit 66c6a6d
Showing
6 changed files
with
74 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--liquibase formatted sql | ||
--changeset rtaylor:ZFIN-9407.sql | ||
|
||
CREATE EXTENSION unaccent; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.zfin.publication; | ||
|
||
import org.junit.Test; | ||
import org.zfin.AbstractDatabaseTest; | ||
import org.zfin.profile.Person; | ||
import org.zfin.publication.presentation.PublicationService; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.zfin.repository.RepositoryFactory.getProfileRepository; | ||
|
||
public class PublicationServiceTest extends AbstractDatabaseTest { | ||
|
||
@Test | ||
public void testAuthorSuggestionWithAccents() { | ||
List<String> queries = List.of("Ozhan, Gunes", "Ozhan, G", "Ozha, G", "Ozhan", "Ozha"); | ||
List<String> accentedQueries = List.of("Özhan, Günes", "Özhan, G", "Özha, G", "Özhan", "Özha"); | ||
|
||
Person author = getProfileRepository().getPerson("ZDB-PERS-100120-1"); | ||
PublicationService publicationService = new PublicationService(); | ||
|
||
List<Person> authorList; | ||
for(String query : queries) { | ||
authorList = publicationService.getAuthorSuggestions(query); | ||
assertNotNull(authorList); | ||
assertTrue(authorList.size() > 0); | ||
assertTrue(authorList.contains(author)); | ||
} | ||
|
||
for(String query : accentedQueries) { | ||
authorList = publicationService.getAuthorSuggestions(query); | ||
assertNotNull(authorList); | ||
assertTrue(authorList.size() > 0); | ||
assertTrue(authorList.contains(author)); | ||
} | ||
|
||
authorList = publicationService.getAuthorSuggestions("Ozhan, Gunes"); | ||
assertNotNull(authorList); | ||
assertEquals(1, authorList.size()); | ||
} | ||
} | ||
|