private static void setTableAttributes(String location, DataStructureSchemaModel result, JsonObject structure, String type, DataStructureTableModel table) { table.setLocation(location); table.setName(structure.get("name").getAsString()); table.setType(type); table.setCreatedAt(result.getCreatedAt()); table.setCreatedBy(result.getCreatedBy()); table.setHash(result.getHash()); JsonElement columnElement = structure.get("columns"); if (columnElement.isJsonObject()) { JsonObject column = columnElement.getAsJsonObject(); DataStructureTableColumnModel columnModel = new DataStructureTableColumnModel(); setColumnAttributes(column, columnModel); table.getColumns().add(columnModel); } else if (columnElement.isJsonArray()) { JsonArray columns = columnElement.getAsJsonArray(); for (int j=0; j<columns.size(); j++) { JsonObject column = columns.get(j).getAsJsonObject(); DataStructureTableColumnModel columnModel = new DataStructureTableColumnModel(); setColumnAttributes(column, columnModel); table.getColumns().add(columnModel); } } else { throw new IllegalArgumentException(format("Error in parsing columns of table [{0}] in schema [{1}]", table.getName(), location)); } }
List<DataStructureTableColumnModel> columns = tableModel.getColumns(); for (DataStructureTableColumnModel columnModel : columns) { String name = columnModel.getName(); DataType type = DataType.valueOf(columnModel.getType()); String length = columnModel.getLength(); boolean isNullable = columnModel.isNullable(); boolean isPrimaryKey = columnModel.isPrimaryKey(); boolean isUnique = columnModel.isUnique(); String defaultValue = columnModel.getDefaultValue(); String precision = columnModel.getPrecision(); String scale = columnModel.getScale(); String args = ""; if (length != null) {