private List<RowModel> mapParsedRowsToRowsModel( ParsedColumnFamily parsedColumnFamily, ComparatorType keyType, GenericTypeEnum[] typesBelongingCompositeTypeForKeyType, ComparatorType comparatorType, GenericTypeEnum[] typesBelongingCompositeTypeForComparatorType, ComparatorType subComparatorType, ComparatorType defaultColumnValueType) { List<RowModel> rowsModel = new ArrayList<RowModel>(); for (ParsedRow jsonRow : parsedColumnFamily.getRows()) { rowsModel.add( mapsParsedRowToRowModel( parsedColumnFamily.getColumnsMetadata(), jsonRow, keyType, typesBelongingCompositeTypeForKeyType, comparatorType, typesBelongingCompositeTypeForComparatorType, subComparatorType, defaultColumnValueType)); } return rowsModel; }
private ColumnFamilyModel mapParsedColumnFamilyToColumnFamilyModel( ParsedColumnFamily parsedColumnFamily) { ColumnFamilyModel columnFamily = new ColumnFamilyModel(); /* structure information */ if (parsedColumnFamily == null || parsedColumnFamily.getName() == null) { throw new ParseException("Column Family Name is missing"); } columnFamily.setName(parsedColumnFamily.getName()); if (parsedColumnFamily.getType() != null) { columnFamily.setType(ColumnType.valueOf(parsedColumnFamily.getType().toString())); } columnFamily.setComment(parsedColumnFamily.getComment()); if (parsedColumnFamily.getCompactionStrategy() != null) { columnFamily.setCompactionStrategy(parsedColumnFamily.getCompactionStrategy()); } if (parsedColumnFamily.getCompactionStrategyOptions() != null && !parsedColumnFamily.getCompactionStrategyOptions().isEmpty()) { List<CompactionStrategyOptionModel> compactionStrategyOptionModels = new ArrayList<CompactionStrategyOptionModel>(); for (ParsedCompactionStrategyOption parsedCompactionStrategyOption : parsedColumnFamily.getCompactionStrategyOptions()) { compactionStrategyOptionModels.add( new CompactionStrategyOptionModel( parsedCompactionStrategyOption.getName(), parsedCompactionStrategyOption.getValue())); } columnFamily.setCompactionStrategyOptions(compactionStrategyOptionModels); } if (parsedColumnFamily.getGcGraceSeconds() != null) { columnFamily.setGcGraceSeconds(parsedColumnFamily.getGcGraceSeconds()); } if (parsedColumnFamily.getMaxCompactionThreshold() != null) { columnFamily.setMaxCompactionThreshold(parsedColumnFamily.getMaxCompactionThreshold()); } if (parsedColumnFamily.getMinCompactionThreshold() != null) { columnFamily.setMinCompactionThreshold(parsedColumnFamily.getMinCompactionThreshold()); } if (parsedColumnFamily.getReadRepairChance() != null) { columnFamily.setReadRepairChance(parsedColumnFamily.getReadRepairChance()); } if (parsedColumnFamily.getReplicationOnWrite() != null) { columnFamily.setReplicationOnWrite(parsedColumnFamily.getReplicationOnWrite()); } /* keyType */ GenericTypeEnum[] typesBelongingCompositeTypeForKeyType = null; if (parsedColumnFamily.getKeyType() != null) { ComparatorType keyType = ComparatorTypeHelper.verifyAndExtract(parsedColumnFamily.getKeyType()); columnFamily.setKeyType(keyType); if (ComparatorType.COMPOSITETYPE.getTypeName().equals(keyType.getTypeName())) { String keyTypeAlias = StringUtils.removeStart( parsedColumnFamily.getKeyType(), ComparatorType.COMPOSITETYPE.getTypeName()); columnFamily.setKeyTypeAlias(keyTypeAlias); typesBelongingCompositeTypeForKeyType = ComparatorTypeHelper.extractGenericTypesFromTypeAlias(keyTypeAlias); } } /* comparatorType */ GenericTypeEnum[] typesBelongingCompositeTypeForComparatorType = null; if (parsedColumnFamily.getComparatorType() != null) { ComparatorType comparatorType = ComparatorTypeHelper.verifyAndExtract(parsedColumnFamily.getComparatorType()); columnFamily.setComparatorType(comparatorType); if (ComparatorType.COMPOSITETYPE.getTypeName().equals(comparatorType.getTypeName())) { String comparatorTypeAlias = StringUtils.removeStart( parsedColumnFamily.getComparatorType(), ComparatorType.COMPOSITETYPE.getTypeName()); columnFamily.setComparatorTypeAlias(comparatorTypeAlias); typesBelongingCompositeTypeForComparatorType = ComparatorTypeHelper.extractGenericTypesFromTypeAlias(comparatorTypeAlias); } } /* subComparatorType */ if (parsedColumnFamily.getSubComparatorType() != null) { columnFamily.setSubComparatorType( ComparatorType.getByClassName(parsedColumnFamily.getSubComparatorType().name())); } if (parsedColumnFamily.getDefaultColumnValueType() != null) { columnFamily.setDefaultColumnValueType( ComparatorType.getByClassName(parsedColumnFamily.getDefaultColumnValueType().name())); } columnFamily.setColumnsMetadata( mapParsedColumsMetadataToColumnsMetadata( parsedColumnFamily.getColumnsMetadata(), columnFamily.getComparatorType(), typesBelongingCompositeTypeForComparatorType)); /* data information */ columnFamily.setRows( mapParsedRowsToRowsModel( parsedColumnFamily, columnFamily.getKeyType(), typesBelongingCompositeTypeForKeyType, columnFamily.getComparatorType(), typesBelongingCompositeTypeForComparatorType, columnFamily.getSubComparatorType(), columnFamily.getDefaultColumnValueType())); return columnFamily; }