package it.cnr.isti.driver.utils;


import org.springframework.beans.factory.annotation.Autowired;

/**
 * The DynamicDriverCollection represents a Driver collection whose state is maintained in the Driver IS
 * 
 * @author marko
 *
 */
public class DynamicDriverCollection extends AbstractDriverCollection {

	@Autowired
	protected LookUpServiceLocator lookupLocator;

	/**
	 * Fetches the membership condition from the Driver IS
	 * 
	 * @return CQL query source
	 */
	public String getQuery() {
		IS_LookUpClient lookup = lookupLocator.getService();

		String query = "collection('/db/DRIVER/CollectionDSResources/CollectionDSResourceType')"
				+ "//CONFIGURATION[NAME='" + getName() + "']/MEMBERSHIP_CONDITION/text()";

		return lookup.getResourceProfileByQuery(query);
	}
	
}
