// Path: runtime/com.incquerylabs.smarthome.eventbus.api/src/main/java/com/incquerylabs/smarthome/eventbus/api/DrlConfiguration.java
// public class DrlConfiguration {
// 	protected final InputStream drl;
// 	protected final String path;
// 	
// 	public DrlConfiguration(InputStream drl, String path) {
// 		this.drl = drl;
// 		this.path = path;
// 	}
// 
// 	public InputStream getDrl() {
// 		return drl;
// 	}
// 
// 	public String getPath() {
// 		return path;
// 	}
// }
// 
// Path: runtime/com.incquerylabs.smarthome.eventbus.api/src/main/java/com/incquerylabs/smarthome/eventbus/api/DtableConfiguration.java
// public class DtableConfiguration {
// 	protected final InputStream dtable;
// 	protected final String path;
// 
// 	public DtableConfiguration(InputStream dtable, String path) {
// 		this.dtable = dtable;
// 		this.path = path;
// 	}
// 
// 	public InputStream getDtable() {
// 		return dtable;
// 	}
// 
// 	public String getPath() {
// 		return path;
// 	}
// }
// 
// Path: runtime/com.incquerylabs.smarthome.eventbus.api/src/main/java/com/incquerylabs/smarthome/eventbus/api/IRuleLoader.java
// public interface IRuleLoader {
//     public List<DrlConfiguration> getDrls();
//     public List<DtableConfiguration> getDtables();
//     public List<RuleTemplateConfiguration> getRuleTemplates();
// }
// 
// Path: runtime/com.incquerylabs.smarthome.eventbus.api/src/main/java/com/incquerylabs/smarthome/eventbus/api/RuleTemplateConfiguration.java
// public class RuleTemplateConfiguration {
// 	// Table of data
// 	protected final InputStream templateData;
// 	protected final String path;
// 	protected final String worksheetName;
// 
// 	//parameters where the data starts in the table
// 	protected final int startRow;
// 	protected final int startColumn;
// 	
// 	// The template data can be applied on many template rules
// 	protected final List<DrlConfiguration> templateRules;
// 
// 	public RuleTemplateConfiguration(InputStream templateData, String path, String worksheetName, int startRow,
// 			int startColumn, List<DrlConfiguration> templateRules) {
// 		this.templateData = templateData;
// 		this.path = path;
// 		this.worksheetName = worksheetName;
// 		this.startRow = startRow;
// 		this.startColumn = startColumn;
// 		this.templateRules = templateRules;
// 	}
// 
// 	public InputStream getTemplateData() {
// 		return templateData;
// 	}
// 
// 	public String getPath() {
// 		return path;
// 	}
// 	
// 	public String getWorksheetName() {
// 		return worksheetName;
// 	}
// 
// 	public int getStartRow() {
// 		return startRow;
// 	}
// 
// 	public int getStartColumn() {
// 		return startColumn;
// 	}
// 
// 	public List<DrlConfiguration> getTemplateRules() {
// 		return templateRules;
// 	}
// }


import java.io.IOException;
import java.net.URL;
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedList;
import java.util.List;
import org.osgi.framework.FrameworkUtil;
import com.incquerylabs.smarthome.eventbus.api.DrlConfiguration;
import com.incquerylabs.smarthome.eventbus.api.DtableConfiguration;
import com.incquerylabs.smarthome.eventbus.api.IRuleLoader;
import com.incquerylabs.smarthome.eventbus.api.RuleTemplateConfiguration;
package com.incquerylabs.smarthome.model.rules;




public class RuleLoader implements IRuleLoader {

    List<String> drlPaths = null;

    @Override
    public List<DrlConfiguration> getDrls() {

        List<DrlConfiguration> list = new LinkedList<DrlConfiguration>();

        Enumeration<URL> baseRules = FrameworkUtil.getBundle(getClass()).findEntries("/src/main/resources/base-rules", "*.drl", true);
        Enumeration<URL> genRules = FrameworkUtil.getBundle(getClass()).findEntries("/src/main/resources/gen-rules", "*.drl", true);
        
        if(baseRules == null) {
        	throw new RuntimeException("Error, base-rules folder shouldn't be empty.");
        }
        if(genRules == null) {
        	throw new RuntimeException("Error, gen-rules folder shouldn't be empty. Have you forget to generate the rules?");
        }
        
        List<URL> loadedDrls = Collections.list(baseRules);
        loadedDrls.addAll(Collections.list(genRules));

// Path: runtime/com.incquerylabs.smarthome.eventbus.api/src/main/java/com/incquerylabs/smarthome/eventbus/api/DrlConfiguration.java
// public class DrlConfiguration {
// 	protected final InputStream drl;
// 	protected final String path;
// 	
// 	public DrlConfiguration(InputStream drl, String path) {
// 		this.drl = drl;
// 		this.path = path;
// 	}
// 
// 	public InputStream getDrl() {
// 		return drl;
// 	}
// 
// 	public String getPath() {
// 		return path;
// 	}
// }
// 
// Path: runtime/com.incquerylabs.smarthome.eventbus.api/src/main/java/com/incquerylabs/smarthome/eventbus/api/DtableConfiguration.java
// public class DtableConfiguration {
// 	protected final InputStream dtable;
// 	protected final String path;
// 
// 	public DtableConfiguration(InputStream dtable, String path) {
// 		this.dtable = dtable;
// 		this.path = path;
// 	}
// 
// 	public InputStream getDtable() {
// 		return dtable;
// 	}
// 
// 	public String getPath() {
// 		return path;
// 	}
// }
// 
// Path: runtime/com.incquerylabs.smarthome.eventbus.api/src/main/java/com/incquerylabs/smarthome/eventbus/api/IRuleLoader.java
// public interface IRuleLoader {
//     public List<DrlConfiguration> getDrls();
//     public List<DtableConfiguration> getDtables();
//     public List<RuleTemplateConfiguration> getRuleTemplates();
// }
// 
// Path: runtime/com.incquerylabs.smarthome.eventbus.api/src/main/java/com/incquerylabs/smarthome/eventbus/api/RuleTemplateConfiguration.java
// public class RuleTemplateConfiguration {
// 	// Table of data
// 	protected final InputStream templateData;
// 	protected final String path;
// 	protected final String worksheetName;
// 
// 	//parameters where the data starts in the table
// 	protected final int startRow;
// 	protected final int startColumn;
// 	
// 	// The template data can be applied on many template rules
// 	protected final List<DrlConfiguration> templateRules;
// 
// 	public RuleTemplateConfiguration(InputStream templateData, String path, String worksheetName, int startRow,
// 			int startColumn, List<DrlConfiguration> templateRules) {
// 		this.templateData = templateData;
// 		this.path = path;
// 		this.worksheetName = worksheetName;
// 		this.startRow = startRow;
// 		this.startColumn = startColumn;
// 		this.templateRules = templateRules;
// 	}
// 
// 	public InputStream getTemplateData() {
// 		return templateData;
// 	}
// 
// 	public String getPath() {
// 		return path;
// 	}
// 	
// 	public String getWorksheetName() {
// 		return worksheetName;
// 	}
// 
// 	public int getStartRow() {
// 		return startRow;
// 	}
// 
// 	public int getStartColumn() {
// 		return startColumn;
// 	}
// 
// 	public List<DrlConfiguration> getTemplateRules() {
// 		return templateRules;
// 	}
// }


// Path: demo/com.incquerylabs.smarthome.demorules.generated/src/main/java/com/incquerylabs/smarthome/model/rules/RuleLoader.java
import java.io.IOException;
import java.net.URL;
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedList;
import java.util.List;
import org.osgi.framework.FrameworkUtil;
import com.incquerylabs.smarthome.eventbus.api.DrlConfiguration;
import com.incquerylabs.smarthome.eventbus.api.DtableConfiguration;
import com.incquerylabs.smarthome.eventbus.api.IRuleLoader;
import com.incquerylabs.smarthome.eventbus.api.RuleTemplateConfiguration;

package com.incquerylabs.smarthome.model.rules;




public class RuleLoader implements IRuleLoader {

    List<String> drlPaths = null;

    @Override
    public List<DrlConfiguration> getDrls() {

        List<DrlConfiguration> list = new LinkedList<DrlConfiguration>();

        Enumeration<URL> baseRules = FrameworkUtil.getBundle(getClass()).findEntries("/src/main/resources/base-rules", "*.drl", true);
        Enumeration<URL> genRules = FrameworkUtil.getBundle(getClass()).findEntries("/src/main/resources/gen-rules", "*.drl", true);
        
        if(baseRules == null) {
        	throw new RuntimeException("Error, base-rules folder shouldn't be empty.");
        }
        if(genRules == null) {
        	throw new RuntimeException("Error, gen-rules folder shouldn't be empty. Have you forget to generate the rules?");
        }
        
        List<URL> loadedDrls = Collections.list(baseRules);
        loadedDrls.addAll(Collections.list(genRules));

        for (URL url : loadedDrls) {