Merge branch 'develop' into feature/fauxEditing

This commit is contained in:
Jim Blake 2014-10-30 15:55:16 -04:00
commit f4b3728822
3 changed files with 25 additions and 31 deletions

View file

@ -8,9 +8,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.jena.atlas.lib.Pair; import edu.cornell.mannlib.vitro.webapp.dao.PropertyDao.FullPropertyKey;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
public class WebappDaoFactoryConfig { public class WebappDaoFactoryConfig {
@ -18,7 +16,7 @@ public class WebappDaoFactoryConfig {
private String defaultNamespace; private String defaultNamespace;
private Set<String> nonUserNamespaces; private Set<String> nonUserNamespaces;
private boolean isUnderlyingStoreReasoned = false; private boolean isUnderlyingStoreReasoned = false;
public Map<Pair<String,Pair<ObjectProperty, String>>, String> customListViewConfigFileMap; public Map<FullPropertyKey, String> customListViewConfigFileMap;
public WebappDaoFactoryConfig() { public WebappDaoFactoryConfig() {
preferredLanguages = Arrays.asList("en-US", "en", "EN"); preferredLanguages = Arrays.asList("en-US", "en", "EN");
@ -59,12 +57,12 @@ public class WebappDaoFactoryConfig {
return this.isUnderlyingStoreReasoned; return this.isUnderlyingStoreReasoned;
} }
public Map<Pair<String,Pair<ObjectProperty, String>>, String> getCustomListViewConfigFileMap() { public Map<FullPropertyKey, String> getCustomListViewConfigFileMap() {
return this.getCustomListViewConfigFileMap(); return this.getCustomListViewConfigFileMap();
} }
public void setCustomListViewConfigFileMap( public void setCustomListViewConfigFileMap(
Map<Pair<String,Pair<ObjectProperty, String>>, String> map) { Map<FullPropertyKey, String> map) {
this.customListViewConfigFileMap = map; this.customListViewConfigFileMap = map;
} }

View file

@ -13,7 +13,6 @@ import java.util.Map;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.jena.atlas.lib.Pair;
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
import com.hp.hpl.jena.ontology.ConversionException; import com.hp.hpl.jena.ontology.ConversionException;
@ -58,8 +57,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
public ObjectPropertyDaoJena(RDFService rdfService, public ObjectPropertyDaoJena(RDFService rdfService,
DatasetWrapperFactory dwf, DatasetWrapperFactory dwf,
Map<Pair<String,Pair<ObjectProperty, String>>, String> Map<FullPropertyKey, String> customListViewConfigFileMap,
customListViewConfigFileMap,
WebappDaoFactoryJena wadf) { WebappDaoFactoryJena wadf) {
super(rdfService, dwf, wadf); super(rdfService, dwf, wadf);
this.customListViewConfigFileMap = customListViewConfigFileMap; this.customListViewConfigFileMap = customListViewConfigFileMap;
@ -1090,12 +1088,12 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
// Map key is inner pair of object property and range class URI, // Map key is inner pair of object property and range class URI,
// with first member of outer pair being a domain class URI. // with first member of outer pair being a domain class URI.
// If domain or range is unspecified, OWL.Thing.getURI() is used in the key. // If domain or range is unspecified, OWL.Thing.getURI() is used in the key.
Map<Pair<String,Pair<ObjectProperty, String>>, String> customListViewConfigFileMap; Map<FullPropertyKey, String> customListViewConfigFileMap;
@Override @Override
public String getCustomListViewConfigFileName(ObjectProperty op) { public String getCustomListViewConfigFileName(ObjectProperty op) {
if (customListViewConfigFileMap == null) { if (customListViewConfigFileMap == null) {
customListViewConfigFileMap = new HashMap<Pair<String,Pair<ObjectProperty, String>>, String>(); customListViewConfigFileMap = new HashMap<>();
} }
if (customListViewConfigFileMap.isEmpty()) { if (customListViewConfigFileMap.isEmpty()) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
@ -1125,33 +1123,31 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
} }
} else { } else {
String filename = soln.getLiteral("filename").getLexicalForm(); String filename = soln.getLiteral("filename").getLexicalForm();
log.debug("putting " + domainUri + " " + prop.getURI() + " " + rangeUri + " " + filename + " into list view map"); FullPropertyKey key = new FullPropertyKey(domainUri, prop.getURI(), rangeUri);
customListViewConfigFileMap.put( log.debug("putting " + key + " " + filename + " into list view map");
new Pair<String,Pair<ObjectProperty,String>>( customListViewConfigFileMap.put(key, filename);
domainUri, new Pair<ObjectProperty, String>(
prop, rangeUri)), filename);
} }
} }
// If there are no custom list views, put a bogus entry in the map // If there are no custom list views, put a bogus entry in the map
// to avoid further recomputation // to avoid further recomputation
if (customListViewConfigFileMap.isEmpty()) { if (customListViewConfigFileMap.isEmpty()) {
ObjectProperty bottom = new ObjectProperty();
bottom.setURI(OWL.NS + "bottomObjectProperty");
customListViewConfigFileMap.put( customListViewConfigFileMap.put(
new Pair<String,Pair<ObjectProperty,String>>( new FullPropertyKey(null, OWL.NS + "bottomObjectProperty", null),
null, new Pair<ObjectProperty, String>( "nothing");
bottom, null)), "nothing");
} }
qexec.close(); qexec.close();
} }
String customListViewConfigFileName = customListViewConfigFileMap.get(new Pair<String, Pair<ObjectProperty, String>>(op.getDomainVClassURI(), new Pair<ObjectProperty,String>(op, op.getRangeVClassURI()))); FullPropertyKey key = new FullPropertyKey(op);
String customListViewConfigFileName = customListViewConfigFileMap.get(key);
if (customListViewConfigFileName == null) { if (customListViewConfigFileName == null) {
log.debug("no list view found for " + op.getURI() + " qualified by range " + op.getRangeVClassURI() + " and domain " + op.getDomainVClassURI()); log.debug("no list view found for " + key);
customListViewConfigFileName = customListViewConfigFileMap.get(new Pair<String, Pair<ObjectProperty, String>>(OWL.Thing.getURI(), new Pair<ObjectProperty,String>(op, op.getRangeVClassURI()))); key = new FullPropertyKey(null, op.getURI(), op.getRangeVClassURI());
customListViewConfigFileName = customListViewConfigFileMap.get(key);
} }
if (customListViewConfigFileName == null) { if (customListViewConfigFileName == null) {
log.debug("no list view found for " + op.getURI() + " qualified by range " + op.getRangeVClassURI()); log.debug("no list view found for " + key);
customListViewConfigFileName = customListViewConfigFileMap.get(new Pair<String, Pair<ObjectProperty, String>>(OWL.Thing.getURI(), new Pair<ObjectProperty,String>(op, OWL.Thing.getURI()))); key = new FullPropertyKey(null, op.getURI(), null);
customListViewConfigFileName = customListViewConfigFileMap.get(key);
} }
return customListViewConfigFileName; return customListViewConfigFileName;

View file

@ -18,10 +18,9 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.jena.atlas.lib.Pair;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyDao.FullPropertyKey;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ontmodels.JoinedOntModelCache; import edu.cornell.mannlib.vitro.webapp.modelaccess.ontmodels.JoinedOntModelCache;
@ -123,11 +122,12 @@ public class BasicShortTermDataStructuresProvider implements
return ("true".equals(isStoreReasoned)); return ("true".equals(isStoreReasoned));
} }
private Map<Pair<String, Pair<ObjectProperty, String>>, String> getCustomListViewConfigFileMap() { private Map<FullPropertyKey, String> getCustomListViewConfigFileMap() {
Map<Pair<String, Pair<ObjectProperty, String>>, String> map = (Map<Pair<String, Pair<ObjectProperty, String>>, String>) ctx @SuppressWarnings("unchecked")
Map<FullPropertyKey, String> map = (Map<FullPropertyKey, String>) ctx
.getAttribute("customListViewConfigFileMap"); .getAttribute("customListViewConfigFileMap");
if (map == null) { if (map == null) {
map = new ConcurrentHashMap<Pair<String, Pair<ObjectProperty, String>>, String>(); map = new ConcurrentHashMap<FullPropertyKey, String>();
ctx.setAttribute("customListViewConfigFileMap", map); ctx.setAttribute("customListViewConfigFileMap", map);
} }
return map; return map;