// Path: src/de/uni_koblenz/west/splendid/config/FederationSailSchema.java
// public static final URI MEMBER    = vf.createURI(NAMESPACE + "member");
// 
// Path: src/de/uni_koblenz/west/splendid/config/FederationSailSchema.java
// public static final URI QUERY_OPT = vf.createURI(NAMESPACE + "queryOptimization");
// 
// Path: src/de/uni_koblenz/west/splendid/config/FederationSailSchema.java
// public static final URI SRC_SELECTION = vf.createURI(NAMESPACE + "sourceSelection");


import org.openrdf.repository.config.RepositoryConfigException;
import org.openrdf.repository.config.RepositoryImplConfig;
import org.openrdf.repository.config.RepositoryImplConfigBase;
import org.openrdf.sail.config.SailConfigException;
import static de.uni_koblenz.west.splendid.config.FederationSailSchema.MEMBER;
import static de.uni_koblenz.west.splendid.config.FederationSailSchema.QUERY_OPT;
import static de.uni_koblenz.west.splendid.config.FederationSailSchema.SRC_SELECTION;
import java.util.ArrayList;
import java.util.List;
import org.openrdf.model.Graph;
import org.openrdf.model.Resource;
import org.openrdf.model.Value;
/*
 * This file is part of RDF Federator.
 * Copyright 2010 Olaf Goerlitz
 * 
 * RDF Federator is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * RDF Federator is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with RDF Federator.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * RDF Federator uses libraries from the OpenRDF Sesame Project licensed 
 * under the Aduna BSD-style license. 
 */
package de.uni_koblenz.west.splendid.config;




/**
 * Configuration details for federation setup including member descriptions.
 * 
 * @author Olaf Goerlitz
 */
public class FederationSailConfig extends AbstractSailConfig {
	
	private static final String DEFAULT_SOURCE_SELECTION = "INDEX_ASK";
	private static final String DEFAULT_OPTIMIZER_STRATEGY = "DYNAMIC_PROGRAMMING";
	
	private final List<RepositoryImplConfig> memberConfig = new ArrayList<RepositoryImplConfig>();
	private SourceSelectorConfig selectorConfig;
	private QueryOptimizerConfig optimizerConfig;
	
	/**
	 * Returns the configuration settings of the federation members.
	 * 
	 * @return the member repository configuration settings.
	 */
	public List<RepositoryImplConfig> getMemberConfigs() {
		return this.memberConfig;
	}
	
	/**
	 * Returns the configuration settings of the source selector.
	 * 
	 * @return the source selection configuration settings.
	 */
	public SourceSelectorConfig getSelectorConfig() {
		return this.selectorConfig;
	}
	
	public QueryOptimizerConfig getOptimizerConfig() {
		return this.optimizerConfig;
	}
	
	// -------------------------------------------------------------------------

	/**
	 * Adds all Sail configuration settings to a configuration model.
	 * 
	 * @param model the configuration model to be filled.
	 * @return the resource representing this Sail configuration.
	 */
	@Override
	public Resource export(Graph model) {
		
		Resource self = super.export(model);
		
		for (RepositoryImplConfig member : this.memberConfig) {
			model.add(self, MEMBER, member.export(model));
		}
		
		model.add(self, SRC_SELECTION, this.selectorConfig.export(model));
// Path: src/de/uni_koblenz/west/splendid/config/FederationSailSchema.java
// public static final URI MEMBER    = vf.createURI(NAMESPACE + "member");
// 
// Path: src/de/uni_koblenz/west/splendid/config/FederationSailSchema.java
// public static final URI QUERY_OPT = vf.createURI(NAMESPACE + "queryOptimization");
// 
// Path: src/de/uni_koblenz/west/splendid/config/FederationSailSchema.java
// public static final URI SRC_SELECTION = vf.createURI(NAMESPACE + "sourceSelection");


// Path: src/de/uni_koblenz/west/splendid/config/FederationSailConfig.java
import org.openrdf.repository.config.RepositoryConfigException;
import org.openrdf.repository.config.RepositoryImplConfig;
import org.openrdf.repository.config.RepositoryImplConfigBase;
import org.openrdf.sail.config.SailConfigException;
import static de.uni_koblenz.west.splendid.config.FederationSailSchema.MEMBER;
import static de.uni_koblenz.west.splendid.config.FederationSailSchema.QUERY_OPT;
import static de.uni_koblenz.west.splendid.config.FederationSailSchema.SRC_SELECTION;
import java.util.ArrayList;
import java.util.List;
import org.openrdf.model.Graph;
import org.openrdf.model.Resource;
import org.openrdf.model.Value;

/*
 * This file is part of RDF Federator.
 * Copyright 2010 Olaf Goerlitz
 * 
 * RDF Federator is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * RDF Federator is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with RDF Federator.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * RDF Federator uses libraries from the OpenRDF Sesame Project licensed 
 * under the Aduna BSD-style license. 
 */
package de.uni_koblenz.west.splendid.config;




/**
 * Configuration details for federation setup including member descriptions.
 * 
 * @author Olaf Goerlitz
 */
public class FederationSailConfig extends AbstractSailConfig {
	
	private static final String DEFAULT_SOURCE_SELECTION = "INDEX_ASK";
	private static final String DEFAULT_OPTIMIZER_STRATEGY = "DYNAMIC_PROGRAMMING";
	
	private final List<RepositoryImplConfig> memberConfig = new ArrayList<RepositoryImplConfig>();
	private SourceSelectorConfig selectorConfig;
	private QueryOptimizerConfig optimizerConfig;
	
	/**
	 * Returns the configuration settings of the federation members.
	 * 
	 * @return the member repository configuration settings.
	 */
	public List<RepositoryImplConfig> getMemberConfigs() {
		return this.memberConfig;
	}
	
	/**
	 * Returns the configuration settings of the source selector.
	 * 
	 * @return the source selection configuration settings.
	 */
	public SourceSelectorConfig getSelectorConfig() {
		return this.selectorConfig;
	}
	
	public QueryOptimizerConfig getOptimizerConfig() {
		return this.optimizerConfig;
	}
	
	// -------------------------------------------------------------------------

	/**
	 * Adds all Sail configuration settings to a configuration model.
	 * 
	 * @param model the configuration model to be filled.
	 * @return the resource representing this Sail configuration.
	 */
	@Override
	public Resource export(Graph model) {
		
		Resource self = super.export(model);
		
		for (RepositoryImplConfig member : this.memberConfig) {
			model.add(self, MEMBER, member.export(model));
		}
		
		model.add(self, SRC_SELECTION, this.selectorConfig.export(model));
		model.add(self, QUERY_OPT, this.optimizerConfig.export(model));