@Test public final void shouldReturnFieldDefinitionForOneLevelDeepPath() { DataDefinition firstBtDataDef = mock(DataDefinition.class); mockBelongsToField("firstBelongsTo", dataDefinition, firstBtDataDef); FieldDefinition fieldDefinition = mockFieldDefinition("fieldName", String.class, firstBtDataDef); String field = "firstBelongsTo.fieldName"; final FieldDefinition res = GridComponentFilterUtils.getFieldDefinition(dataDefinition, field); assertEquals(fieldDefinition, res); }
protected static FieldDefinition getFieldDefinition(DataDefinition dataDefinition, final String field) { String[] path = field.split("\\."); for (int i = 0; i < path.length; i++) { if (dataDefinition.getField(path[i]) == null) { return null; } FieldDefinition fieldDefinition = dataDefinition.getField(path[i]); if (i < path.length - 1) { if (fieldDefinition.getType() instanceof BelongsToType) { dataDefinition = ((BelongsToType) fieldDefinition.getType()).getDataDefinition(); continue; } else { return null; } } return fieldDefinition; } return null; }
GridComponentFilterUtils { protected static FieldDefinition getFieldDefinition(DataDefinition dataDefinition, final String field) { String[] path = field.split("\\."); for (int i = 0; i < path.length; i++) { if (dataDefinition.getField(path[i]) == null) { return null; } FieldDefinition fieldDefinition = dataDefinition.getField(path[i]); if (i < path.length - 1) { if (fieldDefinition.getType() instanceof BelongsToType) { dataDefinition = ((BelongsToType) fieldDefinition.getType()).getDataDefinition(); continue; } else { return null; } } return fieldDefinition; } return null; } }
GridComponentFilterUtils { protected static FieldDefinition getFieldDefinition(DataDefinition dataDefinition, final String field) { String[] path = field.split("\\."); for (int i = 0; i < path.length; i++) { if (dataDefinition.getField(path[i]) == null) { return null; } FieldDefinition fieldDefinition = dataDefinition.getField(path[i]); if (i < path.length - 1) { if (fieldDefinition.getType() instanceof BelongsToType) { dataDefinition = ((BelongsToType) fieldDefinition.getType()).getDataDefinition(); continue; } else { return null; } } return fieldDefinition; } return null; } private  GridComponentFilterUtils(); }
GridComponentFilterUtils { protected static FieldDefinition getFieldDefinition(DataDefinition dataDefinition, final String field) { String[] path = field.split("\\."); for (int i = 0; i < path.length; i++) { if (dataDefinition.getField(path[i]) == null) { return null; } FieldDefinition fieldDefinition = dataDefinition.getField(path[i]); if (i < path.length - 1) { if (fieldDefinition.getType() instanceof BelongsToType) { dataDefinition = ((BelongsToType) fieldDefinition.getType()).getDataDefinition(); continue; } else { return null; } } return fieldDefinition; } return null; } private  GridComponentFilterUtils(); static void addFilters(final Map<String, String> filters, final Map<String, GridComponentColumn> columns,
            final DataDefinition dataDefinition, final SearchCriteriaBuilder criteria); static void addMultiSearchFilter(GridComponentMultiSearchFilter multiSearchFilter,
            Map<String, GridComponentColumn> columns, DataDefinition dataDefinition, SearchCriteriaBuilder criteria); static String addAliases(final SearchCriteriaBuilder criteria, final String field, final JoinType joinType); static String getFieldNameByColumnName(final Map<String, GridComponentColumn> columns, final String columnName); }
GridComponentFilterUtils { protected static FieldDefinition getFieldDefinition(DataDefinition dataDefinition, final String field) { String[] path = field.split("\\."); for (int i = 0; i < path.length; i++) { if (dataDefinition.getField(path[i]) == null) { return null; } FieldDefinition fieldDefinition = dataDefinition.getField(path[i]); if (i < path.length - 1) { if (fieldDefinition.getType() instanceof BelongsToType) { dataDefinition = ((BelongsToType) fieldDefinition.getType()).getDataDefinition(); continue; } else { return null; } } return fieldDefinition; } return null; } private  GridComponentFilterUtils(); static void addFilters(final Map<String, String> filters, final Map<String, GridComponentColumn> columns,
            final DataDefinition dataDefinition, final SearchCriteriaBuilder criteria); static void addMultiSearchFilter(GridComponentMultiSearchFilter multiSearchFilter,
            Map<String, GridComponentColumn> columns, DataDefinition dataDefinition, SearchCriteriaBuilder criteria); static String addAliases(final SearchCriteriaBuilder criteria, final String field, final JoinType joinType); static String getFieldNameByColumnName(final Map<String, GridComponentColumn> columns, final String columnName);  }