private List<ColumnModel> mapParsedColumnsToColumnsModel( List<ParsedColumnMetadata> metaData, List<ParsedColumn> parsedColumns, ComparatorType comparatorType, GenericTypeEnum[] typesBelongingCompositeTypeForComparatorType, ComparatorType defaultColumnValueType) { List<ColumnModel> columnsModel = new ArrayList<ColumnModel>(); for (ParsedColumn jsonColumn : parsedColumns) { ParsedColumnMetadata columnMetaData = null; for (ParsedColumnMetadata tmpMetaData : metaData) { if (tmpMetaData.getName().equals(jsonColumn.getName())) { columnMetaData = tmpMetaData; break; } } columnsModel.add( mapParsedColumnToColumnModel( columnMetaData, jsonColumn, comparatorType, typesBelongingCompositeTypeForComparatorType, defaultColumnValueType)); } return columnsModel; }
private ColumnMetadataModel mapParsedColumMetadataToColumnMetadata( ParsedColumnMetadata parsedColumnMetadata, ComparatorType comparatorType, GenericTypeEnum[] typesBelongingCompositeTypeForComparatorType) { if (parsedColumnMetadata.getName() == null) { throw new ParseException("column metadata name can't be empty"); } if (parsedColumnMetadata.getValidationClass() == null) { throw new ParseException("column metadata validation class can't be empty"); } ColumnMetadataModel columnMetadata = new ColumnMetadataModel(); columnMetadata.setColumnName( TypeExtractor.constructGenericType( parsedColumnMetadata.getName(), comparatorType, typesBelongingCompositeTypeForComparatorType)); columnMetadata.setValidationClass( ComparatorType.getByClassName(parsedColumnMetadata.getValidationClass().name())); if (parsedColumnMetadata.getIndexType() != null) { columnMetadata.setColumnIndexType( ColumnIndexType.valueOf(parsedColumnMetadata.getIndexType().name())); } if (parsedColumnMetadata.getIndexName() != null) { columnMetadata.setIndexName(parsedColumnMetadata.getIndexName()); } return columnMetadata; }
private ColumnModel mapParsedColumnToColumnModel( ParsedColumnMetadata metaData, ParsedColumn parsedColumn, ComparatorType comparatorType, GenericTypeEnum[] typesBelongingCompositeTypeForComparatorType, ComparatorType defaultColumnValueType) { ColumnModel columnModel = new ColumnModel(); columnModel.setName( TypeExtractor.constructGenericType( parsedColumn.getName(), comparatorType, typesBelongingCompositeTypeForComparatorType)); if (ComparatorType.COUNTERTYPE.getClassName().equals(defaultColumnValueType.getClassName()) && TypeExtractor.containFunctions(parsedColumn.getValue())) { throw new ParseException("Impossible to override Column value into a Counter column family"); } GenericType columnValue = null; if (parsedColumn.getValue() != null) { if (metaData != null && !TypeExtractor.containFunctions(parsedColumn.getValue())) { GenericTypeEnum genTypeEnum = GenericTypeEnum.fromValue(metaData.getValidationClass().name()); columnValue = new GenericType(parsedColumn.getValue(), genTypeEnum); } else { columnValue = TypeExtractor.extract(parsedColumn.getValue(), defaultColumnValueType); } } columnModel.setValue(columnValue); String timestamp = parsedColumn.getTimestamp(); if (timestamp != null) { columnModel.setTimestamp(Long.valueOf(timestamp)); } else { columnModel.setTimestamp(null); } return columnModel; }