// Path: be.iminds.iot.things.rule.api/src/be/iminds/iot/things/rule/api/Rule.java
// public interface Rule extends Serializable {
// 
// 	/**
// 	 * Evaluates the rule, returns whether it is triggered or not
// 	 * 
// 	 * @param change the change that can cause the rule to trigger
// 	 */
// 	public boolean evaluate(Change change);
// 	
// 	/**
// 	 * Get the type identifier of this Rule
// 	 */
// 	public String getType();
// 	
// 	/**
// 	 * Get the custom human readable description of this Rule
// 	 */
// 	public String getDescription();
// 	
// 	/**
// 	 * Get the DTO representing this Rule
// 	 */
// 	public RuleDTO getDTO();
// 	
// 	/**
// 	 * Notifies when a Thing that is applicable for this rule is online/offline
// 	 * In case of online, the Thing object is set, in case of offline, null is set
// 	 * 
// 	 * @param id uuid of the Thing
// 	 * @param thing the Thing object
// 	 */
// 	public void setThing(UUID id, Thing thing);
// }
// 
// Path: be.iminds.iot.things.rule.api/src/be/iminds/iot/things/rule/api/RuleDTO.java
// public class RuleDTO {
// 
// 	// Types to match the sources
// 	public String[] sourceTypes;
// 	// Types to match the destinations
// 	public String[] destinationTypes;
// 	
// 	// Thing UUIDs this rule listens to
// 	public UUID[] sources;
// 	// Thing UUIDs this rules actions upon
// 	public UUID[] destinations;
// 	
// 	// Rule type string identifier - from this type a factory can create a rule
// 	public String type;
// 	// Description describing this rule
// 	public String description;
// 	
// 	public RuleDTO clone(){
// 		RuleDTO clone = new RuleDTO();
// 		clone.sourceTypes = Arrays.copyOf(sourceTypes, sourceTypes.length);
// 		clone.destinationTypes = Arrays.copyOf(destinationTypes, destinationTypes.length);;
// 		clone.sources = Arrays.copyOf(sources, sources.length);;
// 		clone.destinations = Arrays.copyOf(destinations, destinations.length);;
// 		clone.type = type;
// 		clone.description = description;
// 		return clone;
// 	}
// }
// 
// Path: be.iminds.iot.things.rule.api/src/be/iminds/iot/things/rule/api/RuleEngine.java
// public interface RuleEngine {
// 
// 	public void addRule(Rule rule);
// 	
// 	public void removeRule(int index);
// 	
// 	public List<Rule> getRules();
// 	
// }
// 
// Path: be.iminds.iot.things.rule.api/src/be/iminds/iot/things/rule/api/RuleFactory.java
// public interface RuleFactory {
// 
// 	public Rule createRule(RuleDTO template) throws Exception;
// 	
// 	public Collection<RuleDTO> getTemplates();
// }


import java.util.Collection;
import java.util.List;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import osgi.enroute.rest.api.REST;
import be.iminds.iot.things.rule.api.Rule;
import be.iminds.iot.things.rule.api.RuleDTO;
import be.iminds.iot.things.rule.api.RuleEngine;
import be.iminds.iot.things.rule.api.RuleFactory;
import java.util.ArrayList;
/*******************************************************************************
 *  Copyright (c) 2015, Tim Verbelen
 *  Internet Based Communication Networks and Services research group (IBCN),
 *  Department of Information Technology (INTEC), Ghent University - iMinds.
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *     - Redistributions of source code must retain the above copyright notice,
 *       this list of conditions and the following disclaimer.
 *     - Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     - Neither the name of Ghent University - iMinds, nor the names of its 
 *       contributors may be used to endorse or promote products derived from 
 *       this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *  POSSIBILITY OF SUCH DAMAGE.
 *******************************************************************************/
package be.iminds.iot.things.rule.endpoint;




@Component()
public class RulesRestEndpoint implements REST {

	private RuleEngine engine;
	private RuleFactory factory;
	
// Path: be.iminds.iot.things.rule.api/src/be/iminds/iot/things/rule/api/Rule.java
// public interface Rule extends Serializable {
// 
// 	/**
// 	 * Evaluates the rule, returns whether it is triggered or not
// 	 * 
// 	 * @param change the change that can cause the rule to trigger
// 	 */
// 	public boolean evaluate(Change change);
// 	
// 	/**
// 	 * Get the type identifier of this Rule
// 	 */
// 	public String getType();
// 	
// 	/**
// 	 * Get the custom human readable description of this Rule
// 	 */
// 	public String getDescription();
// 	
// 	/**
// 	 * Get the DTO representing this Rule
// 	 */
// 	public RuleDTO getDTO();
// 	
// 	/**
// 	 * Notifies when a Thing that is applicable for this rule is online/offline
// 	 * In case of online, the Thing object is set, in case of offline, null is set
// 	 * 
// 	 * @param id uuid of the Thing
// 	 * @param thing the Thing object
// 	 */
// 	public void setThing(UUID id, Thing thing);
// }
// 
// Path: be.iminds.iot.things.rule.api/src/be/iminds/iot/things/rule/api/RuleDTO.java
// public class RuleDTO {
// 
// 	// Types to match the sources
// 	public String[] sourceTypes;
// 	// Types to match the destinations
// 	public String[] destinationTypes;
// 	
// 	// Thing UUIDs this rule listens to
// 	public UUID[] sources;
// 	// Thing UUIDs this rules actions upon
// 	public UUID[] destinations;
// 	
// 	// Rule type string identifier - from this type a factory can create a rule
// 	public String type;
// 	// Description describing this rule
// 	public String description;
// 	
// 	public RuleDTO clone(){
// 		RuleDTO clone = new RuleDTO();
// 		clone.sourceTypes = Arrays.copyOf(sourceTypes, sourceTypes.length);
// 		clone.destinationTypes = Arrays.copyOf(destinationTypes, destinationTypes.length);;
// 		clone.sources = Arrays.copyOf(sources, sources.length);;
// 		clone.destinations = Arrays.copyOf(destinations, destinations.length);;
// 		clone.type = type;
// 		clone.description = description;
// 		return clone;
// 	}
// }
// 
// Path: be.iminds.iot.things.rule.api/src/be/iminds/iot/things/rule/api/RuleEngine.java
// public interface RuleEngine {
// 
// 	public void addRule(Rule rule);
// 	
// 	public void removeRule(int index);
// 	
// 	public List<Rule> getRules();
// 	
// }
// 
// Path: be.iminds.iot.things.rule.api/src/be/iminds/iot/things/rule/api/RuleFactory.java
// public interface RuleFactory {
// 
// 	public Rule createRule(RuleDTO template) throws Exception;
// 	
// 	public Collection<RuleDTO> getTemplates();
// }


// Path: be.iminds.iot.things.rule.engine.provider/src/be/iminds/iot/things/rule/endpoint/RulesRestEndpoint.java
import java.util.Collection;
import java.util.List;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import osgi.enroute.rest.api.REST;
import be.iminds.iot.things.rule.api.Rule;
import be.iminds.iot.things.rule.api.RuleDTO;
import be.iminds.iot.things.rule.api.RuleEngine;
import be.iminds.iot.things.rule.api.RuleFactory;
import java.util.ArrayList;

/*******************************************************************************
 *  Copyright (c) 2015, Tim Verbelen
 *  Internet Based Communication Networks and Services research group (IBCN),
 *  Department of Information Technology (INTEC), Ghent University - iMinds.
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *     - Redistributions of source code must retain the above copyright notice,
 *       this list of conditions and the following disclaimer.
 *     - Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     - Neither the name of Ghent University - iMinds, nor the names of its 
 *       contributors may be used to endorse or promote products derived from 
 *       this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *  POSSIBILITY OF SUCH DAMAGE.
 *******************************************************************************/
package be.iminds.iot.things.rule.endpoint;




@Component()
public class RulesRestEndpoint implements REST {

	private RuleEngine engine;
	private RuleFactory factory;
	
	public List<RuleDTO> getRules(){