use of org.openmrs.ConceptStopWord in project openmrs-core by openmrs.
the class HibernateConceptDAO method saveConceptStopWord.
/**
* @see org.openmrs.api.db.ConceptDAO#saveConceptStopWord(org.openmrs.ConceptStopWord)
*/
@Override
public ConceptStopWord saveConceptStopWord(ConceptStopWord conceptStopWord) throws DAOException {
if (conceptStopWord != null) {
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(ConceptStopWord.class);
criteria.add(Restrictions.eq("value", conceptStopWord.getValue()));
criteria.add(Restrictions.eq("locale", conceptStopWord.getLocale()));
List<ConceptStopWord> stopWordList = criteria.list();
if (!stopWordList.isEmpty()) {
throw new DAOException("Duplicate ConceptStopWord Entry");
}
sessionFactory.getCurrentSession().saveOrUpdate(conceptStopWord);
}
return conceptStopWord;
}
use of org.openmrs.ConceptStopWord in project openmrs-core by openmrs.
the class ConceptServiceTest method saveConceptStopWord_shouldSaveConceptStopWordAssignDefaultLocaleIsItNull.
/**
* @see ConceptService#saveConceptStopWord(ConceptStopWord)
*/
@Test
public void saveConceptStopWord_shouldSaveConceptStopWordAssignDefaultLocaleIsItNull() {
ConceptStopWord conceptStopWord = new ConceptStopWord("The");
conceptService.saveConceptStopWord(conceptStopWord);
List<String> conceptStopWords = conceptService.getConceptStopWords(Context.getLocale());
assertThat(conceptStopWords, hasItem("THE"));
}
use of org.openmrs.ConceptStopWord in project openmrs-core by openmrs.
the class ConceptServiceTest method saveConceptStopWord_shouldSaveConceptStopWordIntoDatabase.
/**
* @see ConceptService#saveConceptStopWord(org.openmrs.ConceptStopWord)
*/
@Test
public void saveConceptStopWord_shouldSaveConceptStopWordIntoDatabase() {
ConceptStopWord conceptStopWord = new ConceptStopWord("AND", Locale.FRANCE);
conceptService.saveConceptStopWord(conceptStopWord);
List<String> conceptStopWords = conceptService.getConceptStopWords(Locale.FRANCE);
assertEquals(1, conceptStopWords.size());
assertEquals("AND", conceptStopWords.get(0));
}
use of org.openmrs.ConceptStopWord in project openmrs-core by openmrs.
the class ConceptServiceTest method saveConceptStopWord_shouldSaveReturnConceptStopWordWithId.
/**
* @see ConceptService#saveConceptStopWord(ConceptStopWord)
*/
@Test
public void saveConceptStopWord_shouldSaveReturnConceptStopWordWithId() {
ConceptStopWord conceptStopWord = new ConceptStopWord("A", Locale.UK);
ConceptStopWord savedConceptStopWord = conceptService.saveConceptStopWord(conceptStopWord);
assertNotNull(savedConceptStopWord.getId());
}
use of org.openmrs.ConceptStopWord in project openmrs-core by openmrs.
the class ConceptServiceTest method saveConceptStopWord_shouldSaveConceptStopWordInUppercase.
/**
* @see ConceptService#saveConceptStopWord(ConceptStopWord)
*/
@Test
public void saveConceptStopWord_shouldSaveConceptStopWordInUppercase() {
ConceptStopWord conceptStopWord = new ConceptStopWord("lowertoupper");
ConceptStopWord savedConceptStopWord = conceptService.saveConceptStopWord(conceptStopWord);
assertEquals("LOWERTOUPPER", savedConceptStopWord.getValue());
}
Aggregations