private List<RowModel> mapXmlRowsToRowsModel( org.cassandraunit.dataset.xml.ColumnFamily xmlColumnFamily, ComparatorType keyType, GenericTypeEnum[] typesBelongingCompositeTypeForKeyType, ComparatorType comparatorType, GenericTypeEnum[] typesBelongingCompositeTypeForComparatorType, ComparatorType subcomparatorType, ComparatorType defaultColumnValueType) { List<RowModel> rowsModel = new ArrayList<RowModel>(); List<ColumnMetadata> columnMetaData = new ArrayList<ColumnMetadata>(); if (xmlColumnFamily.getColumnMetadata() != null) { columnMetaData = xmlColumnFamily.getColumnMetadata(); } for (Row rowType : xmlColumnFamily.getRow()) { rowsModel.add( mapsXmlRowToRowModel( columnMetaData, rowType, keyType, typesBelongingCompositeTypeForKeyType, comparatorType, typesBelongingCompositeTypeForComparatorType, subcomparatorType, defaultColumnValueType)); } return rowsModel; }
private ColumnFamilyModel mapXmlColumnFamilyToColumnFamilyModel( org.cassandraunit.dataset.xml.ColumnFamily xmlColumnFamily) { ColumnFamilyModel columnFamily = new ColumnFamilyModel(); /* structure information */ columnFamily.setName(xmlColumnFamily.getName()); if (xmlColumnFamily.getType() != null) { columnFamily.setType(ColumnType.valueOf(xmlColumnFamily.getType().toString())); } columnFamily.setComment(xmlColumnFamily.getComment()); if (xmlColumnFamily.getCompactionStrategy() != null) { columnFamily.setCompactionStrategy(xmlColumnFamily.getCompactionStrategy()); } if (xmlColumnFamily.getCompactionStrategyOptions() != null) { List<CompactionStrategyOptionModel> compactionStrategyOptionModels = new ArrayList<CompactionStrategyOptionModel>(); for (CompactionStrategyOption compactionStrategyOption : xmlColumnFamily.getCompactionStrategyOptions().getCompactionStrategyOption()) { compactionStrategyOptionModels.add( new CompactionStrategyOptionModel( compactionStrategyOption.getName(), compactionStrategyOption.getValue())); } columnFamily.setCompactionStrategyOptions(compactionStrategyOptionModels); } if (xmlColumnFamily.getGcGraceSeconds() != null) { columnFamily.setGcGraceSeconds(xmlColumnFamily.getGcGraceSeconds()); } if (xmlColumnFamily.getMaxCompactionThreshold() != null) { columnFamily.setMaxCompactionThreshold(xmlColumnFamily.getMaxCompactionThreshold()); } if (xmlColumnFamily.getMinCompactionThreshold() != null) { columnFamily.setMinCompactionThreshold(xmlColumnFamily.getMinCompactionThreshold()); } if (xmlColumnFamily.getReadRepairChance() != null) { columnFamily.setReadRepairChance(xmlColumnFamily.getReadRepairChance()); } if (xmlColumnFamily.getReplicationOnWrite() != null) { columnFamily.setReplicationOnWrite(xmlColumnFamily.getReplicationOnWrite()); } GenericTypeEnum[] typesBelongingCompositeTypeForKeyType = null; if (xmlColumnFamily.getKeyType() != null) { ComparatorType keyType = ComparatorTypeHelper.verifyAndExtract(xmlColumnFamily.getKeyType()); columnFamily.setKeyType(keyType); if (ComparatorType.COMPOSITETYPE.getTypeName().equals(keyType.getTypeName())) { String keyTypeAlias = StringUtils.removeStart( xmlColumnFamily.getKeyType(), ComparatorType.COMPOSITETYPE.getTypeName()); columnFamily.setKeyTypeAlias(keyTypeAlias); typesBelongingCompositeTypeForKeyType = ComparatorTypeHelper.extractGenericTypesFromTypeAlias(keyTypeAlias); } } GenericTypeEnum[] typesBelongingCompositeTypeForComparatorType = null; if (xmlColumnFamily.getComparatorType() != null) { ComparatorType comparatorType = ComparatorTypeHelper.verifyAndExtract(xmlColumnFamily.getComparatorType()); columnFamily.setComparatorType(comparatorType); if (ComparatorType.COMPOSITETYPE.getTypeName().equals(comparatorType.getTypeName())) { String comparatorTypeAlias = StringUtils.removeStart( xmlColumnFamily.getComparatorType(), ComparatorType.COMPOSITETYPE.getTypeName()); columnFamily.setComparatorTypeAlias(comparatorTypeAlias); typesBelongingCompositeTypeForComparatorType = ComparatorTypeHelper.extractGenericTypesFromTypeAlias(comparatorTypeAlias); } } if (xmlColumnFamily.getSubComparatorType() != null) { columnFamily.setSubComparatorType( ComparatorType.getByClassName(xmlColumnFamily.getSubComparatorType().value())); } if (xmlColumnFamily.getDefaultColumnValueType() != null) { columnFamily.setDefaultColumnValueType( ComparatorType.getByClassName(xmlColumnFamily.getDefaultColumnValueType().value())); } columnFamily.setColumnsMetadata( mapXmlColumsMetadataToColumnsMetadata(xmlColumnFamily.getColumnMetadata())); /* data information */ columnFamily.setRows( mapXmlRowsToRowsModel( xmlColumnFamily, columnFamily.getKeyType(), typesBelongingCompositeTypeForKeyType, columnFamily.getComparatorType(), typesBelongingCompositeTypeForComparatorType, columnFamily.getSubComparatorType(), columnFamily.getDefaultColumnValueType())); return columnFamily; }