<%@ page import="oracle.jsp.webutil.personalization.Item" errorPage="error.jsp" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/jml.tld" prefix="jml" %>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/personalization.tld" prefix="op" %>

<html>
<head><title>Personalization Demo</title></head>
<body>
<b><font size=+1>getRecommendations Tag</font></b>
<p>  Use non-dflt Tuning ONLY w/non-dflt Filtering, </p>
<p>  Use non-dflt Filtering with Dflt Tuning </p>
<p>  Use HPGroups with Default Tun & Filtering, </p>
<p>  Use "no IntDim" with Default Tun & Filtering </p>
<p>

<font color="#FF0000">Using storeResultsIn variable </font><br>


<%
   String tuningMeth = request.getParameter("tuningMeth");
   String tuningName = request.getParameter("tuningName");
   String dfltTuning = request.getParameter("dfltTuning");
   String filteringMeth = request.getParameter("filteringMeth");
   String filteringName = request.getParameter("filteringName");
   String dfltFiltering = request.getParameter("dfltFiltering");
   String sortOrder = request.getParameter("sortOrder");
   String maxQ = request.getParameter("maxQ");
   String from = request.getParameter("from");
   String fromHPG = request.getParameter("fromHPG");
   String IntDim = request.getParameter("useIntDim");
   boolean useIntDim = ((IntDim== null)? false :IntDim.equals("true"));

   Item[] items = null;
   String Dim = Item.INT_DIM_NAVIGATION;

 if(tuningMeth != null) {
   if(tuningMeth.equals("Dflt") && filteringMeth.equals("Dflt")) { 
      if(!useIntDim){ %>
<op:getRecommendations storeResultsIn="results" >

</op:getRecommendations>
<% items = results; Dim="Not_Given";
      } else { 
        if(fromHPG != null) {
%>
<op:getRecommendations fromHotPicksGroups="<%=fromHPG%>"
                       storeResultsIn="results"
                       maxQuantity="<%=maxQ%>"
                       sortOrder="<%=sortOrder%>" >
</op:getRecommendations>
<% items = results; Dim="Not_Given";
        }
 else { %>
<op:getRecommendations from="<%=from%>"
                       storeResultsIn="results"
                       maxQuantity="<%=maxQ%>"
                       sortOrder="<%=sortOrder%>" >
</op:getRecommendations>
<% items = results; Dim="Not_Given";
        } 
   } }
   else if(tuningMeth.equals("Dflt")) { %>
<op:getRecommendations from="<%=from%>"
                       storeResultsIn="results"
                       storeInterestDimensionIn="intDim"
                       maxQuantity="<%=maxQ%>"
                       filteringName="filter1" 
                       filteringTaxonomyID="<%=request.getParameter(\"filteringTaxID\")%>"
                       filteringMethod="<%=request.getParameter(\"filteringMethAttr\")%>"
                       filteringCategories="<%=request.getParameter(\"filteringCats\")%>"
                       sortOrder="<%=sortOrder%>" >
</op:getRecommendations>
<% items = results; Dim=intDim; 
} else if(filteringMeth.equals("Dflt")) { %>
<op:getRecommendations from="<%=from%>"
                       storeResultsIn="results"
                       storeInterestDimensionIn="intDim"
                       maxQuantity="<%=maxQ%>"
                       tuningName="<%=tuningName%>"
                       sortOrder="<%=sortOrder%>" >
</op:getRecommendations>
<%  items = results; Dim=intDim; 
} else { %>
<op:getRecommendations from="<%=from%>"
                       storeResultsIn="results"
                       storeInterestDimensionIn="intDim"
                       maxQuantity="<%=maxQ%>"
                  tuningDataSource="<%=request.getParameter(\"tuningDS\")%>"
                  tuningInterestDimension="<%=request.getParameter(\"tuningID\")%>"
                  tuningPersonalizationIndex="<%=request.getParameter(\"tuningPI\")%>"
                  tuningProfileDataBalance="<%=request.getParameter(\"tuningPDB\")%>"
                  tuningProfileUsage="<%=request.getParameter(\"tuningPU\")%>"

                       filteringTaxonomyID="<%=request.getParameter(\"filteringTaxID\")%>"
                       filteringMethod="<%=request.getParameter(\"filteringMethAttr\")%>"
                       filteringCategories="<%=request.getParameter(\"filteringCats\")%>"
                       sortOrder="<%=sortOrder%>" >
</op:getRecommendations>
<%  items = results; Dim=intDim; 
} %>

<p>Here are items we found for you according to interest dimension <b><%=Dim%></b> :</p>

<table border=1>
<tr><td><b>&nbsp;Type</b></td><td><b>&nbsp;ID</b></td>
<td><b>&nbsp;Prediction</b></td></tr>
<jml:for id="i" from="0" to="<%= items.length-1 %>" >
<tr><td><%=items[i.intValue()].getType()%></td><td><%=items[i.intValue()].getID()%></td>
<td><%=items[i.intValue()].getPrediction()%></td></tr>
</jml:for>
</table>
<hr>
<% } %>

<form action="tagdemodriver.jsp" method="post">
<input type="hidden" name="target" value="Return"/>
<input type="submit" name="Choose another tag" value="Choose another tag"/>
</form>

<p>
<form action="getrecsinlist.jsp" method="post">
<table>

<tr><td><b>Use storeInterestDimensionIn:</b> </td><td><input type="checkbox" name="useIntDim" value="true" checked/></td></tr>

<tr><td><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; From: </b></td> </tr>
<tr><td><label><input type="radio" name="from" value="Top" checked>Top </label></td>
<td><label><input type="radio" name="from" value="HPG" >Hot Picks Groups <input type="text" name="fromHPG"/></label></td>
<td><label><input type="radio" name="from" value="Bottom" >Bottom </label></td>
</tr>

<tr><td><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tuning </b></td> </tr>
<tr><td><label><input type="radio" name="tuningMeth" value="Attr" checked>Use Attributes </label></td>
<td><label><input type="radio" name="tuningMeth" value="Name" >Use Tuning Name <input type="text" name="tuningName"/></label></td>
<td><label><input type="radio" name="tuningMeth" value="Dflt" >Use Default Tuning </label></td>
</tr>
<tr><td><b>Tuning Data Source:</b> </td><td><input type="text" name="tuningDS"/></td></tr>
<tr><td><b>Tuning Interest Dimension:</b> </td><td><input type="text" name="tuningID"/></td></tr>
<tr><td><b>Tuning Personalization Index:</b> </td><td><input type="text" name="tuningPI"/></td></tr>
<tr><td><b>Tuning Profile Data Balance:</b> </td><td><input type="text" name="tuningPDB"/></td></tr>
<tr><td><b>Tuning Profile Usage:</b> </td><td><input type="text" name="tuningPU"/></td></tr>

<tr><td><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Filtering </b></td> </tr>
<tr><td><label><input type="radio" name="filteringMeth" value="Attr" checked>Use Attributes </label></td>
<td><label><input type="radio" name="filteringMeth" value="Name" >Use Filtering Name <input type="text" name="filteringName"/></label></td>
<td><label><input type="radio" name="filteringMeth" value="Dflt" >Use Default Filtering </label></td>
</tr>
<tr><td><b>FilteringTaxonomyID:</b> </td><td><input type="text" name="filteringTaxID"/></td></tr>
<tr><td><b>FilteringMethod:</b> </td><td><input type="text" name="filteringMethAttr"/></td></tr>
<tr><td><b>FilteringCategories:</b> </td><td><input type="text" name="filteringCats"/></td></tr>

<tr><td><b>sortOrder:</b> </td><td><select name="sortOrder">
<option value="NONE">NONE</option>
<option value="">no value</option>
<option value="DESCEND">DESCEND</option>
<option value="ASCEND">ASCEND</option>
</select></td>
<td><b>maxQuantity:</b> <input type="text" size=2 name="maxQ" /> </td>
</tr>
</table>
<input type="submit" name="submit" value="Submit"/>
</form>

</body>
</html>
