NIHVIVO-2460 Migrate menu pages to Solr index
This commit is contained in:
parent
e05a531d95
commit
3fbbd561c5
6 changed files with 40 additions and 39 deletions
|
@ -143,17 +143,16 @@
|
|||
</listener>
|
||||
|
||||
<!-- The Lucene index uses a "public" filter, so the PropertyRestrictionPolicyHelper must already be set up. -->
|
||||
<!--
|
||||
<listener>
|
||||
<listener-class> edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneSetup </listener-class>
|
||||
</listener>
|
||||
|
||||
<!--
|
||||
-->
|
||||
<listener>
|
||||
<listener-class>
|
||||
edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup
|
||||
</listener-class>
|
||||
</listener>
|
||||
-->
|
||||
|
||||
<!--<listener>
|
||||
<listener-class>
|
||||
|
@ -874,47 +873,48 @@
|
|||
<servlet-name>ObjectPropertyStatementListingController</servlet-name>
|
||||
<url-pattern>/listObjectPropertyStatements</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
<!--
|
||||
<servlet>
|
||||
<servlet-name>IndividualListController</servlet-name>
|
||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController</servlet-class>
|
||||
</servlet>
|
||||
<!--
|
||||
-->
|
||||
<servlet>
|
||||
<servlet-name>IndividualListController</servlet-name>
|
||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.freemarker.SolrIndividualListController</servlet-class>
|
||||
</servlet>
|
||||
-->
|
||||
<servlet-mapping>
|
||||
<servlet-name>IndividualListController</servlet-name>
|
||||
<url-pattern>/individuallist</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet>
|
||||
|
||||
<!--
|
||||
<servlet>
|
||||
<servlet-name>IndividualListRdf</servlet-name>
|
||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.EntityURLController</servlet-class>
|
||||
</servlet>
|
||||
<!--
|
||||
</servlet>
|
||||
-->
|
||||
<servlet>
|
||||
<servlet-name>IndividualListRdf</servlet-name>
|
||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.IndividualListRdfController</servlet-class>
|
||||
</servlet>
|
||||
-->
|
||||
<servlet-mapping>
|
||||
<servlet-name>IndividualListRdf</servlet-name>
|
||||
<url-pattern>/listrdf/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
<!--
|
||||
<servlet>
|
||||
<servlet-name>SearchController</servlet-name>
|
||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.search.controller.PagedSearchController</servlet-class>
|
||||
</servlet>
|
||||
<!--
|
||||
-->
|
||||
<servlet>
|
||||
<servlet-name>SearchController</servlet-name>
|
||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.search.controller.SolrPagedSearchController</servlet-class>
|
||||
</servlet>
|
||||
-->
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>SearchController</servlet-name>
|
||||
<url-pattern>/search</url-pattern>
|
||||
|
@ -933,16 +933,16 @@
|
|||
<url-pattern>/searchcontroller</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!--
|
||||
<servlet>
|
||||
<servlet-name>AutocompleteController</servlet-name>
|
||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.search.controller.AutocompleteController</servlet-class>
|
||||
</servlet>
|
||||
<!--
|
||||
<servlet>
|
||||
-->
|
||||
<servlet>
|
||||
<servlet-name>AutocompleteController</servlet-name>
|
||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.search.controller.SolrAutocompleteController</servlet-class>
|
||||
</servlet>
|
||||
-->
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>AutocompleteController</servlet-name>
|
||||
<url-pattern>/autocomplete</url-pattern>
|
||||
|
@ -987,17 +987,17 @@
|
|||
<servlet-name>ContactFormController</servlet-name>
|
||||
<url-pattern>/contact</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
<!--
|
||||
<servlet>
|
||||
<servlet-name>JSON Service</servlet-name>
|
||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.JSONServlet</servlet-class>
|
||||
</servlet>
|
||||
<!--
|
||||
-->
|
||||
<servlet>
|
||||
<servlet-name>JSON Service</servlet-name>
|
||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.SolrJsonServlet</servlet-class>
|
||||
</servlet>
|
||||
-->
|
||||
<servlet-mapping>
|
||||
<servlet-name>JSON Service</servlet-name>
|
||||
<url-pattern>/dataservice</url-pattern>
|
||||
|
|
|
@ -33,9 +33,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.SolrIndividualListController.PageRecord;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.SolrIndividualListController;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController.PageRecord;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
|
@ -44,7 +43,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
|||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.SelectListGenerator;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel;
|
||||
|
||||
/**
|
||||
* This servlet is for servicing requests for JSON objects/data.
|
||||
|
@ -54,6 +52,7 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.Individual
|
|||
*/
|
||||
public class SolrJsonServlet extends VitroHttpServlet {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Log log = LogFactory.getLog(SolrJsonServlet.class.getName());
|
||||
private static final int REPLY_SIZE = 256;
|
||||
|
||||
|
@ -79,8 +78,8 @@ public class SolrJsonServlet extends VitroHttpServlet {
|
|||
}else if( vreq.getParameter("getN3EditOptionList") != null ){
|
||||
doN3EditOptionList(req,resp);
|
||||
return;
|
||||
}else if( vreq.getParameter("getLuceneIndividualsByVClass") != null ){
|
||||
getLuceneIndividualsByVClass(req,resp);
|
||||
}else if( vreq.getParameter("getSolrIndividualsByVClass") != null ){
|
||||
getSolrIndividualsByVClass(req,resp);
|
||||
return;
|
||||
}else if( vreq.getParameter("getVClassesForVClassGroup") != null ){
|
||||
getVClassesForVClassGroup(req,resp);
|
||||
|
@ -127,7 +126,7 @@ public class SolrJsonServlet extends VitroHttpServlet {
|
|||
writer.write(map.toString());
|
||||
}
|
||||
|
||||
private void getLuceneIndividualsByVClass( HttpServletRequest req, HttpServletResponse resp ){
|
||||
private void getSolrIndividualsByVClass( HttpServletRequest req, HttpServletResponse resp ){
|
||||
String errorMessage = null;
|
||||
JSONObject rObj = null;
|
||||
try{
|
||||
|
@ -146,7 +145,7 @@ public class SolrJsonServlet extends VitroHttpServlet {
|
|||
log.debug("parameter vclassId URI parameter expected ");
|
||||
throw new Exception("parameter vclassId URI parameter expected ");
|
||||
}
|
||||
rObj = getLuceneIndividualsByVClass(vclass.getURI(),req, getServletContext());
|
||||
rObj = getSolrIndividualsByVClass(vclass.getURI(),req, getServletContext());
|
||||
}catch(Exception ex){
|
||||
errorMessage = ex.toString();
|
||||
log.error(ex,ex);
|
||||
|
@ -175,7 +174,7 @@ public class SolrJsonServlet extends VitroHttpServlet {
|
|||
|
||||
}
|
||||
|
||||
public static JSONObject getLuceneIndividualsByVClass(String vclassURI, HttpServletRequest req, ServletContext context) throws Exception {
|
||||
public static JSONObject getSolrIndividualsByVClass(String vclassURI, HttpServletRequest req, ServletContext context) throws Exception {
|
||||
|
||||
VitroRequest vreq = new VitroRequest(req);
|
||||
VClass vclass=null;
|
||||
|
@ -193,6 +192,7 @@ public class SolrJsonServlet extends VitroHttpServlet {
|
|||
|
||||
|
||||
if( log.isDebugEnabled() ){
|
||||
@SuppressWarnings("unchecked")
|
||||
Enumeration<String> e = vreq.getParameterNames();
|
||||
while(e.hasMoreElements()){
|
||||
String name = (String)e.nextElement();
|
||||
|
@ -224,9 +224,9 @@ public class SolrJsonServlet extends VitroHttpServlet {
|
|||
.put("name",vclass.getName()));
|
||||
|
||||
if (vclass != null) {
|
||||
String alpha = IndividualListController.getAlphaParameter(vreq);
|
||||
int page = IndividualListController.getPageParameter(vreq);
|
||||
Map<String,Object> map = IndividualListController.getResultsForVClass(
|
||||
String alpha = SolrIndividualListController.getAlphaParameter(vreq);
|
||||
int page = SolrIndividualListController.getPageParameter(vreq);
|
||||
Map<String,Object> map = SolrIndividualListController.getResultsForVClass(
|
||||
vclass.getURI(),
|
||||
page,
|
||||
alpha,
|
||||
|
@ -236,6 +236,7 @@ public class SolrJsonServlet extends VitroHttpServlet {
|
|||
rObj.put("totalCount", map.get("totalCount"));
|
||||
rObj.put("alpha", map.get("alpha"));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Individual> inds = (List<Individual>)map.get("entities");
|
||||
|
||||
JSONArray jInds = new JSONArray();
|
||||
|
@ -261,6 +262,7 @@ public class SolrJsonServlet extends VitroHttpServlet {
|
|||
rObj.put("individuals", jInds);
|
||||
|
||||
JSONArray wpages = new JSONArray();
|
||||
@SuppressWarnings("unchecked")
|
||||
List<PageRecord> pages = (List<PageRecord>)map.get("pages");
|
||||
for( PageRecord pr: pages ){
|
||||
JSONObject p = new JSONObject();
|
||||
|
@ -384,6 +386,7 @@ public class SolrJsonServlet extends VitroHttpServlet {
|
|||
HttpSession session = vreq.getSession();
|
||||
if( session == null )
|
||||
throw new ServletException("there is no session to get the pervious results from");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Individual> entsInVClass = (List<Individual>) session.getAttribute(resKey);
|
||||
if( entsInVClass == null )
|
||||
throw new ServletException("Could not find List<Individual> for resultKey " + resKey);
|
||||
|
@ -391,7 +394,6 @@ public class SolrJsonServlet extends VitroHttpServlet {
|
|||
List<Individual> entsToReturn = new ArrayList<Individual>(REPLY_SIZE);
|
||||
boolean more = false;
|
||||
int count = 0;
|
||||
int size = REPLY_SIZE;
|
||||
/* we have a large number of items to send back so we need to stash the list in the session scope */
|
||||
if( entsInVClass.size() > REPLY_SIZE){
|
||||
more = true;
|
||||
|
@ -546,7 +548,7 @@ public class SolrJsonServlet extends VitroHttpServlet {
|
|||
|
||||
private JSONArray individualsToJson(List<Individual> individuals) throws ServletException {
|
||||
JSONArray ja = new JSONArray();
|
||||
Iterator it = individuals.iterator();
|
||||
Iterator<Individual> it = individuals.iterator();
|
||||
try{
|
||||
while(it.hasNext()){
|
||||
Individual ent = (Individual) it.next();
|
||||
|
@ -562,6 +564,4 @@ public class SolrJsonServlet extends VitroHttpServlet {
|
|||
return ja;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ public class HomePageController extends FreemarkerHttpServlet {
|
|||
if(pageData != null)
|
||||
body.putAll(pageData);
|
||||
}
|
||||
body.put("dataServiceUrlVClassesForVClassGroup", UrlBuilder.getUrl("/dataservice?getVClassesForVClassGroup=1&classgroupUri="));
|
||||
|
||||
return new TemplateResponseValues(BODY_TEMPLATE, body);
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ public class PageController extends FreemarkerHttpServlet{
|
|||
if( page.containsKey("title") ){
|
||||
mapForTemplate.put("title", page.get("title"));
|
||||
}
|
||||
mapForTemplate.put("dataServiceUrlIndividualsByVClass", UrlBuilder.getUrl("/dataservice?getSolrIndividualsByVClass=1&vclassId="));
|
||||
} catch (Throwable th) {
|
||||
return doNotFound(vreq);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/css/browseClassGrou
|
|||
<script type="text/javascript">
|
||||
var browseData = {
|
||||
baseUrl: '${urls.base}',
|
||||
dataServiceUrl: '${urls.base}/dataservice?getVClassesForVClassGroup=1&classgroupUri=',
|
||||
dataServiceUrl: '${dataServiceUrlVClassesForVClassGroup}',
|
||||
defaultBrowseClassGroupUri: '${firstPopulatedClassGroup.uri!}',
|
||||
defaultBrowseClassGroupCount: '${firstPopulatedClassGroup.individualCount!}'
|
||||
};
|
||||
|
|
|
@ -15,11 +15,10 @@
|
|||
</#if>
|
||||
</#list>
|
||||
|
||||
<#-- For v1.3: The controller should pass in the dataservice url. -->
|
||||
<script type="text/javascript">
|
||||
var menupageData = {
|
||||
baseUrl: '${urls.base}',
|
||||
dataServiceUrl: '${urls.base}/dataservice?getLuceneIndividualsByVClass=1&vclassId=',
|
||||
dataServiceUrl: '${dataServiceUrlIndividualsByVClass}',
|
||||
defaultBrowseVClassUri: '${firstNonEmptyVClass}'
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Add table
Reference in a new issue