use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class CodeListManagerIntegrationTest method loadItemsByLevelTest.
@Test
public void loadItemsByLevelTest() {
CodeList list = survey.getCodeList("admin_unit");
List<CodeListItem> rootItems = codeListManager.loadItems(list, 1);
assertEquals(8, rootItems.size());
{
CodeListItem item = rootItems.get(1);
assertEquals("002", item.getCode());
}
List<CodeListItem> secondLevelItems = codeListManager.loadItems(list, 2);
assertEquals(23, secondLevelItems.size());
{
CodeListItem item = secondLevelItems.get(1);
assertEquals("002", item.getCode());
}
}
use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class SurveyManagerIntegrationTest method publishSurveyCodeListsTest.
@Test
public void publishSurveyCodeListsTest() throws SurveyImportException {
CollectSurvey surveyWork = surveyManager.createTemporarySurveyFromPublished(survey.getUri(), adminUser);
{
// modify item in list
CodeList list = surveyWork.getCodeList("admin_unit");
PersistedCodeListItem item = codeListManager.loadRootItem(list, "001", null);
assertEquals(Integer.valueOf(1), item.getSortOrder());
item.setCode("001A");
codeListManager.save(item);
}
surveyManager.publish(surveyWork, adminUser);
CollectSurvey publishedSurvey = surveyManager.getByUri(surveyWork.getUri());
CodeList list = publishedSurvey.getCodeList("admin_unit");
List<CodeListItem> rootItems = codeListManager.loadRootItems(list);
assertEquals(8, rootItems.size());
{
PersistedCodeListItem item = codeListManager.loadRootItem(list, "001A", null);
assertEquals(Integer.valueOf(1), item.getSortOrder());
}
{
PersistedCodeListItem item = codeListManager.loadRootItem(list, "001", null);
assertNull(item);
}
}
use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class CodeListItemDaoIntegrationTest method persistedFlatListTest.
@Test
public void persistedFlatListTest() {
CodeList list = survey.getCodeList("measurement");
List<PersistedCodeListItem> rootItems = codeListItemDao.loadRootItems(list);
assertEquals(3, rootItems.size());
{
PersistedCodeListItem item = rootItems.get(0);
assertEquals("P", item.getCode());
assertEquals(Integer.valueOf(1), item.getSortOrder());
assertEquals("Planned", item.getLabel(EN_LANG_CODE));
assertEquals("Planned as part of original sampling design", item.getDescription(EN_LANG_CODE));
}
}
use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class CodeListItemDaoIntegrationTest method persistedHierarchicalListTest.
@Test
public void persistedHierarchicalListTest() {
CodeList list = survey.getCodeList("admin_unit");
List<PersistedCodeListItem> rootItems = codeListItemDao.loadRootItems(list);
assertEquals(8, rootItems.size());
{
PersistedCodeListItem item = rootItems.get(2);
assertEquals(22, item.getId());
assertEquals("003", item.getCode());
assertEquals(Integer.valueOf(3), item.getSortOrder());
assertEquals("Colin", item.getLabel(EN_LANG_CODE));
boolean hasChildItems = codeListItemDao.hasChildItems(list, item.getSystemId());
assertTrue(hasChildItems);
{
PersistedCodeListItem child = (PersistedCodeListItem) codeListItemDao.loadItem(list, item.getSystemId(), "002", null);
assertNotNull(child);
assertEquals(24, child.getId());
assertEquals(Integer.valueOf(2), child.getSortOrder());
assertEquals("Muddy Banks", child.getLabel(EN_LANG_CODE));
boolean hasChildItems2 = codeListItemDao.hasChildItems(list, child.getSystemId());
assertFalse(hasChildItems2);
}
}
}
use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class CodeParentValidator method isExternalCodeList.
private boolean isExternalCodeList(CodeAttribute node) {
CodeAttributeDefinition definition = node.getDefinition();
CodeList codeList = definition.getList();
return codeList.isExternal();
}
Aggregations