Package org.kitesdk.morphline.api

Examples of org.kitesdk.morphline.api.MorphlineCompilationException


  @Override
  public Command build(Config config, Command parent, Command child, MorphlineContext context) {
    try {
      return new DownloadHdfsFile(this, config, parent, child, context);
    } catch (IOException e) {
      throw new MorphlineCompilationException("Cannot compile", config, e);
    }
  }
View Full Code Here


      this.inputFieldName = getConfigs().getString(config, "inputField");
     
      this.outputFieldName = getConfigs().getString(config, "outputField", null);
      this.outputFieldNames = getConfigs().getStringList(config, "outputFields", null);
      if (outputFieldName == null && outputFieldNames == null) {
        throw new MorphlineCompilationException("Either outputField or outputFields must be defined", config);
      }
      if (outputFieldName != null && outputFieldNames != null) {
        throw new MorphlineCompilationException("Must not define both outputField and outputFields at the same time", config);
      }
     
      String separator = getConfigs().getString(config, "separator");
      boolean isRegex = getConfigs().getBoolean(config, "isRegex", false);
      GrokDictionaries dict = new GrokDictionaries(config, getConfigs());
View Full Code Here

    public XQuery(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) throws SaxonApiException, IOException, XMLStreamException {
      super(builder, config, parent, child, context);
     
      List<? extends Config> fragmentConfigs = getConfigs().getConfigList(config, "fragments");
      if (fragmentConfigs.size() == 0) {
        throw new MorphlineCompilationException("At least one fragment must be defined", config);
      }
      if (fragmentConfigs.size() > 1) {
        throw new MorphlineCompilationException("More than one fragment is not yet supported", config);
      }
      for (Config fragment : fragmentConfigs) {
        String fragmentPath = getConfigs().getString(fragment, "fragmentPath");
        if (!fragmentPath.equals("/")) {
          throw new MorphlineCompilationException("Non-root fragment paths are not yet supported", config);
       
       
        XQueryCompiler compiler = processor.newXQueryCompiler();
        compiler.setErrorListener(new DefaultErrorListener());
        compiler.setCompileWithTracing(isTracing);
        compiler.setLanguageVersion(getConfigs().getString(config, "languageVersion", "1.0"));
       
        XQueryExecutable executable = null;
        String query = getConfigs().getString(fragment, "queryString", null);
        if (query != null) {
          executable = compiler.compile(query);    
        }
        String queryFile = getConfigs().getString(fragment, "queryFile", null);
        if (queryFile != null) {
          executable = compiler.compile(new File(queryFile));
        }
        if (query == null && queryFile == null) {
          throw new MorphlineCompilationException("Either query or queryFile must be defined", config);
        }
        if (query != null && queryFile != null) {
          throw new MorphlineCompilationException("Must not define both query and queryFile at the same time", config);
        }
       
        XQueryEvaluator evaluator = executable.load();
        Config variables = getConfigs().getConfig(fragment, "externalVariables", ConfigFactory.empty());
        for (Map.Entry<String, Object> entry : new Configs().getEntrySet(variables)) {
View Full Code Here

  @Override
  public Command build(Config config, Command parent, Command child, MorphlineContext context) {
    try {
      return new XSLT(this, config, parent, child, context);
    } catch (SaxonApiException e) {
      throw new MorphlineCompilationException("Cannot compile", config, e);
    } catch (IOException e) {
      throw new MorphlineCompilationException("Cannot compile", config, e);
    } catch (XMLStreamException e) {
      throw new MorphlineCompilationException("Cannot compile", config, e);
    }
  }
View Full Code Here

    // work around the fact that SimpleDateFormat doesn't understand Unix time format
    private SimpleDateFormat getUnixTimeFormat(String format, TimeZone timeZone) {
      if (format.equals("unixTimeInMillis")) {
        if (!"UTC".equals(timeZone.getID())) {
          throw new MorphlineCompilationException("timeZone must be UTC for date format 'unixTimeInMillis'", getConfig());
        }
        return UNIX_TIME_IN_MILLIS;
      } else if (format.equals("unixTimeInSeconds")) {
        if (!"UTC".equals(timeZone.getID())) {
          throw new MorphlineCompilationException("timeZone must be UTC for date format 'unixTimeInSeconds'", getConfig());
        }
        return UNIX_TIME_IN_SECONDS;
      } else {
        return null;
      }
View Full Code Here

      }
    }
   
    private TimeZone getTimeZone(String timeZoneID) {
      if (!Arrays.asList(TimeZone.getAvailableIDs()).contains(timeZoneID)) {
        throw new MorphlineCompilationException("Unknown timezone: " + timeZoneID, getConfig());
      }
      return TimeZone.getTimeZone(timeZoneID);
    }
View Full Code Here

      }
      assert Locale.ROOT.toString().equals("");
      if (name.equals(Locale.ROOT.toString())) {
        return Locale.ROOT;
      }
      throw new MorphlineCompilationException("Unknown locale: " + name, getConfig());
    }
View Full Code Here

    public XSLT(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) throws SaxonApiException, IOException, XMLStreamException {
      super(builder, config, parent, child, context);
     
      List<? extends Config> fragmentConfigs = getConfigs().getConfigList(config, "fragments");
      if (fragmentConfigs.size() == 0) {
        throw new MorphlineCompilationException("At least one fragment must be defined", config);
      }
      if (fragmentConfigs.size() > 1) {
        throw new MorphlineCompilationException("More than one fragment is not yet supported", config);
      }
      for (Config fragment : fragmentConfigs) {
        String fragmentPath = getConfigs().getString(fragment, "fragmentPath");
        if (!fragmentPath.equals("/")) {
          throw new MorphlineCompilationException("Non-root fragment paths are not yet supported", config);
       
       
        XsltCompiler compiler = processor.newXsltCompiler();
        compiler.setErrorListener(new DefaultErrorListener());
        compiler.setCompileWithTracing(isTracing);
        String version = getConfigs().getString(config, "languageVersion", null);
        if (version != null) {
          compiler.setXsltLanguageVersion(version);
        }
       
        XsltExecutable executable = null;
        String query = getConfigs().getString(fragment, "queryString", null);
        if (query != null) {
          executable = compiler.compile(new StreamSource(new StringReader(query)));    
        }
        String queryFile = getConfigs().getString(fragment, "queryFile", null);
        if (queryFile != null) {
          executable = compiler.compile(new StreamSource(new File(queryFile)));    
        }
        if (query == null && queryFile == null) {
          throw new MorphlineCompilationException("Either query or queryFile must be defined", config);
        }
        if (query != null && queryFile != null) {
          throw new MorphlineCompilationException("Must not define both query and queryFile at the same time", config);
        }
       
        XsltTransformer evaluator = executable.load();
        Config variables = getConfigs().getConfig(fragment, "parameters", ConfigFactory.empty());
        for (Map.Entry<String, Object> entry : new Configs().getEntrySet(variables)) {
View Full Code Here

      public RCFileColumn(Config columnConfig, Configuration conf) {
        this.conf = conf;
        Configs configs = new Configs();
        this.inputField = configs.getInt(columnConfig, "inputField");
        if (inputField < 0) {
          throw new MorphlineCompilationException(
              "Invalid column inputField specified: " + inputField, columnConfig);
        }

        this.outputField = configs.getString(columnConfig, "outputField");
        String writableClassString = configs.getString(columnConfig, "writableClass");

        if (writableClassString == null || writableClassString.isEmpty()) {
          throw new MorphlineCompilationException(
              "No writableClass specified for column " + outputField, columnConfig);
        }
        try {
          Class clazz = Class.forName(writableClassString);
          if (!Writable.class.isAssignableFrom(clazz)) {
            throw new MorphlineCompilationException("writableClass provided "
                + writableClassString + " for column " + outputField
                + " does not implement " + Writable.class.getName(), columnConfig);
          }
          this.writableClass = clazz;
        } catch (ClassNotFoundException e) {
          throw new MorphlineCompilationException("Could not load class "
              + writableClassString + " definition", columnConfig, e);
        }
        configs.validateArguments(columnConfig);
      }
View Full Code Here

          } finally {
            Closeables.closeQuietly(in);
          }
        }       
      } catch (IOException e) {
        throw new MorphlineCompilationException("Cannot parse UserAgent database: " + databaseFile, config, e);
      }
     
      Meter numCacheHitsMeter = isMeasuringMetrics() ? getMeter(Metrics.NUM_CACHE_HITS) : null;
      Meter numCacheMissesMeter = isMeasuringMetrics() ? getMeter(Metrics.NUM_CACHE_MISSES) : null;
     
View Full Code Here

TOP

Related Classes of org.kitesdk.morphline.api.MorphlineCompilationException

Copyright © 2018 www.massapicom. 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.