Examples of ScriptProcessor


Examples of com.cloutree.modelevaluator.impl.pmml.scripting.ScriptProcessor

      log.log(Level.WARNING, "Model-File not set properly");
      result.addError("Model-File not set properly");
      return result;
    }
   
    ScriptProcessor processor = ScriptFactory.getScriptProcessor(ScriptFactory.Types.JAVASCRIPT);
   
    // Do PreProcessing on Parameters
    if(this.preProcessor != null && !this.preProcessor.isEmpty())
      processor.doScriptProcessing(this.preProcessor, parameters);
   
    // Compile parameters for R
    String rParamaterAssignString = "params <- data.frame(";
    boolean initial = true;
    for(String key : parameters.keySet()) {
      try {
        String obj = (String)parameters.get(key);
        if(initial) {
          rParamaterAssignString = rParamaterAssignString + key + "=" + obj;
          initial= false;
        } else {
          rParamaterAssignString = rParamaterAssignString + "," + key + "=" + obj;
        }
      } catch(ClassCastException e) {
        log.log(Level.WARNING, "Parameter " + key + "->" + parameters.get(key) + " seems to be no String, which was expected for native R! Continouing without this parameter now...");
        result.addError("Parameter " + key + "->" + parameters.get(key) + " could not be read (String expected)!");
      }
    }
   
    //Get model name out of file
    this.engine.eval("modelname<-load('"+ this.modelFile.getFile().getPath());
    String modelName = this.engine.eval("modelname").asString();
   
    REXP rResult = this.engine.eval("predict(" + modelName + "," + rParamaterAssignString);
   
    if(rResult == null || rResult.getType() == REXP.XT_NULL) {
      result.addError("Empty R result, model has an error");
    } else {
      Map<String, Object> tempPredictions = new HashMap<String, Object>();
      this.processRResult(rResult, tempPredictions, "result");
    }
   
    // Do Post-Processing
    if(this.postProcessor != null && !this.postProcessor.isEmpty())
      processor.doScriptProcessing(this.postProcessor, (Map<String, Object>) result.getOutputValues());
      processor.doScriptProcessing(this.postProcessor, (Map<String, Object>) result.getPredictedValues());
   
    return result;
  }
View Full Code Here

Examples of com.cloutree.modelevaluator.impl.pmml.scripting.ScriptProcessor

    PmmlPredictiveModelResult result = new PmmlPredictiveModelResult(this, parameters);
    Map<FieldName, Object> arguments = new LinkedHashMap<FieldName, Object>();
    List<FieldName> activeFields = this.evaluator.getActiveFields();
    Map<FieldName, ?> pmmlResult;
 
    ScriptProcessor processor = ScriptFactory.getScriptProcessor(ScriptFactory.Types.JAVASCRIPT);
   
    // Do PreProcessing on Parameters
    if(this.preProcessor != null && !this.preProcessor.isEmpty())
      processor.doScriptProcessing(this.preProcessor, parameters);
   
    for(FieldName activeField : activeFields){
      DataField dataField = this.evaluator.getDataField(activeField);
      Object value = parameters.get(dataField.getName().getValue());
     
      if(value == null || value.toString().isEmpty()) {
          result.addError("No parameter found for: " + dataField.getName());
          log.log(Level.WARNING, "No parameter found for: " + dataField.getName());
      } else {
          try {
        arguments.put(activeField, evaluator.prepare(activeField, value));
          } catch (Exception e) {
        result.addError("Field " + activeField.getValue() + " has invalid value " + value);
        log.log(Level.SEVERE, e.getMessage());
        result.setValid(false);
        return result;
          }
      }
 
    }
   
    try {
        pmmlResult = evaluator.evaluate(arguments);
    } catch (Exception e) {
        result.addError("Unable to evaluate model: " + e.getMessage());
        log.log(Level.WARNING, "Unable to evaluate model: " + e.getMessage());
        return result;
    }
   
    List<FieldName> predictedFields = evaluator.getPredictedFields();
    for(FieldName predictedField : predictedFields){
      DataField dataField = evaluator.getDataField(predictedField);
      Object predictedValue = pmmlResult.get(predictedField);
      result.addPredictedValue(dataField.getName().getValue(), predictedValue);
    }
 
    List<FieldName> resultFields = this.evaluator.getOutputFields();
    for(FieldName resultField : resultFields){
      OutputField outputField = evaluator.getOutputField(resultField);
      Object outputValue = pmmlResult.get(resultField);
      result.addOutputValue(outputField.getName().getValue(), outputValue);
    }
   
    if(this.postProcessor != null && !this.postProcessor.isEmpty()) {
      processor.doScriptProcessing(this.postProcessor, (Map<String, Object>) result.getOutputValues());
      processor.doScriptProcessing(this.postProcessor, (Map<String, Object>) result.getPredictedValues());
    }
   
    return result;
    }
View Full Code Here

Examples of org.apache.fop.complexscripts.scripts.ScriptProcessor

     * @param script a script identifier
     * @param language a language identifier
     * @return the reordered (output) glyph sequence
     */
    public GlyphSequence reorderCombiningMarks ( GlyphSequence gs, int[][] gpa, String script, String language ) {
        ScriptProcessor sp = ScriptProcessor.getInstance ( script );
        return sp.reorderCombiningMarks ( this, gs, gpa, script, language );
    }
View Full Code Here

Examples of org.apache.fop.complexscripts.scripts.ScriptProcessor

     * @return true if some adjustment is not zero; otherwise, false
     */
    public boolean position ( GlyphSequence gs, String script, String language, int fontSize, int[] widths, int[][] adjustments ) {
        Map/*<LookupSpec,List<LookupTable>>*/ lookups = matchLookups ( script, language, "*" );
        if ( ( lookups != null ) && ( lookups.size() > 0 ) ) {
            ScriptProcessor sp = ScriptProcessor.getInstance ( script );
            return sp.position ( this, gs, script, language, fontSize, lookups, widths, adjustments );
        } else {
            return false;
        }
    }
View Full Code Here

Examples of org.apache.fop.complexscripts.scripts.ScriptProcessor

     */
    public GlyphSequence substitute ( GlyphSequence gs, String script, String language ) {
        GlyphSequence ogs;
        Map/*<LookupSpec,List<LookupTable>>*/ lookups = matchLookups ( script, language, "*" );
        if ( ( lookups != null ) && ( lookups.size() > 0 ) ) {
            ScriptProcessor sp = ScriptProcessor.getInstance ( script );
            ogs = sp.substitute ( this, gs, script, language, lookups );
        } else {
            ogs = gs;
        }
        return ogs;
    }
View Full Code Here

Examples of org.aperteworkflow.scripting.ScriptProcessor

            ScriptProcessorRegistry registry = ProcessToolContext.Util.getThreadProcessToolContext().getRegistry().lookupService(
                    ScriptProcessorRegistry.class.getName());
//          TODO: some smart cacheing
            InputStream is = loadScriptCode();
            ScriptProcessor scriptProcessor = registry.getScriptProcessor(getScriptEngineType());
            if (scriptProcessor == null) {
                logger.severe("Script processor not found: " + getScriptEngineType() + ", skipping script execution. ");
                return executed;
            }
            scriptProcessor.process(fields, is);
            executed = true;
            boundProperties.clear();
         //   dictContainers.clear();

        } catch (Exception e) {
View Full Code Here

Examples of org.aperteworkflow.scripting.ScriptProcessor

                    ScriptProcessorRegistry.class.getName());
            Property scriptType = formProperties.get("scriptEngineType");

            if (scriptType == null || scriptType.getValue() == null || ((String) scriptType.getValue()).isEmpty())
                throw new Validator.InvalidValueException("script.undefined.type");
            ScriptProcessor scriptProcessor = registry.getScriptProcessor((String) scriptType.getValue());
            if (scriptProcessor == null)
                throw new Validator.InvalidValueException("script.processor.not.found");
            InputStream is = new URL((String) url.getValue()).openStream();
            scriptProcessor.validate(is);
            url.commit();
            showInfoNotification("validation.script.ok");

        } catch (Validator.InvalidValueException e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

Examples of org.aperteworkflow.scripting.ScriptProcessor

            ScriptProcessorRegistry registry = ProcessToolContext.Util.getThreadProcessToolContext().getRegistry().lookupService(
                    ScriptProcessorRegistry.class.getName());
            Property scriptType = formProperties.get("scriptEngineType");
            if (scriptType == null || scriptType.getValue() == null || ((String) scriptType.getValue()).isEmpty())
                throw new Validator.InvalidValueException("script.undefined.type");
            ScriptProcessor scriptProcessor = registry.getScriptProcessor((String) scriptType.getValue());
            if (scriptProcessor == null)
                throw new Validator.InvalidValueException("script.processor.not.found");

            InputStream is = new ByteArrayInputStream(((String) code.getValue()).getBytes());

            scriptProcessor.validate(is);
            code.commit();
            showInfoNotification("validation.script.ok");
        } catch (Validator.InvalidValueException e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
            showWarningNotification(e.getMessage(), null);
View Full Code Here

Examples of org.jboss.ejb3.packagemanager.script.ScriptProcessor

      }
      for (ScriptType script : preInstallScripts)
      {
         // TODO: Can we just have one instance of the script processor to process
         // all scripts? Stateful/stateless?
         ScriptProcessor scriptProcessor = new AntScriptProcessor();
         String scriptFileName = script.getName();
         File root = pkgCtx.getPackageRoot();
         File path = root;
         if (script.getPath() != null)
         {
            path = new File(root, script.getPath());
         }
         File scriptFile = new File(path, scriptFileName);
         if (!scriptFile.exists())
         {
            throw new PackageManagerException("Script file " + scriptFile + " for " + pkgCtx + " does not exist!");
         }
         scriptProcessor.processPreInstallScript(this.pkgMgrCtx, pkgCtx, scriptFile);
      }

   }
View Full Code Here

Examples of org.jboss.ejb3.packagemanager.script.ScriptProcessor

         logger.trace("There are no pre-uninstall scripts for package " + installedPackage.getPackageName());
         return;
      }
      for (org.jboss.ejb3.packagemanager.entity.PersistentPreUnInstallScript script : preUnInstallScripts)
      {
         ScriptProcessor scriptProcessor = new AntScriptProcessor();
         File packageManagerHome = this.pkgMgrCtx.getPackageManagerEnvironment().getPackageManagerHome();
         File scriptFileLocation = new File(packageManagerHome, script.getPath());
         File scriptFile = new File(scriptFileLocation, script.getName());
         if (!scriptFile.exists())
         {
            throw new PackageManagerException("Script file " + scriptFile + " for package "
                  + installedPackage.getPackageName() + " does not exist!");
         }
         scriptProcessor.processPreUnInstallScript(this.pkgMgrCtx, installedPackage, scriptFile);
      }

   }
View Full Code Here
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.