public static Map<String, ?> getMappingSource(final MutableTable table) { if (table.getColumnByName(FIELD_ID) == null) { final MutableColumn idColumn = new MutableColumn(FIELD_ID, ColumnType.STRING).setTable(table).setPrimaryKey( true); table.addColumn(0, idColumn); } final Map<String, Map<String, String>> propertiesMap = new LinkedHashMap<>(); for (Column column : table.getColumns()) { final String columnName = column.getName(); if (FIELD_ID.equals(columnName)) { // do nothing - the ID is a client-side construct continue; } final String fieldName = getValidatedFieldName(columnName); final Map<String, String> propertyMap = new HashMap<>(); final String type = getType(column); propertyMap.put("type", type); propertiesMap.put(fieldName, propertyMap); } HashMap<String, Map<String, Map<String, String>>> docTypeMap = new HashMap<>(); docTypeMap.put("properties", propertiesMap); final Map<String, Map<String, Map<String, Map<String, String>>>> mapping = new HashMap<>(); mapping.put(table.getName(), docTypeMap); return mapping; }
public static Map<String, ?> getMappingSource(final MutableTable table) { if (table.getColumnByName(FIELD_ID) == null) { final MutableColumn idColumn = new MutableColumn(FIELD_ID, ColumnType.STRING).setTable(table).setPrimaryKey( true); table.addColumn(0, idColumn); } final Map<String, Map<String, String>> propertiesMap = new LinkedHashMap<>(); for (Column column : table.getColumns()) { final String columnName = column.getName(); if (FIELD_ID.equals(columnName)) { // do nothing - the ID is a client-side construct continue; } final String fieldName = getValidatedFieldName(columnName); final Map<String, String> propertyMap = new HashMap<>(); final String type = getType(column); propertyMap.put("type", type); propertiesMap.put(fieldName, propertyMap); } HashMap<String, Map<String, Map<String, String>>> docTypeMap = new HashMap<>(); docTypeMap.put("properties", propertiesMap); final Map<String, Map<String, Map<String, Map<String, String>>>> mapping = new HashMap<>(); mapping.put(table.getName(), docTypeMap); return mapping; }