<beans xmlns:p="http://www.springframework.org/schema/p"
	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	   xmlns="http://www.springframework.org/schema/beans"
	   xsi:schemaLocation="http://www.springframework.org/schema/beans
						http://www.springframework.org/schema/beans/spring-beans.xsd
						http://www.springframework.org/schema/context
    					http://www.springframework.org/schema/context/spring-context-3.0.xsd">

	<bean id="collectionsSubprocessor"
	  	class="org.dataone.cn.indexer.parser.ScienceMetadataDocumentSubprocessor">
	  	<property name="xmlNamespaceConfig" ref="xmlNamespaceConfig" />
		<property name="matchDocuments">
	   		<list>
				<value>https://purl.dataone.org/collections-1.0.0</value>
				<value>https://purl.dataone.org/collections-1.1.0</value>
			</list>
	   	</property>
	  	<property name="fieldList">
		   	<list>
		    	<ref bean="collections.name" />
		    	<ref bean="collections.label" />
		    	<ref bean="collections.description" />
				<ref bean="collection.collectionQuery" />
		   	</list>
	  	</property>
	</bean>

	<bean id="collections.label" class="org.dataone.cn.indexer.parser.SolrField">
	  <constructor-arg name="name" value="label" />
	  <constructor-arg name="xpath" value="//label/text()" />
	  <property name="multivalue" value="false" />
	</bean>

	<bean id="collections.name" class="org.dataone.cn.indexer.parser.SolrField">
	  <constructor-arg name="name" value="title" />
	  <constructor-arg name="xpath" value="//name/text()" />
	  <property name="multivalue" value="false" />
	</bean>

	<bean id="collections.description" class="org.dataone.cn.indexer.parser.SolrField">
	  <constructor-arg name="name" value="abstract" />
	  <constructor-arg name="xpath" value="//description/text()" />
	  <property name="multivalue" value="false" />
	</bean>

	<bean id="collection.collectionQuery" class="org.dataone.cn.indexer.parser.FilterCommonRootSolrField"
		  p:root-ref="collection.filterFields">
		<constructor-arg name="name" value="collectionQuery" />
	</bean>

    <!-- See 'FilterRootElement.java and FilterGroupProcessor.java for an explaination of the properties defined for
         processing collection filter defintions.
    -->

	<bean id="collection.filterFields" class="org.dataone.cn.indexer.parser.utility.FilterRootElement"
		  p:name="collectionQuery"
		  p:xPath=".//definition/booleanFilter | .//definition/dateFilter | .//definition/filter | .//definition/numericFilter | .//definition/filterGroup | booleanFilter | dateFilter | filter | numericFilter | filterGroup"
		  p:idFilterMatch="id,identifier,seriesId"
		  p:catalogQuery="(-obsoletedBy:* AND formatType:METADATA)"
	      p:isPartOfFilterMatch="isPartOf">
		<property name="filters">
			<list>
				<ref bean="collection.booleanFilter"/>
				<ref bean="collection.dateFilter"/>
				<ref bean="collection.numericFilter"/>
				<ref bean="collection.textFilter"/>
			</list>
		</property>
		<property name="filterGroup">
			<ref bean="collection.filterGroup"/>
		</property>
	</bean>

	<bean id="collection.booleanFilter" class="org.dataone.cn.indexer.parser.utility.FilterProcessor"
		  p:name="booleanFilter"
		  p:matchElement="booleanFilter"
		  p:template="field:value">
		<property name="leafs">
			<list>
				<ref bean="collection.filterFieldLeaf"/>
				<ref bean="collection.filterOperatorLeaf"/>
				<ref bean="collection.filterValueLeaf"/>
				<ref bean="collection.filterExclude"/>
			</list>
		</property>
	</bean>

	<bean id="collection.dateFilter" class="org.dataone.cn.indexer.parser.utility.FilterProcessor"
		  p:name="dateFilter"
		  p:matchElement="dateFilter"
		  p:defaults="min:*,max:*"
		  p:template="field:value,field:[min TO max]">
		<property name="leafs">
			<list>
				<ref bean="collection.filterFieldLeaf"/>
				<ref bean="collection.filterMinLeaf"/>
				<ref bean="collection.filterMaxLeaf"/>
				<ref bean="collection.filterOperatorLeaf"/>
				<ref bean="collection.filterValueLeaf"/>
				<ref bean="collection.filterExclude"/>
			</list>
		</property>
	</bean>

	<bean id="collection.numericFilter" class="org.dataone.cn.indexer.parser.utility.FilterProcessor"
		  p:name="numericFilter"
		  p:matchElement="numericFilter"
		  p:defaults="min:*,max:*"
		  p:template="field:value,field:[min TO max]">
		<property name="leafs">
			<list>
				<ref bean="collection.filterFieldLeaf"/>
				<ref bean="collection.filterMinLeaf"/>
				<ref bean="collection.filterMaxLeaf"/>
				<ref bean="collection.filterOperatorLeaf"/>
				<ref bean="collection.filterFieldsOperatorLeaf"/>
				<ref bean="collection.filterValueLeaf"/>
				<ref bean="collection.filterExclude"/>
			</list>
		</property>
	</bean>

	<bean id="collection.textFilter" class="org.dataone.cn.indexer.parser.utility.FilterProcessor"
		  p:name="textfilter"
		  p:matchElement="filter"
		  p:escapeSpecialChars="true"
		  p:quoteMultipleWords="true"
		  p:template="field:value">
		<property name="leafs">
			<list>
				<ref bean="collection.filterFieldLeaf"/>
				<ref bean="collection.filterOperatorLeaf"/>
				<ref bean="collection.filterFieldsOperatorLeaf"/>
				<ref bean="collection.filterValueLeaf"/>
				<ref bean="collection.filterExclude"/>
				<ref bean="collection.filterMatchSubstring"/>
			</list>
		</property>
	</bean>

	<bean id="collection.filterGroup" class="org.dataone.cn.indexer.parser.utility.FilterGroupProcessor"
		  p:name="filterGroup"
		  p:matchElement="filterGroup">
	</bean>

	<!-- Currently 'field' is the only element in the collection.xsd that is allowed repeat,
         so only need a delimeter for this, to determine if multiple values have been specified. -->
	<bean id="collection.filterFieldLeaf" class="org.dataone.cn.indexer.parser.utility.LeafElement"
		  p:name="field"
		  p:delimiter="--"
		  p:xPath="field/text()" />

	<bean id="collection.filterValueLeaf" class="org.dataone.cn.indexer.parser.utility.LeafElement"
		  p:name="value"
		  p:delimiter="--"
		  p:xPath="value/text()" />

	<bean id="collection.filterExcludeLeaf" class="org.dataone.cn.indexer.parser.utility.LeafElement"
		  p:name="exclude"
		  p:xPath="exclude/text()" />

	<bean id="collection.filterMinLeaf" class="org.dataone.cn.indexer.parser.utility.LeafElement"
		  p:name="min"
		  p:xPath="min/text()" />

	<bean id="collection.filterMaxLeaf" class="org.dataone.cn.indexer.parser.utility.LeafElement"
		  p:name="max"
		  p:xPath="max/text()" />

	<bean id="collection.filterOperatorLeaf" class="org.dataone.cn.indexer.parser.utility.LeafElement"
		  p:name="operator"
		  p:xPath="operator/text()" />

	<bean id="collection.filterFieldsOperatorLeaf" class="org.dataone.cn.indexer.parser.utility.LeafElement"
		  p:name="fieldsOperator"
		  p:xPath="fieldsOperator/text()" />

	<bean id="collection.filterExclude" class="org.dataone.cn.indexer.parser.utility.LeafElement"
		  p:name="exclude"
		  p:xPath="exclude/text()" />

	<bean id="collection.filterMatchSubstring" class="org.dataone.cn.indexer.parser.utility.LeafElement"
		  p:name="matchSubstring"
		  p:xPath="matchSubstring/text()" />

</beans>
