<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>

<h2>${applicationScope.ConsensusFoundation.ontologyManager.queryEngine.querySyntaxName}-Suche</h2>

<p>Im folgenden Formular k&ouml;nnen Sie eine Suchanfrage in <html:link href="${applicationScope.ConsensusFoundation.ontologyManager.queryEngine.querySyntaxURL}">${applicationScope.ConsensusFoundation.ontologyManager.queryEngine.querySyntaxName} ${applicationScope.ConsensusFoundation.ontologyManager.queryEngine.querySyntaxVersion}</html:link>-Syntax formulieren:</p>

<script language="JavaScript1.1" type="text/javascript">
<!--

var queries = new Array(
	"select $T from topic($T)",
	"select $T,$O from topic($T),occurrence($T,$O)",
	"select $A from association($A)",
	"select $A,$R,$P from association($A),association-role($A,$R),role-player($R,$P)"
);

function selectQuery(idx)
{
	var area = document.getElementsByName( "suchanfrage" )[0];
	area.value = queries[idx-1];
	var select = document.getElementById( "auswahl" );
	select.selectedIndex = 0;
}
// -->
</script>


<div class="FORMULAR">
	<html:errors/>

	<select id="auswahl" onChange="selectQuery(this.selectedIndex)">
	<option disabled selected>Vordefinierte Abfrage in das Eingabefeld &uuml;bernehmen?
	<option>Alle Topics
	<option>Alle Topics mit Occurrences
	<option>Alle Assoziationen
	<option>Alle Assoziationen mit Rollen und Spielern
	</select>

	<html:form action="enginesearch" focus="suchanfrage">
		<p><bean:message key="engineform.searchstring"/>:<br>
		<html:textarea property="suchanfrage" cols="70" rows="5"/></p>
		<p><html:submit><bean:message key="engineform.submit"/></html:submit></p>
	</html:form>
</div>

<p>&nbsp;</p>

<c:choose>
	<c:when test="${not empty requestScope.EngineError}">
		<hr><p>&nbsp;</p>
		<div class="FEHLER">
			<p>Bei der Suche ist ein Fehler aufgetreten:<br>${requestScope.EngineError}</p>
		</div>
	</c:when>
	<c:when test="${not empty requestScope.EngineResults}">
		<hr>
		<p>Ergebnisse: ${requestScope.EngineResults.rowCount}</p>
		<c:if test="${requestScope.EngineResults.rowCount > 0}">
			<table border="1" cellpadding="2" cellspacing="2">
				<tr>
					<th>Nr</th>
					<c:forEach items="${requestScope.EngineResults.columnNames}" var="colname">
						<th>${colname}</th>
					</c:forEach>
				</tr>
				<c:forEach items="${requestScope.EngineResults.rows}" var="row" varStatus="nr">
					<tr>
						<td>${nr.count}</td>
						<c:forEach items="${row}" var="col">
							<td>${col}</td>
						</c:forEach>
					</tr>
				</c:forEach>
			</table>
		</c:if>
	</c:when>
	<c:otherwise>
	</c:otherwise>
</c:choose>
