updated from trunk
This commit is contained in:
commit
c24926e72b
21 changed files with 516 additions and 262 deletions
|
@ -44,18 +44,18 @@ public void doGet (HttpServletRequest req, HttpServletResponse res) throws IOExc
|
|||
String url = req.getRequestURI().substring(req.getContextPath().length());
|
||||
ContentType contentType = checkForRequestType(req.getHeader("accept"));
|
||||
|
||||
if(Pattern.compile("^/entityurl/$").matcher(url).matches()){
|
||||
if(Pattern.compile("^/listrdf/$").matcher(url).matches()){
|
||||
String redirectURL = null;
|
||||
if(contentType!=null){
|
||||
if ( RDFXML_MIMETYPE.equals(contentType.getMediaType()))
|
||||
redirectURL = "/entityurl/entityurl.rdf";
|
||||
redirectURL = "/listrdf/listrdf.rdf";
|
||||
else if( N3_MIMETYPE.equals(contentType.getMediaType()))
|
||||
redirectURL = "/entityurl/entityurl.n3";
|
||||
redirectURL = "/listrdf/listrdf.n3";
|
||||
else if ( TTL_MIMETYPE.equals(contentType.getMediaType()))
|
||||
redirectURL = "/entityurl/entityurl.ttl";
|
||||
redirectURL = "/listrdf/listrdf.ttl";
|
||||
}
|
||||
else{
|
||||
redirectURL = "/entityurl/entityrurl.rdf";
|
||||
redirectURL = "/listrdf/listrdf.rdf";
|
||||
}
|
||||
|
||||
String hn = req.getHeader("Host");
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
package edu.cornell.mannlib.vitro.webapp.controller;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.client.solrj.SolrServer;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.common.SolrDocument;
|
||||
import org.apache.solr.common.SolrDocumentList;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
import com.hp.hpl.jena.vocabulary.RDF;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc.VitroLuceneTermNames;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup;
|
||||
|
||||
public class IndividualListRdfController extends VitroHttpServlet {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Log log = LogFactory.getLog(IndividualListRdfController.class.getName());
|
||||
|
||||
public static final int ENTITY_LIST_CONTROLLER_MAX_RESULTS = 30000;
|
||||
|
||||
public void doGet (HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
|
||||
|
||||
// Make the query
|
||||
String classUri = (String) getServletContext().getAttribute("classuri");
|
||||
String queryStr = VitroLuceneTermNames.RDFTYPE + ":\"" + classUri + "\"";
|
||||
SolrQuery query = new SolrQuery(queryStr);
|
||||
query.setStart(0)
|
||||
.setRows(ENTITY_LIST_CONTROLLER_MAX_RESULTS)
|
||||
.setFields(VitroLuceneTermNames.URI);
|
||||
// For now, we're only displaying the url, so no need to sort.
|
||||
//.setSortField(VitroLuceneTermNames.NAME_LOWERCASE_SINGLE_VALUED);
|
||||
|
||||
// Execute the query
|
||||
SolrServer solr = SolrSetup.getSolrServer(getServletContext());
|
||||
QueryResponse response = null;
|
||||
|
||||
try {
|
||||
response = solr.query(query);
|
||||
} catch (Throwable t) {
|
||||
log.error(t, t);
|
||||
}
|
||||
|
||||
if ( response == null ) {
|
||||
throw new ServletException("Could not run search in IndividualListRdfController");
|
||||
}
|
||||
|
||||
SolrDocumentList docs = response.getResults();
|
||||
|
||||
if (docs == null) {
|
||||
throw new ServletException("Could not run search in IndividualListRdfController");
|
||||
}
|
||||
|
||||
Model model = ModelFactory.createDefaultModel();
|
||||
for (SolrDocument doc : docs) {
|
||||
String uri = doc.get(VitroLuceneTermNames.URI).toString();
|
||||
Resource resource = ResourceFactory.createResource(uri);
|
||||
RDFNode node = (RDFNode) ResourceFactory.createResource(classUri);
|
||||
model.add(resource, RDF.type, node);
|
||||
}
|
||||
|
||||
res.setContentType(RDFXML_MIMETYPE);
|
||||
model.write(res.getOutputStream(), "RDF/XML");
|
||||
}
|
||||
|
||||
public void doPost (HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException{
|
||||
doGet(req,res);
|
||||
}
|
||||
|
||||
}
|
|
@ -233,7 +233,7 @@ public class JSONServlet extends VitroHttpServlet {
|
|||
rObj.put("alpha", map.get("alpha"));
|
||||
|
||||
List<Individual> inds = (List<Individual>)map.get("entities");
|
||||
List<IndividualTemplateModel> indsTm = new ArrayList<IndividualTemplateModel>();
|
||||
|
||||
JSONArray jInds = new JSONArray();
|
||||
for(Individual ind : inds ){
|
||||
JSONObject jo = new JSONObject();
|
||||
|
|
|
@ -225,11 +225,14 @@ public class VitroHttpServlet extends HttpServlet {
|
|||
* A child class may call this if logging is set to debug level.
|
||||
*/
|
||||
protected void dumpRequestParameters(HttpServletRequest req) {
|
||||
Log subclassLog = LogFactory.getLog(this.getClass());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, String[]> map = req.getParameterMap();
|
||||
|
||||
for (String key : map.keySet()) {
|
||||
String[] values = map.get(key);
|
||||
log.debug("Parameter '" + key + "' = "
|
||||
subclassLog.debug("Parameter '" + key + "' = "
|
||||
+ Arrays.deepToString(values));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,14 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Res
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* Handle the "Add new account" form display and submission.
|
||||
*
|
||||
* TODO Associate a profile from this account
|
||||
*
|
||||
* TODO Handle sending of email.
|
||||
*
|
||||
* TODO Handle initial password set if email isn't available. Set password
|
||||
* fields, change-required flag, account is active.
|
||||
*/
|
||||
public class UserAccountsAddPage extends UserAccountsPage {
|
||||
private static final String PARAMETER_SUBMIT = "submitAdd";
|
||||
|
@ -145,4 +152,20 @@ public class UserAccountsAddPage extends UserAccountsPage {
|
|||
return new TemplateResponseValues(TEMPLATE_NAME, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public UserAccount getAddedAccount() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new RuntimeException("UserAccountsAddPage.getAddedAccount() not implemented.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public boolean wasPasswordEmailSent() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new RuntimeException("UserAccountsAddPage.wasPasswordEmailSent() not implemented.");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.apache.commons.logging.LogFactory;
|
|||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.ManageUserAccounts;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
|
@ -49,7 +48,13 @@ public class UserAccountsController extends FreemarkerHttpServlet {
|
|||
}
|
||||
|
||||
} else if (ACTION_EDIT.equals(action)) {
|
||||
return new UserAccountsEditPage(vreq).showPage();
|
||||
UserAccountsEditPage page = new UserAccountsEditPage(vreq);
|
||||
page.parseParametersAndValidate();
|
||||
if (page.isSubmit() && page.isValid()) {
|
||||
return editAccountAndShowList(vreq, page);
|
||||
} else {
|
||||
return page.showPage();
|
||||
}
|
||||
|
||||
} else if (ACTION_DELETE.equals(action)) {
|
||||
UserAccountsDeleter deleter = new UserAccountsDeleter(vreq);
|
||||
|
@ -66,10 +71,18 @@ public class UserAccountsController extends FreemarkerHttpServlet {
|
|||
|
||||
private ResponseValues addAccountAndShowList(VitroRequest vreq,
|
||||
UserAccountsAddPage addPage) {
|
||||
UserAccount userAccount = addPage.createNewAccount();
|
||||
addPage.createNewAccount();
|
||||
|
||||
UserAccountsListPage listPage = new UserAccountsListPage(vreq);
|
||||
return listPage.showPageWithNewAccount(userAccount);
|
||||
return listPage.showPageWithNewAccount(addPage.getAddedAccount(),
|
||||
addPage.wasPasswordEmailSent());
|
||||
}
|
||||
|
||||
private ResponseValues editAccountAndShowList(VitroRequest vreq,
|
||||
UserAccountsEditPage editPage) {
|
||||
editPage.updateAccount();
|
||||
UserAccountsListPage listPage = new UserAccountsListPage(vreq);
|
||||
return listPage.showPageWithUpdatedAccount(
|
||||
editPage.getUpdatedAccount(), editPage.wasPasswordEmailSent());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@ import java.util.Collection;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* TODO delete and kick to Accounts list with message, telling how many were
|
||||
* deleted. If there was a problem, the user will need to infer it from the
|
||||
* count??
|
||||
*/
|
||||
public class UserAccountsDeleter extends UserAccountsPage {
|
||||
|
||||
|
@ -16,12 +18,13 @@ public class UserAccountsDeleter extends UserAccountsPage {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
public Collection<String> delete() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new RuntimeException("UserAccountsDeleter.delete() not implemented.");
|
||||
throw new RuntimeException(
|
||||
"UserAccountsDeleter.delete() not implemented.");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,12 +2,23 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller.accounts;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* TODO present the form. Get the submission.
|
||||
*
|
||||
* TODO If email is available, present the reset flag with message templage, and send email
|
||||
*
|
||||
* TODO if email is not available, allow password change with checks for validity
|
||||
*
|
||||
* TODO If successful, go to AccountsList with message and optional password message.
|
||||
*
|
||||
* TODO if unsuccessful, go back to the page, with errors.
|
||||
*
|
||||
* TODO How much of this can be shared with AddPage? Email templates?
|
||||
*/
|
||||
public class UserAccountsEditPage extends UserAccountsPage {
|
||||
private static final String TEMPLATE_NAME = "userAccounts-edit.ftl";
|
||||
|
@ -20,5 +31,53 @@ public class UserAccountsEditPage extends UserAccountsPage {
|
|||
return new TemplateResponseValues(TEMPLATE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public UserAccount updateAccount() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new RuntimeException("UserAccountsEditPage.updateAccount() not implemented.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public boolean wasPasswordEmailSent() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new RuntimeException("UserAccountsEditPage.wasPasswordEmailSent() not implemented.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public UserAccount getUpdatedAccount() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new RuntimeException("UserAccountsEditPage.getUpdatedAccount() not implemented.");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void parseParametersAndValidate() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new RuntimeException("UserAccountsEditPage.parseParametersAndValidate() not implemented.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public boolean isValid() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new RuntimeException("UserAccountsEditPage.isValid() not implemented.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public boolean isSubmit() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new RuntimeException("UserAccountsEditPage.isSubmit() not implemented.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,11 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem
|
|||
|
||||
/**
|
||||
* Handle the List page.
|
||||
*
|
||||
* TODO: agree with Manolo how to do the column heads as links that change the
|
||||
* sort order
|
||||
*
|
||||
* TODO: auto-complete
|
||||
*/
|
||||
public class UserAccountsListPage extends UserAccountsPage {
|
||||
private static final Log log = LogFactory
|
||||
|
@ -87,7 +92,8 @@ public class UserAccountsListPage extends UserAccountsPage {
|
|||
/**
|
||||
* We just came from adding a new account. Show the list with a message.
|
||||
*/
|
||||
public ResponseValues showPageWithNewAccount(UserAccount userAccount) {
|
||||
public ResponseValues showPageWithNewAccount(UserAccount userAccount,
|
||||
boolean emailWasSent) {
|
||||
UserAccountsSelection selection = UserAccountsSelector.select(
|
||||
userAccountsModel, criteria);
|
||||
Map<String, Object> body = buildTemplateBodyMap(selection);
|
||||
|
@ -98,6 +104,15 @@ public class UserAccountsListPage extends UserAccountsPage {
|
|||
return new TemplateResponseValues(TEMPLATE_NAME, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* We just came from editing an account. Show the list with a message.
|
||||
*/
|
||||
public ResponseValues showPageWithUpdatedAccount(UserAccount userAccount,
|
||||
boolean emailWasSent) {
|
||||
throw new RuntimeException(
|
||||
"UserAccountsListPage.showPageWithUpdatedAccount not implemented.");
|
||||
}
|
||||
|
||||
/**
|
||||
* We just came from deleting accounts. Show the list with a message.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller.accounts;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
|
||||
/**
|
||||
* TODO If hash is not valid display bogus message.
|
||||
*
|
||||
* TODO Set the password fields, reset the expire time, set account active, kick
|
||||
* to home page with message. Send confirmation email.
|
||||
*
|
||||
* TODO How do we know "createPassword" from "setPassword"? a parameter? or just by account status?
|
||||
*/
|
||||
public class UserAccountsSetPasswordPage extends UserAccountsPage {
|
||||
|
||||
protected UserAccountsSetPasswordPage(VitroRequest vreq) {
|
||||
super(vreq);
|
||||
}
|
||||
|
||||
}
|
|
@ -21,6 +21,11 @@ import com.hp.hpl.jena.ontology.DatatypeProperty;
|
|||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.ontology.OntProperty;
|
||||
import com.hp.hpl.jena.ontology.OntResource;
|
||||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||
import com.hp.hpl.jena.query.QueryFactory;
|
||||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
|
@ -45,7 +50,10 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
|||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.EditOntology;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
|
||||
import edu.cornell.mannlib.vitro.webapp.servlet.setup.FileGraphSetup;
|
||||
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase;
|
||||
|
||||
public class RefactorOperationController extends BaseEditController {
|
||||
|
||||
|
@ -68,17 +76,7 @@ public class RefactorOperationController extends BaseEditController {
|
|||
OntModel ontModel = (OntModel) getServletContext().getAttribute("baseOntModel");
|
||||
ontModel.enterCriticalSection(Lock.WRITE);
|
||||
ArrayList<String> results = new ArrayList<String>();
|
||||
|
||||
/* Debugging code thats inserts invalid triples into model
|
||||
Property hasTitle = ontModel.getProperty("http://www.owl-ontologies.com/Ontology1209425965.owl#hasTitleee");
|
||||
Resource product = ontModel.createResource("http://www.owl-ontologies.com/Ontology1209425965.owl#someBook14");
|
||||
Resource product2 = ontModel.createResource("http://www.owl-ontologies.com/Ontology1209425965.owl#someBook15");
|
||||
Literal illegalLiteral = ontModel.createTypedLiteral(134);
|
||||
Literal illegalLiteral2 = ontModel.createTypedLiteral(234);
|
||||
ontModel.add(product, hasTitle, illegalLiteral);
|
||||
ontModel.add(product2, hasTitle, illegalLiteral2);
|
||||
*/
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
ExtendedIterator dataProperties = ontModel.listDatatypeProperties();
|
||||
|
@ -180,12 +178,10 @@ public class RefactorOperationController extends BaseEditController {
|
|||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
private String doRenameResource(VitroRequest request, HttpServletResponse response, EditProcessObject epo) {
|
||||
|
||||
String userURI = LoginStatusBean.getBean(request).getUserURI();
|
||||
|
||||
OntModel ontModel = (OntModel) getServletContext().getAttribute("baseOntModel");
|
||||
|
||||
String oldURIStr = (String) epo.getAttribute("oldURI");
|
||||
String newURIStr = request.getParameter("newURI");
|
||||
|
||||
|
@ -213,40 +209,44 @@ public class RefactorOperationController extends BaseEditController {
|
|||
}
|
||||
return "STOP";
|
||||
}
|
||||
|
||||
ontModel.enterCriticalSection(Lock.WRITE);
|
||||
ontModel.getBaseModel().notifyEvent(new EditEvent(userURI,true));
|
||||
try {
|
||||
Property prop = ontModel.getProperty(oldURIStr);
|
||||
if(prop != null)
|
||||
{
|
||||
try {
|
||||
Property newProp = ontModel.createProperty(newURIStr);
|
||||
StmtIterator statements = ontModel.listStatements(null, prop, (RDFNode)null);
|
||||
try {
|
||||
while(statements.hasNext()) {
|
||||
Statement statement = (Statement)statements.next();
|
||||
Resource subj = statement.getSubject();
|
||||
RDFNode obj = statement.getObject();
|
||||
Statement newStatement = ontModel.createStatement(subj, newProp, obj);
|
||||
ontModel.add(newStatement);
|
||||
}
|
||||
} finally {
|
||||
if (statements != null) {
|
||||
statements.close();
|
||||
}
|
||||
}
|
||||
ontModel.remove(ontModel.listStatements(null, prop, (RDFNode)null));
|
||||
} catch (InvalidPropertyURIException ipue) {
|
||||
/* if it can't be a property, don't bother with predicates */
|
||||
}
|
||||
Resource res = ontModel.getResource(oldURIStr);
|
||||
ResourceUtils.renameResource(res,newURIStr);
|
||||
}
|
||||
} finally {
|
||||
ontModel.getBaseModel().notifyEvent(new EditEvent(userURI,false));
|
||||
ontModel.leaveCriticalSection();
|
||||
}
|
||||
|
||||
// find the models that the resource is referred to in and change
|
||||
// the name in each of those models.
|
||||
String queryStr = "SELECT distinct ?graph WHERE {{ GRAPH ?graph { ?subj <" + oldURIStr + "> ?obj }} ";
|
||||
queryStr += " union { GRAPH ?graph { <" + oldURIStr + "> ?prop ?obj }} ";
|
||||
queryStr += " union { GRAPH ?graph { ?subj ?prop <" + oldURIStr + ">}}}";
|
||||
Dataset dataset = request.getDataset();
|
||||
|
||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
ResultSet resultSet = QueryExecutionFactory.create(QueryFactory.create(queryStr), dataset).execSelect();
|
||||
|
||||
while (resultSet.hasNext()) {
|
||||
QuerySolution qs = resultSet.next();
|
||||
String graphURI = qs.get("graph").asNode().toString();
|
||||
|
||||
if (graphURI.startsWith(FileGraphSetup.FILEGRAPH_URI_ROOT)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean doNotify = false;
|
||||
Model model = null;
|
||||
|
||||
if (JenaDataSourceSetupBase.JENA_TBOX_ASSERTIONS_MODEL.equals(graphURI)) {
|
||||
model = ModelContext.getBaseOntModelSelector(getServletContext()).getTBoxModel();
|
||||
doNotify = true;
|
||||
} else if (JenaDataSourceSetupBase.JENA_DB_MODEL.equals(graphURI)) {
|
||||
model = ModelContext.getBaseOntModelSelector(getServletContext()).getABoxModel();
|
||||
doNotify = true;
|
||||
} else {
|
||||
model = dataset.getNamedModel(graphURI);
|
||||
}
|
||||
|
||||
renameResourceInModel(model, userURI, oldURIStr, newURIStr, doNotify);
|
||||
}
|
||||
} finally {
|
||||
dataset.getLock().leaveCriticalSection();
|
||||
}
|
||||
|
||||
// there are no statements to delete, but we want indexes updated appropriately
|
||||
request.getFullWebappDaoFactory().getIndividualDao().deleteIndividual(oldURIStr);
|
||||
|
@ -275,6 +275,50 @@ public class RefactorOperationController extends BaseEditController {
|
|||
|
||||
}
|
||||
|
||||
private void renameResourceInModel(Model model, String userURI, String oldURIStr, String newURIStr, boolean doNotify) {
|
||||
|
||||
model.enterCriticalSection(Lock.WRITE);
|
||||
|
||||
if (doNotify) {
|
||||
model.notifyEvent(new EditEvent(userURI,true));
|
||||
}
|
||||
|
||||
try {
|
||||
Property prop = model.getProperty(oldURIStr); // this will create a resource if there isn't
|
||||
// one by this URI (we don't expect this to happen
|
||||
// and will also return a resource if the given
|
||||
// URI is the URI of a class.
|
||||
try {
|
||||
Property newProp = model.createProperty(newURIStr);
|
||||
StmtIterator statements = model.listStatements(null, prop, (RDFNode)null);
|
||||
try {
|
||||
while(statements.hasNext()) {
|
||||
Statement statement = (Statement)statements.next();
|
||||
Resource subj = statement.getSubject();
|
||||
RDFNode obj = statement.getObject();
|
||||
Statement newStatement = model.createStatement(subj, newProp, obj);
|
||||
model.add(newStatement);
|
||||
}
|
||||
} finally {
|
||||
if (statements != null) {
|
||||
statements.close();
|
||||
}
|
||||
}
|
||||
model.remove(model.listStatements(null, prop, (RDFNode)null));
|
||||
} catch (InvalidPropertyURIException ipue) {
|
||||
/* if it can't be a property, don't bother with predicates */
|
||||
}
|
||||
Resource res = model.getResource(oldURIStr);
|
||||
ResourceUtils.renameResource(res,newURIStr);
|
||||
|
||||
} finally {
|
||||
if (doNotify) {
|
||||
model.notifyEvent(new EditEvent(userURI,false));
|
||||
}
|
||||
model.leaveCriticalSection();
|
||||
}
|
||||
}
|
||||
|
||||
private void doMovePropertyStatements(VitroRequest request, HttpServletResponse response, EditProcessObject epo) {
|
||||
String userURI = LoginStatusBean.getBean(request).getUserURI();
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ public class IndividualListController extends FreemarkerHttpServlet {
|
|||
body.put("subtitle", vclass.getName());
|
||||
}
|
||||
body.put("title", title);
|
||||
body.put("redirecturl", vreq.getContextPath()+"/entityurl/");
|
||||
body.put("rdfUrl", vreq.getContextPath()+"/listrdf/");
|
||||
getServletContext().setAttribute("classuri", vclass.getURI());
|
||||
}
|
||||
|
||||
|
|
|
@ -15,18 +15,12 @@ import javax.servlet.ServletException;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.index.CorruptIndexException;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.PrefixQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.ScoreDoc;
|
||||
import org.apache.lucene.search.Sort;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.TopDocs;
|
||||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.client.solrj.SolrServer;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.common.SolrDocument;
|
||||
import org.apache.solr.common.SolrDocumentList;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
|
@ -36,8 +30,8 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Exc
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneIndexFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc.VitroLuceneTermNames;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividualTemplateModel;
|
||||
import freemarker.ext.beans.BeansWrapper;
|
||||
import freemarker.template.TemplateModel;
|
||||
|
@ -62,7 +56,6 @@ public class SolrIndividualListController extends FreemarkerHttpServlet {
|
|||
String templateName = TEMPLATE_DEFAULT;
|
||||
Map<String, Object> body = new HashMap<String, Object>();
|
||||
String errorMessage = null;
|
||||
String message = null;
|
||||
|
||||
try {
|
||||
Object obj = vreq.getAttribute("vclass");
|
||||
|
@ -78,7 +71,7 @@ public class SolrIndividualListController extends FreemarkerHttpServlet {
|
|||
errorMessage = "Class " + vitroClassIdStr + " not found";
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new HelpException("IndividualListController: request parameter 'vclassId' must be a URI string.");
|
||||
throw new HelpException("IndividualListController: url parameter 'vclassId' must be a URI string.");
|
||||
}
|
||||
}
|
||||
} else if (obj instanceof VClass) {
|
||||
|
@ -101,14 +94,16 @@ public class SolrIndividualListController extends FreemarkerHttpServlet {
|
|||
getServletContext());
|
||||
body.putAll(map);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Individual> inds = (List<Individual>)map.get("entities");
|
||||
List<ListedIndividualTemplateModel> indsTm = new ArrayList<ListedIndividualTemplateModel>();
|
||||
for(Individual ind : inds ){
|
||||
for ( Individual ind : inds ) {
|
||||
indsTm.add(new ListedIndividualTemplateModel(ind,vreq));
|
||||
}
|
||||
body.put("individuals", indsTm);
|
||||
|
||||
List<TemplateModel> wpages = new ArrayList<TemplateModel>();
|
||||
@SuppressWarnings("unchecked")
|
||||
List<PageRecord> pages = (List<PageRecord>)body.get("pages");
|
||||
BeansWrapper wrapper = new BeansWrapper();
|
||||
for( PageRecord pr: pages ){
|
||||
|
@ -125,10 +120,10 @@ public class SolrIndividualListController extends FreemarkerHttpServlet {
|
|||
body.put("subtitle", vclass.getName());
|
||||
}
|
||||
body.put("title", title);
|
||||
body.put("redirecturl", vreq.getContextPath()+"/entityurl/");
|
||||
body.put("rdfUrl", vreq.getContextPath() + "/listrdf/" + vclass.getLocalName() + ".rdf");
|
||||
getServletContext().setAttribute("classuri", vclass.getURI());
|
||||
}
|
||||
|
||||
|
||||
} catch (HelpException help){
|
||||
errorMessage = "Request attribute 'vclass' or request parameter 'vclassId' must be set before calling. Its value must be a class uri.";
|
||||
} catch (Throwable e) {
|
||||
|
@ -138,10 +133,8 @@ public class SolrIndividualListController extends FreemarkerHttpServlet {
|
|||
if (errorMessage != null) {
|
||||
templateName = Template.ERROR_MESSAGE.toString();
|
||||
body.put("errorMessage", errorMessage);
|
||||
} else if (message != null) {
|
||||
body.put("message", message);
|
||||
}
|
||||
|
||||
|
||||
return new TemplateResponseValues(templateName, body);
|
||||
}
|
||||
|
||||
|
@ -175,163 +168,148 @@ public class SolrIndividualListController extends FreemarkerHttpServlet {
|
|||
* This method is now called in a couple of places. It should be refactored
|
||||
* into a DAO or similar object.
|
||||
*/
|
||||
public static Map<String,Object> getResultsForVClass(String vclassURI, int page, String alpha, IndividualDao indDao, ServletContext context)
|
||||
throws CorruptIndexException, IOException, ServletException{
|
||||
Map<String,Object> rvMap = new HashMap<String,Object>();
|
||||
|
||||
//make lucene query for this rdf:type
|
||||
Query query = getQuery(vclassURI, alpha);
|
||||
|
||||
//execute lucene query for individuals of the specified type
|
||||
IndexSearcher index = LuceneIndexFactory.getIndexSearcher(context);
|
||||
TopDocs docs = null;
|
||||
try{
|
||||
docs = index.search(query, null,
|
||||
ENTITY_LIST_CONTROLLER_MAX_RESULTS,
|
||||
new Sort(Entity2LuceneDoc.term.NAME_LOWERCASE));
|
||||
}catch(Throwable th){
|
||||
log.error("Could not run search. " + th.getMessage());
|
||||
docs = null;
|
||||
}
|
||||
|
||||
if( docs == null )
|
||||
throw new ServletException("Could not run search in IndividualListController");
|
||||
|
||||
//get list of individuals for the search results
|
||||
int size = docs.totalHits;
|
||||
log.debug("Number of search results: " + size);
|
||||
|
||||
// don't get all the results, only get results for the requestedSize
|
||||
List<Individual> individuals = new ArrayList<Individual>(INDIVIDUALS_PER_PAGE);
|
||||
int individualsAdded = 0;
|
||||
int ii = (page-1)*INDIVIDUALS_PER_PAGE;
|
||||
while( individualsAdded < INDIVIDUALS_PER_PAGE && ii < size ){
|
||||
ScoreDoc hit = docs.scoreDocs[ii];
|
||||
if (hit != null) {
|
||||
Document doc = index.doc(hit.doc);
|
||||
if (doc != null) {
|
||||
String uri = doc.getField(Entity2LuceneDoc.term.URI).stringValue();
|
||||
Individual ind = indDao.getIndividualByURI( uri );
|
||||
if( ind != null ){
|
||||
individuals.add( ind );
|
||||
individualsAdded++;
|
||||
}
|
||||
} else {
|
||||
log.warn("no document found for lucene doc id " + hit.doc);
|
||||
}
|
||||
} else {
|
||||
log.debug("hit was null");
|
||||
}
|
||||
ii++;
|
||||
}
|
||||
|
||||
rvMap.put("count", size);
|
||||
|
||||
if( size > INDIVIDUALS_PER_PAGE ){
|
||||
rvMap.put("showPages", Boolean.TRUE);
|
||||
List<PageRecord> pageRecords = makePagesList(size, INDIVIDUALS_PER_PAGE, page);
|
||||
rvMap.put("pages", pageRecords);
|
||||
}else{
|
||||
rvMap.put("showPages", Boolean.FALSE);
|
||||
rvMap.put("pages", Collections.emptyList());
|
||||
}
|
||||
|
||||
rvMap.put("alpha",alpha);
|
||||
|
||||
rvMap.put("totalCount", size);
|
||||
rvMap.put("entities",individuals);
|
||||
if (individuals == null)
|
||||
log.debug("entities list is null for vclass " + vclassURI );
|
||||
|
||||
return rvMap;
|
||||
}
|
||||
|
||||
private static BooleanQuery getQuery(String vclassUri, String alpha){
|
||||
BooleanQuery query = new BooleanQuery();
|
||||
try{
|
||||
//query term for rdf:type
|
||||
query.add(
|
||||
new TermQuery( new Term(Entity2LuceneDoc.term.RDFTYPE, vclassUri)),
|
||||
BooleanClause.Occur.MUST );
|
||||
|
||||
//Add alpha filter if it is needed
|
||||
Query alphaQuery = null;
|
||||
if( alpha != null && !"".equals(alpha) && alpha.length() == 1){
|
||||
alphaQuery =
|
||||
new PrefixQuery(new Term(Entity2LuceneDoc.term.NAME_LOWERCASE, alpha.toLowerCase()));
|
||||
query.add(alphaQuery,BooleanClause.Occur.MUST);
|
||||
}
|
||||
|
||||
log.debug("Query: " + query);
|
||||
return query;
|
||||
} catch (Exception ex){
|
||||
log.error(ex,ex);
|
||||
return new BooleanQuery();
|
||||
}
|
||||
}
|
||||
public static Map<String,Object> getResultsForVClass(String vclassURI, int page, String alpha, IndividualDao indDao, ServletContext context)
|
||||
throws CorruptIndexException, IOException, ServletException {
|
||||
Map<String,Object> rvMap = new HashMap<String,Object>();
|
||||
|
||||
public static List<PageRecord> makePagesList( int count, int pageSize, int selectedPage){
|
||||
// Make solr query for this rdf:type
|
||||
SolrQuery query = getQuery(vclassURI, alpha, page);
|
||||
SolrServer solr = SolrSetup.getSolrServer(context);
|
||||
QueryResponse response = null;
|
||||
|
||||
// Execute query for individuals of the specified type
|
||||
try {
|
||||
response = solr.query(query);
|
||||
} catch (Throwable t) {
|
||||
log.error(t, t);
|
||||
}
|
||||
|
||||
if ( response == null ) {
|
||||
throw new ServletException("Could not run search in IndividualListController");
|
||||
}
|
||||
|
||||
SolrDocumentList docs = response.getResults();
|
||||
|
||||
if (docs == null) {
|
||||
throw new ServletException("Could not run search in IndividualListController");
|
||||
}
|
||||
|
||||
// get list of individuals for the search results
|
||||
long size = docs.getNumFound();
|
||||
log.debug("Number of search results: " + size);
|
||||
|
||||
List<Individual> individuals = new ArrayList<Individual>();
|
||||
for (SolrDocument doc : docs) {
|
||||
String uri = doc.get(VitroLuceneTermNames.URI).toString();
|
||||
Individual individual = indDao.getIndividualByURI( uri );
|
||||
if (individual != null) {
|
||||
individuals.add(individual);
|
||||
}
|
||||
}
|
||||
|
||||
rvMap.put("count", size);
|
||||
|
||||
List<PageRecord> records = new ArrayList<PageRecord>( MAX_PAGES + 1 );
|
||||
int requiredPages = count/pageSize ;
|
||||
int remainder = count % pageSize ;
|
||||
if( remainder > 0 )
|
||||
requiredPages++;
|
||||
if( size > INDIVIDUALS_PER_PAGE ){
|
||||
rvMap.put("showPages", Boolean.TRUE);
|
||||
List<PageRecord> pageRecords = makePagesList(size, INDIVIDUALS_PER_PAGE, page);
|
||||
rvMap.put("pages", pageRecords);
|
||||
}else{
|
||||
rvMap.put("showPages", Boolean.FALSE);
|
||||
rvMap.put("pages", Collections.emptyList());
|
||||
}
|
||||
|
||||
rvMap.put("alpha",alpha);
|
||||
|
||||
rvMap.put("totalCount", size);
|
||||
rvMap.put("entities",individuals);
|
||||
|
||||
if (individuals.isEmpty())
|
||||
log.debug("entities list is empty for vclass " + vclassURI );
|
||||
|
||||
if( selectedPage < MAX_PAGES && requiredPages > MAX_PAGES ){
|
||||
//the selected pages is within the first maxPages, just show the normal pages up to maxPages.
|
||||
for(int page = 1; page < requiredPages && page <= MAX_PAGES ; page++ ){
|
||||
records.add( new PageRecord( "page=" + page, Integer.toString(page), Integer.toString(page), selectedPage == page ) );
|
||||
}
|
||||
records.add( new PageRecord( "page="+ (MAX_PAGES+1), Integer.toString(MAX_PAGES+1), "more...", false));
|
||||
}else if( requiredPages > MAX_PAGES && selectedPage+1 > MAX_PAGES && selectedPage < requiredPages - MAX_PAGES){
|
||||
//the selected pages is in the middle of the list of page
|
||||
int startPage = selectedPage - MAX_PAGES / 2;
|
||||
int endPage = selectedPage + MAX_PAGES / 2;
|
||||
for(int page = startPage; page <= endPage ; page++ ){
|
||||
records.add( new PageRecord( "page=" + page, Integer.toString(page), Integer.toString(page), selectedPage == page ) );
|
||||
}
|
||||
records.add( new PageRecord( "page="+ endPage+1, Integer.toString(endPage+1), "more...", false));
|
||||
}else if ( requiredPages > MAX_PAGES && selectedPage > requiredPages - MAX_PAGES ){
|
||||
//the selected page is in the end of the list
|
||||
int startPage = requiredPages - MAX_PAGES;
|
||||
double max = Math.ceil(count/pageSize);
|
||||
for(int page = startPage; page <= max; page++ ){
|
||||
records.add( new PageRecord( "page=" + page, Integer.toString(page), Integer.toString(page), selectedPage == page ) );
|
||||
}
|
||||
}else{
|
||||
//there are fewer than maxPages pages.
|
||||
for(int i = 1; i <= requiredPages; i++ ){
|
||||
records.add( new PageRecord( "page=" + i, Integer.toString(i), Integer.toString(i), selectedPage == i ) );
|
||||
return rvMap;
|
||||
}
|
||||
|
||||
private static SolrQuery getQuery(String vclassUri, String alpha, int page){
|
||||
|
||||
String queryStr = VitroLuceneTermNames.RDFTYPE + ":\"" + vclassUri + "\"";
|
||||
|
||||
// Add alpha filter if it is needed
|
||||
if ( alpha != null && !"".equals(alpha) && alpha.length() == 1) {
|
||||
queryStr += VitroLuceneTermNames.NAME_LOWERCASE + ":" + alpha.toLowerCase() + "*";
|
||||
}
|
||||
|
||||
SolrQuery query = new SolrQuery(queryStr);
|
||||
|
||||
int start = (page-1)*INDIVIDUALS_PER_PAGE;
|
||||
query.setStart(start)
|
||||
.setRows(INDIVIDUALS_PER_PAGE)
|
||||
.setSortField(VitroLuceneTermNames.NAME_LOWERCASE_SINGLE_VALUED, SolrQuery.ORDER.asc);
|
||||
|
||||
log.debug("Query: " + query);
|
||||
return query;
|
||||
}
|
||||
|
||||
public static List<PageRecord> makePagesList( long size, int pageSize, int selectedPage ) {
|
||||
|
||||
List<PageRecord> records = new ArrayList<PageRecord>( MAX_PAGES + 1 );
|
||||
int requiredPages = (int) (size/pageSize) ;
|
||||
int remainder = (int) (size % pageSize) ;
|
||||
if( remainder > 0 )
|
||||
requiredPages++;
|
||||
|
||||
if( selectedPage < MAX_PAGES && requiredPages > MAX_PAGES ){
|
||||
//the selected pages is within the first maxPages, just show the normal pages up to maxPages.
|
||||
for(int page = 1; page < requiredPages && page <= MAX_PAGES ; page++ ){
|
||||
records.add( new PageRecord( "page=" + page, Integer.toString(page), Integer.toString(page), selectedPage == page ) );
|
||||
}
|
||||
records.add( new PageRecord( "page="+ (MAX_PAGES+1), Integer.toString(MAX_PAGES+1), "more...", false));
|
||||
}else if( requiredPages > MAX_PAGES && selectedPage+1 > MAX_PAGES && selectedPage < requiredPages - MAX_PAGES){
|
||||
//the selected pages is in the middle of the list of page
|
||||
int startPage = selectedPage - MAX_PAGES / 2;
|
||||
int endPage = selectedPage + MAX_PAGES / 2;
|
||||
for(int page = startPage; page <= endPage ; page++ ){
|
||||
records.add( new PageRecord( "page=" + page, Integer.toString(page), Integer.toString(page), selectedPage == page ) );
|
||||
}
|
||||
records.add( new PageRecord( "page="+ endPage+1, Integer.toString(endPage+1), "more...", false));
|
||||
}else if ( requiredPages > MAX_PAGES && selectedPage > requiredPages - MAX_PAGES ){
|
||||
//the selected page is in the end of the list
|
||||
int startPage = requiredPages - MAX_PAGES;
|
||||
double max = Math.ceil(size/pageSize);
|
||||
for(int page = startPage; page <= max; page++ ){
|
||||
records.add( new PageRecord( "page=" + page, Integer.toString(page), Integer.toString(page), selectedPage == page ) );
|
||||
}
|
||||
}else{
|
||||
//there are fewer than maxPages pages.
|
||||
for(int i = 1; i <= requiredPages; i++ ){
|
||||
records.add( new PageRecord( "page=" + i, Integer.toString(i), Integer.toString(i), selectedPage == i ) );
|
||||
}
|
||||
}
|
||||
return records;
|
||||
}
|
||||
|
||||
public static class PageRecord {
|
||||
public PageRecord(String param, String index, String text, boolean selected) {
|
||||
this.param = param;
|
||||
this.index = index;
|
||||
this.text = text;
|
||||
this.selected = selected;
|
||||
}
|
||||
public String param;
|
||||
public String index;
|
||||
public String text;
|
||||
public boolean selected=false;
|
||||
|
||||
public String getParam() {
|
||||
return param;
|
||||
}
|
||||
public String getIndex() {
|
||||
return index;
|
||||
}
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
public boolean getSelected(){
|
||||
return selected;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return records;
|
||||
}
|
||||
|
||||
public static class PageRecord {
|
||||
public PageRecord(String param, String index, String text, boolean selected) {
|
||||
this.param = param;
|
||||
this.index = index;
|
||||
this.text = text;
|
||||
this.selected = selected;
|
||||
}
|
||||
public String param;
|
||||
public String index;
|
||||
public String text;
|
||||
public boolean selected=false;
|
||||
|
||||
public String getParam() {
|
||||
return param;
|
||||
}
|
||||
public String getIndex() {
|
||||
return index;
|
||||
}
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
public boolean getSelected(){
|
||||
return selected;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,6 @@ public class SolrAutocompleteController extends VitroAjaxController {
|
|||
}
|
||||
}
|
||||
|
||||
// Since SolrQuery.setSortField() is buggy, sort the results here
|
||||
Collections.sort(results);
|
||||
|
||||
// map.put("results", results);
|
||||
|
@ -157,8 +156,9 @@ public class SolrAutocompleteController extends VitroAjaxController {
|
|||
}
|
||||
|
||||
query.setFields(VitroLuceneTermNames.NAME_RAW, VitroLuceneTermNames.URI); // fields to retrieve
|
||||
// Solr bug: generates sort=nameLowercase asc instead of sort=nameLowercase+asc
|
||||
//.setSortField(VitroLuceneTermNames.NAME_LOWERCASE, SolrQuery.ORDER.asc);
|
||||
|
||||
// Can't sort on multivalued field, so sort results in Java when we get them
|
||||
// query.setSortField(VitroLuceneTermNames.NAME_LOWERCASE, SolrQuery.ORDER.asc);
|
||||
|
||||
return query;
|
||||
}
|
||||
|
@ -187,6 +187,7 @@ public class SolrAutocompleteController extends VitroAjaxController {
|
|||
// RY 5/18/2011 For now, just doing untokenized query, due to the interactions of wildcard
|
||||
// query and stemming described below. Need to find a way to do this in Solr.
|
||||
// Should take the same approach if we can figure out how to do a disjunction.
|
||||
// Probably just add an explicit "OR" between the terms.
|
||||
|
||||
// String stemParam = (String) request.getParameter("stem");
|
||||
// boolean stem = "true".equals(stemParam);
|
||||
|
|
|
@ -174,11 +174,7 @@ public class SolrPagedSearchController extends FreemarkerHttpServlet {
|
|||
|
||||
log.debug("Query text is \""+ qtxt + "\"");
|
||||
|
||||
SolrQuery query = getQuery(qtxt, maxHitCount, vreq);
|
||||
|
||||
// ** For xml requested, add version=2.2 for xml version
|
||||
// is that enough, or do we also have to add wt param?
|
||||
|
||||
SolrQuery query = getQuery(qtxt, maxHitCount, vreq);
|
||||
SolrServer solr = SolrSetup.getSolrServer(getServletContext());
|
||||
QueryResponse response = null;
|
||||
|
||||
|
|
|
@ -86,6 +86,10 @@ public class Entity2LuceneDoc implements Obj2DocIface{
|
|||
/** rdfs:label lowercased, no tokenizing, no stop words, no stemming **/
|
||||
public static String NAME_LOWERCASE = "nameLowercase"; // was NAMELOWERCASE
|
||||
|
||||
/** Same as NAME_LOWERCASE, but single-valued so it's sortable. **/
|
||||
// RY Need to control how indexing selects which of multiple values to copy.
|
||||
public static String NAME_LOWERCASE_SINGLE_VALUED = "nameLowercaseSingleValued";
|
||||
|
||||
/** rdfs:label lowercased, tokenized, stop words, no stemming.
|
||||
* Used for autocomplete matching on proper names. **/
|
||||
public static String AC_NAME_UNSTEMMED = "acNameUnstemmed"; // was NAMEUNSTEMMED
|
||||
|
|
|
@ -32,10 +32,10 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelectorImpl;
|
|||
|
||||
public class FileGraphSetup implements ServletContextListener {
|
||||
|
||||
private static String ABOX = "abox";
|
||||
private static String TBOX = "tbox";
|
||||
private static String PATH_ROOT = "/WEB-INF/filegraph/";
|
||||
private static String URI_ROOT = "http://vitro.mannlib.cornell.edu/filegraph/";
|
||||
private static final String ABOX = "abox";
|
||||
private static final String TBOX = "tbox";
|
||||
private static final String PATH_ROOT = "/WEB-INF/filegraph/";
|
||||
public static final String FILEGRAPH_URI_ROOT = "http://vitro.mannlib.cornell.edu/filegraph/";
|
||||
|
||||
private static final Log log = LogFactory.getLog(FileGraphSetup.class);
|
||||
|
||||
|
@ -189,7 +189,7 @@ public class FileGraphSetup implements ServletContextListener {
|
|||
*/
|
||||
public void cleanupDB(Store kbStore, Set<String> uriSet, String type) {
|
||||
|
||||
Pattern graphURIPat = Pattern.compile("^" + URI_ROOT + type);
|
||||
Pattern graphURIPat = Pattern.compile("^" + FILEGRAPH_URI_ROOT + type);
|
||||
|
||||
Iterator<Node> iter = StoreUtils.storeGraphNames(kbStore);
|
||||
|
||||
|
@ -237,7 +237,7 @@ public class FileGraphSetup implements ServletContextListener {
|
|||
|
||||
if (path != null) {
|
||||
File file = new File(path);
|
||||
uri = URI_ROOT + type + "/" + file.getName();
|
||||
uri = FILEGRAPH_URI_ROOT + type + "/" + file.getName();
|
||||
}
|
||||
|
||||
return uri;
|
||||
|
|
|
@ -80,6 +80,7 @@ public class JenaDataSourceSetupSDB extends JenaDataSourceSetupBase implements j
|
|||
|
||||
//memModel.writeAll(System.out,"N3",null);
|
||||
|
||||
/* commenting out during development of 1.3 - this will be redone.
|
||||
if ( updateRequired(ctx, memModel)) {
|
||||
log.error(getMigrationErrString());
|
||||
System.out.println(getMigrationErrString());
|
||||
|
@ -88,6 +89,7 @@ public class JenaDataSourceSetupSDB extends JenaDataSourceSetupBase implements j
|
|||
AbortStartup.abortStartup(ctx);
|
||||
throw new MigrationRequiredError(getMigrationErrString());
|
||||
}
|
||||
*/
|
||||
|
||||
if (memModel == null) {
|
||||
memModel = ModelFactory.createOntologyModel(MEM_ONT_MODEL_SPEC);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue