[VIVO-1400] Add the capability to use / parse out precise-subquery tags.
This commit is contained in:
parent
107c2bff03
commit
792ca4138f
13 changed files with 78 additions and 7 deletions
|
@ -254,6 +254,8 @@ public interface RDFService {
|
|||
|
||||
public Model getTriples(RDFNode subject, RDFNode predicate, RDFNode object, long limit, long offset) throws RDFServiceException;
|
||||
|
||||
public boolean preferPreciseOptionals();
|
||||
|
||||
/**
|
||||
* Frees any resources held by this RDFService object
|
||||
*
|
||||
|
|
|
@ -470,6 +470,11 @@ public class LanguageFilteringRDFService implements RDFService {
|
|||
return s.getTriples(subject, predicate, object, limit, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preferPreciseOptionals() {
|
||||
return s.preferPreciseOptionals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
s.close();
|
||||
|
|
|
@ -306,6 +306,11 @@ public class SameAsFilteringRDFServiceFactory implements RDFServiceFactory {
|
|||
return s.isEquivalentGraph(graphURI, graph);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preferPreciseOptionals() {
|
||||
return s.preferPreciseOptionals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
s.close();
|
||||
|
|
|
@ -203,6 +203,11 @@ public class RDFServiceFactorySingle implements RDFServiceFactory {
|
|||
return s.getTriples(subject, predicate, object, limit, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preferPreciseOptionals() {
|
||||
return s.preferPreciseOptionals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// Don't close s. It's being used by everybody.
|
||||
|
|
|
@ -692,6 +692,10 @@ public abstract class RDFServiceJena extends RDFServiceImpl implements RDFServic
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preferPreciseOptionals() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
|
|
|
@ -273,6 +273,11 @@ public class RDFServiceSDB extends RDFServiceJena implements RDFService {
|
|||
return super.getTriples(subject, predicate, object, limit, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preferPreciseOptionals() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (conn != null) {
|
||||
|
|
|
@ -193,6 +193,11 @@ public class LoggingRDFService implements RDFService {
|
|||
return innerService.getTriples(subject, predicate, object, limit, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preferPreciseOptionals() {
|
||||
return innerService.preferPreciseOptionals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
innerService.close();
|
||||
|
|
|
@ -909,6 +909,11 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService {
|
|||
return graph.isIsomorphicWith(fromTripleStoreModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preferPreciseOptionals() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected HttpContext getContext(HttpRequestBase request) {
|
||||
UsernamePasswordCredentials credentials = getCredentials();
|
||||
if (credentials != null) {
|
||||
|
|
|
@ -20,6 +20,8 @@ import javax.xml.transform.TransformerFactory;
|
|||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.Document;
|
||||
|
@ -56,6 +58,7 @@ public class CustomListViewConfigFile {
|
|||
private static final String TAG_POSTPROCESSOR = "postprocessor";
|
||||
private static final String TAG_COLLATED = "collated";
|
||||
private static final String TAG_CRITICAL = "critical-data-required";
|
||||
private static final String TAG_PRECISE = "precise-subquery";
|
||||
|
||||
// Will not be null. This is mutable, but don't modify it. Clone it and
|
||||
// modify the clone.
|
||||
|
@ -198,7 +201,7 @@ public class CustomListViewConfigFile {
|
|||
}
|
||||
}
|
||||
|
||||
public String getSelectQuery(boolean collated, boolean editing) {
|
||||
public String getSelectQuery(boolean collated, boolean editing, boolean usePreciseSubquery) {
|
||||
Element cloned = (Element) selectQueryElement.cloneNode(true);
|
||||
|
||||
if (!collated) {
|
||||
|
@ -207,6 +210,9 @@ public class CustomListViewConfigFile {
|
|||
if (editing) {
|
||||
removeChildElements(cloned, TAG_CRITICAL);
|
||||
}
|
||||
if (!usePreciseSubquery) {
|
||||
removeChildElements(cloned, TAG_PRECISE);
|
||||
}
|
||||
|
||||
return cloned.getTextContent();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.io.FileReader;
|
|||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -45,7 +46,6 @@ public class DataPropertyListConfig {
|
|||
public DataPropertyListConfig(DataPropertyTemplateModel dptm, TemplateLoader templateLoader, VitroRequest vreq,
|
||||
DataProperty dp, boolean editing)
|
||||
throws InvalidConfigurationException {
|
||||
|
||||
this.dptm = dptm;
|
||||
this.vreq = vreq;
|
||||
WebappDaoFactory wadf = vreq.getWebappDaoFactory();
|
||||
|
@ -125,7 +125,7 @@ public class DataPropertyListConfig {
|
|||
FileReader reader = new FileReader(configFilePath);
|
||||
CustomListViewConfigFile configFileContents = new CustomListViewConfigFile(reader);
|
||||
|
||||
selectQuery = configFileContents.getSelectQuery(false, editing);
|
||||
selectQuery = configFileContents.getSelectQuery(false, editing, ListConfigUtils.getUsePreciseSubquery(vreq));
|
||||
templateName = configFileContents.getTemplateName();
|
||||
constructQueries = configFileContents.getConstructQueries();
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.customlistview;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.sdb.RDFServiceSDB;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public final class ListConfigUtils {
|
||||
private static Boolean usePrecise = null;
|
||||
|
||||
public static final boolean getUsePreciseSubquery(VitroRequest vreq) {
|
||||
if (usePrecise == null) {
|
||||
String usePreciseProp = ConfigurationProperties.getBean(vreq).getProperty("listview.usePreciseSubquery");
|
||||
if (!StringUtils.isEmpty(usePreciseProp)) {
|
||||
usePrecise = Boolean.parseBoolean(usePreciseProp);
|
||||
} else if (vreq != null && vreq.getRDFService() != null) {
|
||||
usePrecise = vreq.getRDFService().preferPreciseOptionals();
|
||||
} else {
|
||||
usePrecise = false;
|
||||
}
|
||||
}
|
||||
|
||||
return usePrecise;
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import java.io.IOException;
|
|||
import java.lang.reflect.Constructor;
|
||||
import java.util.Set;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -140,7 +141,7 @@ public class PropertyListConfig {
|
|||
|
||||
boolean collated = optm instanceof CollatedObjectPropertyTemplateModel;
|
||||
|
||||
selectQuery = configFileContents.getSelectQuery(collated, editing);
|
||||
selectQuery = configFileContents.getSelectQuery(collated, editing, ListConfigUtils.getUsePreciseSubquery(vreq));
|
||||
templateName = configFileContents.getTemplateName();
|
||||
constructQueries = configFileContents.getConstructQueries();
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ public class CustomListViewConfigFileTest extends AbstractTestClass {
|
|||
String selectQuery, String[] constructQueries, String templateName,
|
||||
String postprocessorName) {
|
||||
assertEquals("select query", selectQuery,
|
||||
configFile.getSelectQuery(collated, editing));
|
||||
configFile.getSelectQuery(collated, editing, true));
|
||||
assertEquals("construct queries",
|
||||
new HashSet<String>(Arrays.asList(constructQueries)),
|
||||
configFile.getConstructQueries());
|
||||
|
|
Loading…
Add table
Reference in a new issue