protected void mapParsedKeyspaceToModel(ParsedKeyspace parsedKeyspace) { if (parsedKeyspace == null) { throw new ParseException("dataSet is empty"); } /* keyspace */ keyspace = new KeyspaceModel(); if (parsedKeyspace.getName() == null) { throw new ParseException("Keyspace name is mandatory"); } keyspace.setName(parsedKeyspace.getName()); /* optional conf */ if (parsedKeyspace.getReplicationFactor() != 0) { keyspace.setReplicationFactor(parsedKeyspace.getReplicationFactor()); } if (parsedKeyspace.getStrategy() != null) { try { keyspace.setStrategy(StrategyModel.fromValue(parsedKeyspace.getStrategy())); } catch (IllegalArgumentException e) { throw new ParseException("Invalid keyspace Strategy"); } } mapsParsedColumnFamiliesToColumnFamiliesModel(parsedKeyspace); }
@Override public List<ColumnFamilyModel> getColumnFamilies() { if (keyspace == null) { getKeyspace(); } return keyspace.getColumnFamilies(); }
@Override public List<ColumnFamilyModel> getColumnFamilies() { if (keyspace == null) { mapParsedKeyspaceToModel(getParsedKeyspace()); } return keyspace.getColumnFamilies(); }
private void mapXmlKeyspaceToModel(org.cassandraunit.dataset.xml.Keyspace xmlKeyspace) { /* keyspace */ keyspace = new KeyspaceModel(); keyspace.setName(xmlKeyspace.getName()); /* optional conf */ if (xmlKeyspace.getReplicationFactor() != null) { keyspace.setReplicationFactor(xmlKeyspace.getReplicationFactor()); } if (xmlKeyspace.getStrategy() != null) { keyspace.setStrategy(StrategyModel.fromValue(xmlKeyspace.getStrategy().value())); } mapsXmlColumnFamiliesToColumnFamiliesModel(xmlKeyspace); }
private void mapsParsedColumnFamiliesToColumnFamiliesModel(ParsedKeyspace parsedKeyspace) { if (parsedKeyspace.getColumnFamilies() != null) { /* there is column families to integrate */ for (ParsedColumnFamily parsedColumnFamily : parsedKeyspace.getColumnFamilies()) { keyspace .getColumnFamilies() .add(mapParsedColumnFamilyToColumnFamilyModel(parsedColumnFamily)); } } }
private void mapsXmlColumnFamiliesToColumnFamiliesModel( org.cassandraunit.dataset.xml.Keyspace xmlKeyspace) { if (xmlKeyspace.getColumnFamilies() != null) { /* there is column families to integrate */ for (org.cassandraunit.dataset.xml.ColumnFamily xmlColumnFamily : xmlKeyspace.getColumnFamilies().getColumnFamily()) { keyspace.getColumnFamilies().add(mapXmlColumnFamilyToColumnFamilyModel(xmlColumnFamily)); } } }