@Test public void evaluatesAdditionalVar() throws Exception { WorkflowConfigurationParser parser = new WorkflowConfigurationParser(new File("unused"), ImmutableMap.of("var1", "val1")); Object jsResult = parser.evaluateReader(new StringReader("var1"), "string", new MemoryStateDatabase().openConnection()); Assert.assertEquals(jsResult, "val1"); }
Object evaluateReader(Reader r, String fileName, StateDatabaseConnection connection) throws Exception { Global scope = jsConfigParser.createGlobalScope(); Object wrappedThis = Context.javaToJS(this, scope); Map jsProperties = Maps.newHashMap(additionalJsVariables); jsProperties.put("celosWorkflowConfigurationParser", wrappedThis); jsProperties.put("celosConnection", connection); jsConfigParser.putPropertiesInScope(jsProperties, scope); InputStream scripts = WorkflowConfigurationParser.class.getResourceAsStream(CELOS_SCRIPTS_FILENAME); jsConfigParser.evaluateReader(scope, new InputStreamReader(scripts), CELOS_SCRIPTS_FILENAME); return jsConfigParser.evaluateReader(scope, r, fileName); }
WorkflowConfigurationParser { Object evaluateReader(Reader r, String fileName, StateDatabaseConnection connection) throws Exception { Global scope = jsConfigParser.createGlobalScope(); Object wrappedThis = Context.javaToJS(this, scope); Map jsProperties = Maps.newHashMap(additionalJsVariables); jsProperties.put("celosWorkflowConfigurationParser", wrappedThis); jsProperties.put("celosConnection", connection); jsConfigParser.putPropertiesInScope(jsProperties, scope); InputStream scripts = WorkflowConfigurationParser.class.getResourceAsStream(CELOS_SCRIPTS_FILENAME); jsConfigParser.evaluateReader(scope, new InputStreamReader(scripts), CELOS_SCRIPTS_FILENAME); return jsConfigParser.evaluateReader(scope, r, fileName); } }
WorkflowConfigurationParser { Object evaluateReader(Reader r, String fileName, StateDatabaseConnection connection) throws Exception { Global scope = jsConfigParser.createGlobalScope(); Object wrappedThis = Context.javaToJS(this, scope); Map jsProperties = Maps.newHashMap(additionalJsVariables); jsProperties.put("celosWorkflowConfigurationParser", wrappedThis); jsProperties.put("celosConnection", connection); jsConfigParser.putPropertiesInScope(jsProperties, scope); InputStream scripts = WorkflowConfigurationParser.class.getResourceAsStream(CELOS_SCRIPTS_FILENAME); jsConfigParser.evaluateReader(scope, new InputStreamReader(scripts), CELOS_SCRIPTS_FILENAME); return jsConfigParser.evaluateReader(scope, r, fileName); } WorkflowConfigurationParser(File defaultsDir, Map<String, String> additionalJsVariables); }
WorkflowConfigurationParser { Object evaluateReader(Reader r, String fileName, StateDatabaseConnection connection) throws Exception { Global scope = jsConfigParser.createGlobalScope(); Object wrappedThis = Context.javaToJS(this, scope); Map jsProperties = Maps.newHashMap(additionalJsVariables); jsProperties.put("celosWorkflowConfigurationParser", wrappedThis); jsProperties.put("celosConnection", connection); jsConfigParser.putPropertiesInScope(jsProperties, scope); InputStream scripts = WorkflowConfigurationParser.class.getResourceAsStream(CELOS_SCRIPTS_FILENAME); jsConfigParser.evaluateReader(scope, new InputStreamReader(scripts), CELOS_SCRIPTS_FILENAME); return jsConfigParser.evaluateReader(scope, r, fileName); } WorkflowConfigurationParser(File defaultsDir, Map<String, String> additionalJsVariables); WorkflowConfigurationParser parseConfiguration(File workflowsDir, StateDatabaseConnection connection); WorkflowConfiguration getWorkflowConfiguration(); void importDefaultsIntoScope(String label, Global scope); void addWorkflow(Workflow wf); }
WorkflowConfigurationParser { Object evaluateReader(Reader r, String fileName, StateDatabaseConnection connection) throws Exception { Global scope = jsConfigParser.createGlobalScope(); Object wrappedThis = Context.javaToJS(this, scope); Map jsProperties = Maps.newHashMap(additionalJsVariables); jsProperties.put("celosWorkflowConfigurationParser", wrappedThis); jsProperties.put("celosConnection", connection); jsConfigParser.putPropertiesInScope(jsProperties, scope); InputStream scripts = WorkflowConfigurationParser.class.getResourceAsStream(CELOS_SCRIPTS_FILENAME); jsConfigParser.evaluateReader(scope, new InputStreamReader(scripts), CELOS_SCRIPTS_FILENAME); return jsConfigParser.evaluateReader(scope, r, fileName); } WorkflowConfigurationParser(File defaultsDir, Map<String, String> additionalJsVariables); WorkflowConfigurationParser parseConfiguration(File workflowsDir, StateDatabaseConnection connection); WorkflowConfiguration getWorkflowConfiguration(); void importDefaultsIntoScope(String label, Global scope); void addWorkflow(Workflow wf); static final String WORKFLOW_FILE_EXTENSION; }