Package com.pardot.rhombus.cli.commands

Source Code of com.pardot.rhombus.cli.commands.RcliWithExistingKeyspace

package com.pardot.rhombus.cli.commands;

import com.pardot.rhombus.CassandraConfiguration;
import com.pardot.rhombus.ConnectionManager;
import com.pardot.rhombus.ObjectMapper;
import com.pardot.rhombus.util.JsonUtil;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;

/**
* User: Rob Righter
* Date: 10/9/13
*/
public class RcliWithExistingKeyspace extends RcliWithCassandraConfig {

  public String keyspaceName;
  public ObjectMapper objectMapper;

  public Options getCommandOptions(){
    Options ret = super.getCommandOptions();
    Option keyspaceName = OptionBuilder.withArgName("name")
        .hasArg()
        .withDescription("Name of the existing keyspace to be used")
        .create( "keyspace" );
    ret.addOption(keyspaceName);
    return ret;
  }

  public boolean executeCommand(CommandLine cl) throws Exception {
    boolean ret = super.executeCommand(cl);
    if(!ret){
      return false;
    }

    if(!cl.hasOption("keyspace")){
      displayHelpMessage();
      return false;
    }
    this.keyspaceName = cl.getOptionValue("keyspace");
    ConnectionManager cm = getConnectionManager();
    this.objectMapper = cm.getObjectMapper(this.keyspaceName);
    return true;
  }

}
TOP

Related Classes of com.pardot.rhombus.cli.commands.RcliWithExistingKeyspace

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.