// Path: c3po-cmd/src/main/java/com/petpet/c3po/command/GatherCommand.java
// public class GatherCommand extends AbstractCLICommand implements Command {
// 
//   /**
//    * Default logger.
//    */
//   private static final Logger LOG = LoggerFactory.getLogger( GatherCommand.class );
// 
//   /**
//    * The gathering params passed on the command line.
//    */
//   private GatherParams params;
// 
//   /**
//    * Creates a controller and submits a process meta data request.
//    */
//   @Override
//   public void execute() {
//     LOG.info( "Starting meta data gathering command." );
//     long start = System.currentTimeMillis();
// 
//     final Configurator configurator = Configurator.getDefaultConfigurator();
//     configurator.configure();
// 
//     final Map<String, String> conf = new HashMap<String, String>();
//     conf.put( Constants.OPT_COLLECTION_LOCATION, this.params.getLocation() );
//     conf.put( Constants.OPT_COLLECTION_NAME, this.params.getCollection() );
//     conf.put( Constants.OPT_INPUT_TYPE, this.params.getType() );
//     conf.put( Constants.OPT_RECURSIVE, this.params.isRecursive() + "" );
// 
//     final Controller ctrl = new Controller( configurator );
//     try {
//       ctrl.processMetaData( conf );
//       System.out.println( "I finished translating the data. I am fluent in over six million forms of communication." );
//       System.out.println( "I finished memorizing all the data." );
//     } catch ( C3POConfigurationException e ) {
//       LOG.error( e.getMessage() );
//       System.err.println("An error occurred: " + e.getMessage());
//       return;
// 
//     } finally {
//       cleanup();
//     }
// 
//     long end = System.currentTimeMillis();
//     this.setTime( end - start );
//   }
// 
//   @Override
//   public void setParams( Params params ) {
//     if ( params != null && params instanceof GatherParams ) {
//       this.params = (GatherParams) params;
//     }
//   }
// 
// }
// 
// Path: c3po-cmd/src/main/java/com/petpet/c3po/parameters/validation/InputTypeValidator.java
// public class InputTypeValidator implements IValueValidator<String> {
// 
//   /**
//    * The supported metadata types.
//    */
//   private static final String[] SUPPORTED_METADATA = { "FITS", "TIKA" };
// 
//   /**
//    * @throws ParameterException
//    *           if the passed value is not supported.
//    */
//   @Override
//   public void validate( String name, String value ) throws ParameterException {
//     if ( !Arrays.asList( SUPPORTED_METADATA ).contains( value ) ) {
//       throw new ParameterException( "Input type '" + value + "' is not supported. Please use one of "
//           + Arrays.deepToString( SUPPORTED_METADATA ) );
//     }
// 
//   }
// 
// }


import com.beust.jcommander.Parameter;
import com.petpet.c3po.command.GatherCommand;
import com.petpet.c3po.parameters.validation.InputTypeValidator;
/*******************************************************************************
 * Copyright 2013 Petar Petrov <me@petarpetrov.org>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package com.petpet.c3po.parameters;


/**
 * The supported parameters for the {@link GatherCommand}
 * 
 * @author Petar Petrov <me@petarpetrov.org>
 * 
 */
public class GatherParams implements Params {

  /**
   * The collection under which to store the gathered data - required. Supports
   * '-c' and '--collection'.
   */
  @Parameter( names = { "-c", "--collection" }, description = "The name of the collection", required = true )
  private String collection;

  /**
   * The input directory, where the meta data is stored - required. Supports
   * '-i' and '--inputdir'.
   */
  @Parameter( names = { "-i", "--inputdir" }, description = "The input directory where the meta data is stored", required = true )
  private String location;

  /**
   * If the flag is present, then the gathering process will traverse the input
   * dir recursively. Default is false. Supports '-r' and '--recursive'.
   */
  @Parameter( names = { "-r", "--recursive" }, arity = 0, description = "Whether or not to gather recursively" )
  private boolean recursive = false;

  /**
   * The type of meta data that will be gathered. Default is 'FITS' Supports
   * '-t' and '--type'.
   */
// Path: c3po-cmd/src/main/java/com/petpet/c3po/command/GatherCommand.java
// public class GatherCommand extends AbstractCLICommand implements Command {
// 
//   /**
//    * Default logger.
//    */
//   private static final Logger LOG = LoggerFactory.getLogger( GatherCommand.class );
// 
//   /**
//    * The gathering params passed on the command line.
//    */
//   private GatherParams params;
// 
//   /**
//    * Creates a controller and submits a process meta data request.
//    */
//   @Override
//   public void execute() {
//     LOG.info( "Starting meta data gathering command." );
//     long start = System.currentTimeMillis();
// 
//     final Configurator configurator = Configurator.getDefaultConfigurator();
//     configurator.configure();
// 
//     final Map<String, String> conf = new HashMap<String, String>();
//     conf.put( Constants.OPT_COLLECTION_LOCATION, this.params.getLocation() );
//     conf.put( Constants.OPT_COLLECTION_NAME, this.params.getCollection() );
//     conf.put( Constants.OPT_INPUT_TYPE, this.params.getType() );
//     conf.put( Constants.OPT_RECURSIVE, this.params.isRecursive() + "" );
// 
//     final Controller ctrl = new Controller( configurator );
//     try {
//       ctrl.processMetaData( conf );
//       System.out.println( "I finished translating the data. I am fluent in over six million forms of communication." );
//       System.out.println( "I finished memorizing all the data." );
//     } catch ( C3POConfigurationException e ) {
//       LOG.error( e.getMessage() );
//       System.err.println("An error occurred: " + e.getMessage());
//       return;
// 
//     } finally {
//       cleanup();
//     }
// 
//     long end = System.currentTimeMillis();
//     this.setTime( end - start );
//   }
// 
//   @Override
//   public void setParams( Params params ) {
//     if ( params != null && params instanceof GatherParams ) {
//       this.params = (GatherParams) params;
//     }
//   }
// 
// }
// 
// Path: c3po-cmd/src/main/java/com/petpet/c3po/parameters/validation/InputTypeValidator.java
// public class InputTypeValidator implements IValueValidator<String> {
// 
//   /**
//    * The supported metadata types.
//    */
//   private static final String[] SUPPORTED_METADATA = { "FITS", "TIKA" };
// 
//   /**
//    * @throws ParameterException
//    *           if the passed value is not supported.
//    */
//   @Override
//   public void validate( String name, String value ) throws ParameterException {
//     if ( !Arrays.asList( SUPPORTED_METADATA ).contains( value ) ) {
//       throw new ParameterException( "Input type '" + value + "' is not supported. Please use one of "
//           + Arrays.deepToString( SUPPORTED_METADATA ) );
//     }
// 
//   }
// 
// }


// Path: c3po-cmd/src/main/java/com/petpet/c3po/parameters/GatherParams.java
import com.beust.jcommander.Parameter;
import com.petpet.c3po.command.GatherCommand;
import com.petpet.c3po.parameters.validation.InputTypeValidator;

/*******************************************************************************
 * Copyright 2013 Petar Petrov <me@petarpetrov.org>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package com.petpet.c3po.parameters;


/**
 * The supported parameters for the {@link GatherCommand}
 * 
 * @author Petar Petrov <me@petarpetrov.org>
 * 
 */
public class GatherParams implements Params {

  /**
   * The collection under which to store the gathered data - required. Supports
   * '-c' and '--collection'.
   */
  @Parameter( names = { "-c", "--collection" }, description = "The name of the collection", required = true )
  private String collection;

  /**
   * The input directory, where the meta data is stored - required. Supports
   * '-i' and '--inputdir'.
   */
  @Parameter( names = { "-i", "--inputdir" }, description = "The input directory where the meta data is stored", required = true )
  private String location;

  /**
   * If the flag is present, then the gathering process will traverse the input
   * dir recursively. Default is false. Supports '-r' and '--recursive'.
   */
  @Parameter( names = { "-r", "--recursive" }, arity = 0, description = "Whether or not to gather recursively" )
  private boolean recursive = false;

  /**
   * The type of meta data that will be gathered. Default is 'FITS' Supports
   * '-t' and '--type'.
   */
  @Parameter( names = { "-t", "--type" }, arity = 1, validateValueWith = InputTypeValidator.class, description = "Optional parameter to define the meta data type. Use one of 'FITS' or 'TIKA', to select the type of the input files. Default is FITS" )