 <cfif action is "show">
 <script src="/includes/sorttable.js"></script>
 <cfoutput>
+
+	<p>
+		<a href="BulkloadTaxonomy.cfm?action=getFile">download CSV</a>
+	</p>
+	<p>
+		<a href="BulkloadTaxonomy.cfm?action=makeTemplate">get a template</a> (or just load CSV with one column "scientific_name")
+	</p>
+
+
 	<cfquery name="data" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
-		select * from cf_temp_taxonomy
+		select * from cf_temp_taxonomy  where upper(username)='#ucase(session.username)#'
 	</cfquery>
 	<cfquery name="isProb" dbtype="query">
-		select count(*) c from data where status ='valid'
+		select status,count(*) c from data group by status
 	</cfquery>
+	Status:
+	<ul>
+		<cfloop query="isProb">
+			<li>#status# (#c#)</li>
+		</cfloop>
+	</ul>
 	<p>
 		This form will happily create garbage. CHECK <strong>ALL</strong> DATA CAREFULLY BEFORE LOADING!!!
 	</p>
 	<p>
-		This form is not the preferred method of creating classifications. Use GNITE if you can.
+		You should <a href="BulkloadTaxonomy.cfm?action=validate">validate</a> before loading. The validation service queries various sources
+		for the name. It fails, often, with both false positives and false negatives. You are solely responsible for the names you create.
+		Only records with NULL status will be validated. You may need to reload a few times; the external services can be slow.
 	</p>
-	<P>
-		Some terms may not mean what you think they do. Ask us (contact link below) if you're uncertain.
-	</P>
-	<ul>
-		<cfif isProb.c eq data.recordcount>
-			<li><strong>Carefully</strong> check the table below, then <a href="BulkloadTaxonomy.cfm?action=loadData">continue to load</a></li>
-		</cfif>
-		<li>
-			<a href="BulkloadTaxonomy.cfm?action=autogenmn">Click here to generate multinomials</a>
-			<br>Do this BEFORE generating display_name
-			<br>Do this BEFORE validation
-			<br>CHECK THE RESULTS
-		</li>
-		<li>
-			<a href="BulkloadTaxonomy.cfm?action=autogendispname">Click here to generate display_name</a>
-			Do this BEFORE validation and CHECK THE RESULTS. This may not do what you want if you don't specify nomenclatural_code.
-		</li>
-		<li><a href="BulkloadTaxonomy.cfm?action=validate">validate</a></li>
-		<li><a href="BulkloadTaxonomy.cfm?action=deleteDups">discard duplicate names</a></li>
-		<li><a href="BulkloadTaxonomy.cfm?action=down">download</a></li>
-		<li><a href="BulkloadTaxonomy.cfm?action=nothing">start over</a></li>
-	</ul>
+	<p>
+		If everything looks happy, you can <a href="BulkloadTaxonomy.cfm?action=loadData">load data</a>. Names will be deleted from this
+		app as they load. You may have to reload a few times for very large datasets.
 	<cfset h=data.columnlist>
 	<table border id="t" class="sortable">
 		<tr>

<!------------------------------------------------------->
<cfif action is "nothing">
	<cfoutput>
		Load names, optionally with classifications. This form will happily create garbage; use the Contact link below to ask questions and do not
		click any buttons unless you KNOW what they do.
		 <p>
			Upload a comma-delimited text file (csv). <a href="BulkloadTaxonomy.cfm?action=makeTemplate">[ Get the Template ]</a>
		</p>
		<p>
			You can (and should) also pull classification from globalnames.
		</p>
		<p>subgeneric terms are multinomial</p>
		<p>
			Source is <a href="/info/ctDocumentation.cfm?table=CTTAXONOMY_SOURCE">CTTAXONOMY_SOURCE</a>
		</p>
		<cfform name="oids" method="post" enctype="multipart/form-data" action="BulkloadTaxonomy.cfm">
			<input type="hidden" name="action" value="getFile">
			<input type="file" name="FiletoUpload" size="45" onchange="checkCSV(this);">

</cfoutput>
</cfif>
<!------------------------------------------------------->
<cfif action is "validate">
<cfoutput>
	<cfquery name="d" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
		select * from  cf_temp_taxonomy  where status is null and  upper(username)='#ucase(session.username)#'
	</cfquery>
	<cfset tc = CreateObject("component","component.taxonomy")>

	<cfloop query="d">
		<cfset result=tc.validateName(scientific_name)>
		<cfquery name="u" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
			update cf_temp_taxonomy set status='#result.consensus#' where scientific_name='#scientific_name#'
		</cfquery>
	</cfloop>
	<cflocation url="BulkloadTaxonomy.cfm" addtoken="false">
</cfoutput>
</cfif>



<!------------------------------------------------------->
<cfif action is "loadData">
<cfoutput>
	<cfquery name="d" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
		select * from  cf_temp_taxonomy  where  upper(username)='#ucase(session.username)#'
	</cfquery>
	<cfloop query="d">
		<cftransaction>
			<cfquery name="isn" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
				insert into taxon_name (scientific_name) values ('#scientific_name#')
			</cfquery>
			<cfquery name="dup" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
				delete from cf_temp_taxonomy  where scientific_name='#scientific_name#' and upper(username)='#ucase(session.username)#'
			</cfquery>
			<br>loaded #scientific_name#
		</cftransaction>
	</cfloop>
	Spiffy, all done.
</cfoutput>
</cfif>
