use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class RelationalSchemaGenerator method addCodeListTables.
private void addCodeListTables(RelationalSchema rs) throws CollectRdbException {
Survey survey = rs.getSurvey();
List<CodeList> codeLists = survey.getCodeLists();
for (CodeList codeList : codeLists) {
addCodeListTable(rs, codeList);
}
}
use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class RelationalSchemaGenerator method addCodeAttributeDataColumns.
private void addCodeAttributeDataColumns(RelationalSchema rs, DataTable table, CodeAttributeDefinition defn, Path relativePath) throws CollectRdbException {
FieldDefinition<?> codeField = defn.getFieldDefinition(CodeAttributeDefinition.CODE_FIELD);
addCodeColumn(table, codeField, relativePath);
CodeList list = defn.getList();
if (!list.isExternal()) {
addCodeValueFKColumn(rs, table, defn, relativePath);
}
boolean qualifiable = isQualifiable(list);
if (qualifiable) {
addDataColumn(table, defn.getFieldDefinition(CodeAttributeDefinition.QUALIFIER_FIELD), relativePath);
}
}
use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class IdmDatabaseSnapshotBuilder method createCodeListTables.
// private void createDataTable(EntityDefinition defn) throws DatabaseException {
// Set<Table> tables = snapshot.getTables();
//
// // Tail recursion so that leaf tables are created first; required for relations
// List<NodeDefinition> childDefns = ((EntityDefinition) defn).getChildDefinitions();
// for (NodeDefinition child : childDefns) {
// if ( child instanceof EntityDefinition ) {
// createDataTable((EntityDefinition) child);
// }
// }
//
// IdmDataTableBuilder dtb = new IdmDataTableBuilder(defn);
// dtb.setTablePrefix(tablePrefix);
// dtb.setTableSuffix(dataTableSuffix);
// Table table = dtb.toTable();
//
// if ( tables.contains(table) ) {
// throw new DatabaseException("Duplicate table name '"+table.getName()+"' for "+defn.getPath());
// }
//
// tables.add(table);
// }
// TODO hierarchical code lists as multiple tables
private void createCodeListTables() throws DatabaseException {
List<CodeList> lists = survey.getCodeLists();
for (CodeList list : lists) {
IdmCodeListTableBuilder tb = new IdmCodeListTableBuilder();
tb.setList(list);
tb.setTablePrefix(tablePrefix);
tb.setTableSuffix(codeTableSuffix);
Table table = tb.toTable();
if (tables.contains(table)) {
throw new DatabaseException("Duplicate table name '" + table.getName() + "' for list " + list.getName());
}
tables.add(table);
}
}
use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class RelationalSchema method addTable.
/**
* Adds a table to the schema. If table with the same name
* already exists it will be replaced.
* @param table
*/
void addTable(Table<?> table) {
String name = table.getName();
tablesByName.put(name, table);
if (table instanceof DataTable) {
DataTable dataTable = (DataTable) table;
NodeDefinition defn = dataTable.getNodeDefinition();
dataTableByDefinitionId.put(defn.getId(), dataTable);
if (dataTable.getParent() == null) {
rootDataTables.put(defn.getName(), dataTable);
}
} else if (table instanceof CodeTable) {
CodeTable codeListTable = (CodeTable) table;
CodeList codeList = codeListTable.getCodeList();
CodeListTableKey key = new CodeListTableKey(codeList.getId(), codeListTable.getLevelIdx());
codeListTables.put(key, codeListTable);
}
}
use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class CodeListSessionService method isEditedSurveyCodeListEmpty.
@Secured("ROLE_ADMIN")
public boolean isEditedSurveyCodeListEmpty(int codeListId) {
CollectSurvey editedSurvey = sessionManager.getActiveDesignerSurvey();
CodeList list = editedSurvey.getCodeListById(codeListId);
boolean result = codeListManager.isEmpty(list);
return result;
}
Aggregations