コード例 #1
0
  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);
  }
コード例 #2
0
 @Override
 public List<ColumnFamilyModel> getColumnFamilies() {
   if (keyspace == null) {
     getKeyspace();
   }
   return keyspace.getColumnFamilies();
 }
コード例 #3
0
 @Override
 public List<ColumnFamilyModel> getColumnFamilies() {
   if (keyspace == null) {
     mapParsedKeyspaceToModel(getParsedKeyspace());
   }
   return keyspace.getColumnFamilies();
 }
コード例 #4
0
  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);
  }
コード例 #5
0
 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));
     }
   }
 }
コード例 #6
0
  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));
      }
    }
  }