class SchedulerRequest {

  StringEntity buildSchedulerRequestEntity( AbstractMeta meta )
          throws UnsupportedEncodingException, UnknownParamException {
    String filename = getFullPath( meta );

    StringBuilder sb = new StringBuilder();
    sb.append( "<jobScheduleRequest>\n" );
    sb.append( "<inputFile>" ).append( filename ).append( "</inputFile>\n" );

    // Set the log level
    if ( meta.getLogLevel() != null ) {
      sb.append( "<jobParameters>\n" );
      sb.append( "<name>" ).append( "logLevel" ).append( "</name>\n" );
      sb.append( "<type>" ).append( "string" ).append( "</type>\n" );
      sb.append( "<stringValue>" ).append( meta.getLogLevel().getCode() ).append( "</stringValue>\n" );
      sb.append( "</jobParameters>\n" );
    }

    // Set the clearing log param
    sb.append( "<jobParameters>\n" );
    sb.append( "<name>" ).append( "clearLog" ).append( "</name>\n" );
    sb.append( "<type>" ).append( "string" ).append( "</type>\n" );
    sb.append( "<stringValue>" ).append( meta.isClearingLog() ).append( "</stringValue>\n" );
    sb.append( "</jobParameters>\n" );

    // Set the safe mode enabled param
    sb.append( "<jobParameters>\n" );
    sb.append( "<name>" ).append( "runSafeMode" ).append( "</name>\n" );
    sb.append( "<type>" ).append( "string" ).append( "</type>\n" );
    sb.append( "<stringValue>" ).append( meta.isSafeModeEnabled() ).append( "</stringValue>\n" );
    sb.append( "</jobParameters>\n" );

    // Set the gathering metrics param
    sb.append( "<jobParameters>\n" );
    sb.append( "<name>" ).append( "gatheringMetrics" ).append( "</name>\n" );
    sb.append( "<type>" ).append( "string" ).append( "</type>\n" );
    sb.append( "<stringValue>" ).append( meta.isGatheringMetrics() ).append( "</stringValue>\n" );
    sb.append( "</jobParameters>\n" );

    if ( meta instanceof JobMeta ) {
      JobMeta jobMeta = (JobMeta) meta;

      if ( jobMeta.getStartCopyName() != null ) {
        // Set the start step name
        sb.append( "<jobParameters>\n" );
        sb.append( "<name>" ).append( "startCopyName" ).append( "</name>\n" );
        sb.append( "<type>" ).append( "string" ).append( "</type>\n" );
        sb.append( "<stringValue>" ).append( jobMeta.getStartCopyName() ).append( "</stringValue>\n" );
        sb.append( "</jobParameters>\n" );
      }

      // Set the expanding remote job param
      sb.append( "<jobParameters>\n" );
      sb.append( "<name>" ).append( "expandingRemoteJob" ).append( "</name>\n" );
      sb.append( "<type>" ).append( "string" ).append( "</type>\n" );
      sb.append( "<stringValue>" ).append( jobMeta.isExpandingRemoteJob() ).append( "</stringValue>\n" );
      sb.append( "</jobParameters>\n" );
    }

    // Set the PDI parameters
    if ( meta.listParameters() != null ) {
      sb.append( "<pdiParameters>\n" );
      for ( String param : meta.listParameters() ) {
        sb.append( "<entry>\n" );
        sb.append( "<key>" ).append( param ).append( "</key>\n" );
        sb.append( "<value>" ).append( meta.getParameterValue( param ) ).append( "</value>\n" );
        sb.append( "</entry>\n" );
      }
      sb.append( "</pdiParameters>\n" );
    }

    sb.append( "</jobScheduleRequest>" );

    return new StringEntity( sb.toString() );
  }

  public  SchedulerRequest( Builder builder );

}