use of org.olat.modules.qpool.model.QEducationalContext in project openolat by klemens.
the class QEducationalContextDAOTest method testGetItemLevels.
@Test
public void testGetItemLevels() {
String levelStr = "primary-school-" + UUID.randomUUID().toString();
QEducationalContext level = qEduContextDao.create(levelStr, true);
dbInstance.commit();
// load it
List<QEducationalContext> allLevels = qEduContextDao.getEducationalContexts();
// check the values
Assert.assertNotNull(allLevels);
Assert.assertTrue(allLevels.contains(level));
}
use of org.olat.modules.qpool.model.QEducationalContext in project openolat by klemens.
the class QEducationalContextDAOTest method testCreateAndGet_byLevel.
@Test
public void testCreateAndGet_byLevel() {
String levelStr = "onlyLevel-" + UUID.randomUUID().toString();
QEducationalContext level = qEduContextDao.create(levelStr, true);
dbInstance.commit();
// load it
QEducationalContext reloadedLevel = qEduContextDao.loadByLevel(levelStr);
// check the values
Assert.assertNotNull(reloadedLevel);
Assert.assertEquals(level.getKey(), reloadedLevel.getKey());
Assert.assertNotNull(reloadedLevel.getCreationDate());
Assert.assertEquals(levelStr, reloadedLevel.getLevel());
Assert.assertTrue(reloadedLevel.isDeletable());
}
use of org.olat.modules.qpool.model.QEducationalContext in project openolat by klemens.
the class QEducationalContextDAOTest method testDelete_deletable.
@Test
public void testDelete_deletable() {
String levelStr = "secondary-school-" + UUID.randomUUID().toString();
QEducationalContext level = qEduContextDao.create(levelStr, true);
dbInstance.commitAndCloseSession();
// delete it
boolean deleted = qEduContextDao.delete(level);
dbInstance.commitAndCloseSession();
Assert.assertTrue(deleted);
// check that the type is really, really deleted
QEducationalContext reloadedLevel = qEduContextDao.loadById(level.getKey());
Assert.assertNull(reloadedLevel);
List<QEducationalContext> allLevels = qEduContextDao.getEducationalContexts();
Assert.assertFalse(allLevels.contains(level));
}
use of org.olat.modules.qpool.model.QEducationalContext in project openolat by klemens.
the class QEducationalContextDAO method create.
public QEducationalContext create(String level, boolean deletable) {
QEducationalContext itemLevel = new QEducationalContext();
itemLevel.setCreationDate(new Date());
itemLevel.setLevel(level);
itemLevel.setDeletable(deletable);
dbInstance.getCurrentEntityManager().persist(itemLevel);
return itemLevel;
}
use of org.olat.modules.qpool.model.QEducationalContext in project openolat by klemens.
the class MetaUIFactory method getContextKeyValues.
public static KeyValues getContextKeyValues(Translator translator, QPoolService qpoolService) {
List<QEducationalContext> levels = qpoolService.getAllEducationlContexts();
String[] contextKeys = new String[levels.size()];
String[] contextValues = new String[levels.size()];
int count = 0;
for (QEducationalContext level : levels) {
contextKeys[count] = level.getLevel();
String i18nKey = "item.level." + level.getLevel().toLowerCase();
String translation = translator.translate(i18nKey);
if (i18nKey.equals(translation) || translation.length() > 256) {
translation = level.getLevel();
}
contextValues[count++] = translation;
}
return new KeyValues(contextKeys, contextValues);
}
Aggregations