Examples of ModelRepository


Examples of org.openhab.model.core.ModelRepository

   *
   * @return the return value of the script
   * @throws ScriptExecutionException if an error occurs during the execution
   */
  public static Object callScript(String scriptName) throws ScriptExecutionException {
    ModelRepository repo = ScriptActivator.modelRepositoryTracker.getService();
    if(repo!=null) {
      String scriptNameWithExt = scriptName;
      if (!StringUtils.endsWith(scriptName, Script.SCRIPT_FILEEXT)) {
        scriptNameWithExt = scriptName + "." + Script.SCRIPT_FILEEXT;
      }
      XExpression expr = (XExpression) repo.getModel(scriptNameWithExt);
      if(expr!=null) {
        ScriptEngine scriptEngine = ScriptActivator.scriptEngineTracker.getService();
        if(scriptEngine!=null) {
          Script script = scriptEngine.newScriptFromXExpression(expr);
          return script.execute();
View Full Code Here

Examples of org.openhab.model.core.ModelRepository

 
  public void execute(JobExecutionContext context) throws JobExecutionException {
    String modelName = (String) context.getJobDetail().getJobDataMap().get(JOB_DATA_RULEMODEL);       
    String ruleName = (String) context.getJobDetail().getJobDataMap().get(JOB_DATA_RULENAME);
   
    ModelRepository modelRepository = RuleModelActivator.modelRepositoryTracker.getService();
    ScriptEngine scriptEngine = RuleModelActivator.scriptEngineTracker.getService();
   
    if(modelRepository!=null && scriptEngine!=null) {
      EObject model = modelRepository.getModel(modelName);
      if (model instanceof RuleModel) {
        RuleModel ruleModel = (RuleModel) model;
        Rule rule = getRule(ruleModel, ruleName);
        if(rule!=null) {
          Script script = scriptEngine.newScriptFromXExpression(rule.getScript());
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.