package gr.iti.mklab.framework.common.domain.config;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.mongodb.morphia.annotations.Entity;

import gr.iti.mklab.framework.common.domain.JSONable;

/**
 * Class for the configuration of streams or storages 
 * reading a set of parameters
 * 
 * @author manosetro - manosetro@iti.gr
 *
 */

@Entity(noClassnameStored = true)
public class Configuration extends JSONable implements Iterable<String> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5070483137103099259L;
	
	public static final String CLASS_PATH = "Classpath";
	
	private Map<String, String> params = new HashMap<String, String>();

	public String getParameter(String name) {
		return getParameter(name,null);
	}
	
	public String getParameter(String name, String defaultValue){
		String value = params.get(name);
		return value == null ? defaultValue : value;
	}
	
	public void setParameter(String name, String value) {
		params.put(name,value);
	}

	@Override
	public Iterator<String> iterator() {
		return params.keySet().iterator();
	}
	
}

@@ -121,16 +121,80 @@
 til.Map;
+%0Aimport java.util.regex.Matcher;%0Aimport java.util.regex.Pattern;
 %0A%0Aimport
@@ -626,16 +626,96 @@
 259L;%0A%09%0A
+%09private static Pattern pattern = Pattern.compile(%22(%5C%5CQ$%7B%5C%5CE)(.*)(%5C%5CQ%7D%5C%5CE)%22);%0A%09%0A
 %09public 
@@ -976,16 +976,17 @@
 tValue)%7B
+%09
 %0A%09%09Strin
@@ -1013,16 +1013,177 @@
 (name);%0A
+%09%09%0A%09%09Matcher matcher = pattern.matcher(value);%0A%09%09if(value != null && matcher.find()) %7B%0A%09%09%09value = matcher.group(2);%0A%09%09%09value = System.getProperty(value);%0A%09%09%7D%0A%09%09%0A
 %09%09return

Fix config to accept system variables