Merge branch 'develop' of https://github.com/vivo-project/Vitro into develop
This commit is contained in:
commit
8e0bf8c229
6 changed files with 95 additions and 29 deletions
|
@ -831,7 +831,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected static final List<String> EXCLUDED_NAMESPACES = Arrays.asList(
|
protected static final List<String> EXCLUDED_NAMESPACES = Arrays.asList(
|
||||||
"http://www.w3.org/2002/07/owl#"
|
//"http://www.w3.org/2002/07/owl#"
|
||||||
);
|
);
|
||||||
/*
|
/*
|
||||||
* This is a hack to throw out properties in the vitro, rdf, rdfs, and owl namespaces.
|
* This is a hack to throw out properties in the vitro, rdf, rdfs, and owl namespaces.
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -10,6 +11,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
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;
|
||||||
|
@ -34,6 +36,7 @@ import com.hp.hpl.jena.rdf.model.Statement;
|
||||||
import com.hp.hpl.jena.rdf.model.StmtIterator;
|
import com.hp.hpl.jena.rdf.model.StmtIterator;
|
||||||
import com.hp.hpl.jena.shared.Lock;
|
import com.hp.hpl.jena.shared.Lock;
|
||||||
import com.hp.hpl.jena.util.iterator.ClosableIterator;
|
import com.hp.hpl.jena.util.iterator.ClosableIterator;
|
||||||
|
import com.hp.hpl.jena.vocabulary.OWL;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||||
|
@ -402,13 +405,24 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
|
||||||
w.close();
|
w.close();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
constructedModel.read(
|
String parseFormat = "N3";
|
||||||
rdfService.sparqlConstructQuery(
|
RDFService.ModelSerializationFormat resultFormat = RDFService.ModelSerializationFormat.N3;
|
||||||
queryString, RDFService.ModelSerializationFormat.N3), null, "N3");
|
|
||||||
|
|
||||||
|
/* If the test ObjectPropertyStatementDaoJenaTest.testN3WithSameAs() fails
|
||||||
|
* this code can be removed: */
|
||||||
|
if( OWL.sameAs.getURI().equals( propertyUri )){
|
||||||
|
// VIVO-111: owl:sameAs can be represented as = in n3 but Jena's parser does not recognize it.
|
||||||
|
// Switch to rdf/xml only for sameAs since it seems like n3 would be faster the rest of the time.
|
||||||
|
parseFormat = "RDF/XML";
|
||||||
|
resultFormat = RDFService.ModelSerializationFormat.RDFXML;
|
||||||
|
}
|
||||||
|
/* end of removal */
|
||||||
|
|
||||||
|
InputStream is = rdfService.sparqlConstructQuery(queryString, resultFormat);
|
||||||
|
constructedModel.read( is, null, parseFormat);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error getting constructed model for subject " + subjectUri + " and property " + propertyUri);
|
log.error("Error getting constructed model for subject " + subjectUri + " and property " + propertyUri, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,12 @@ public class PropertyGroupTemplateModel extends BaseTemplateModel {
|
||||||
private final String name;
|
private final String name;
|
||||||
private final List<PropertyTemplateModel> properties;
|
private final List<PropertyTemplateModel> properties;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PropertyGroupTemplateModel(VitroRequest vreq, PropertyGroup group,
|
PropertyGroupTemplateModel(VitroRequest vreq, PropertyGroup group,
|
||||||
Individual subject, boolean editing,
|
Individual subject, boolean editing,
|
||||||
List<DataProperty> populatedDataPropertyList, List<ObjectProperty> populatedObjectPropertyList) {
|
List<DataProperty> populatedDataPropertyList,
|
||||||
|
List<ObjectProperty> populatedObjectPropertyList) {
|
||||||
|
|
||||||
this.name = group.getName();
|
this.name = group.getName();
|
||||||
|
|
||||||
|
@ -50,6 +53,17 @@ public class PropertyGroupTemplateModel extends BaseTemplateModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
String ptmStr ="";
|
||||||
|
for( int i=0; i < properties.size() ; i ++ ){
|
||||||
|
PropertyTemplateModel ptm = properties.get(i);
|
||||||
|
String spacer = "\n ";
|
||||||
|
if( ptm != null )
|
||||||
|
ptmStr = ptmStr + spacer + ptm.toString();
|
||||||
|
}
|
||||||
|
return String.format("\nPropertyGroupTemplateModel %s[%s] ",name, ptmStr );
|
||||||
|
}
|
||||||
|
|
||||||
/* Accessor methods for templates */
|
/* Accessor methods for templates */
|
||||||
// Add this so it's included in dumps for debugging. The templates will want to display
|
// Add this so it's included in dumps for debugging. The templates will want to display
|
||||||
// name using getName(String)
|
// name using getName(String)
|
||||||
|
@ -58,18 +72,14 @@ public class PropertyGroupTemplateModel extends BaseTemplateModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName(String otherGroupName) {
|
public String getName(String otherGroupName) {
|
||||||
String displayName = name;
|
if (name == null || name.isEmpty()) {
|
||||||
if (displayName == null) {
|
return otherGroupName;
|
||||||
displayName = "";
|
} else {
|
||||||
} else if (displayName.isEmpty()) {
|
return name;
|
||||||
displayName = otherGroupName;
|
|
||||||
}
|
}
|
||||||
return displayName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PropertyTemplateModel> getProperties() {
|
public List<PropertyTemplateModel> getProperties() {
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,12 +36,13 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PropertyTemplateModel(Property property, Individual subject, VitroRequest vreq) {
|
PropertyTemplateModel(Property property, Individual subject, VitroRequest vreq) {
|
||||||
this.vreq = vreq;
|
this.vreq = vreq;
|
||||||
subjectUri = subject.getURI();
|
subjectUri = subject.getURI();
|
||||||
propertyUri = property.getURI();
|
propertyUri = property.getURI();
|
||||||
localName = property.getLocalName();
|
localName = property.getLocalName();
|
||||||
log.debug("Local name for property " + propertyUri + ": " + localName);
|
|
||||||
setVerboseDisplayValues(property);
|
setVerboseDisplayValues(property);
|
||||||
addUrl = "";
|
addUrl = "";
|
||||||
|
|
||||||
|
@ -53,14 +54,18 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
|
||||||
protected void setVerboseDisplayValues(Property property) {
|
protected void setVerboseDisplayValues(Property property) {
|
||||||
|
|
||||||
// No verbose display for vitro and vitro public properties.
|
// No verbose display for vitro and vitro public properties.
|
||||||
// This models previous behavior. In theory the verbose display can be provided, but we may not want
|
// This models previous behavior. In theory the verbose display can be provided,
|
||||||
// to give anyone access to these properties, since the application is dependent on them.
|
// but we may not want to give anyone access to these properties, since the
|
||||||
|
// application is dependent on them.
|
||||||
String namespace = property.getNamespace();
|
String namespace = property.getNamespace();
|
||||||
if (VitroVocabulary.vitroURI.equals(namespace) || VitroVocabulary.VITRO_PUBLIC.equals(namespace)) {
|
if (VitroVocabulary.vitroURI.equals(namespace)
|
||||||
|
|| VitroVocabulary.VITRO_PUBLIC.equals(namespace)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolean verboseDisplayValue = (Boolean) vreq.getSession().getAttribute("verbosePropertyDisplay");
|
Boolean verboseDisplayValue =
|
||||||
|
(Boolean) vreq.getSession().getAttribute("verbosePropertyDisplay");
|
||||||
|
|
||||||
if ( ! Boolean.TRUE.equals(verboseDisplayValue)) {
|
if ( ! Boolean.TRUE.equals(verboseDisplayValue)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -94,6 +99,12 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return String.format("%s on %s",
|
||||||
|
propertyUri != null ? propertyUri : "null Prop URI",
|
||||||
|
subjectUri != null ? subjectUri : "null Sub URI" );
|
||||||
|
}
|
||||||
|
|
||||||
/* Template properties */
|
/* Template properties */
|
||||||
|
|
||||||
public abstract String getType();
|
public abstract String getType();
|
||||||
|
@ -118,5 +129,4 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
|
||||||
public Map<String, Object> getVerboseDisplay() {
|
public Map<String, Object> getVerboseDisplay() {
|
||||||
return verboseDisplay;
|
return verboseDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
|
|
||||||
|
public class ObjectPropertyStatementDaoJenaTest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if jena lib can parse N3 that it generates.
|
||||||
|
* owl:sameAs has been a problem when it is represetned
|
||||||
|
* in N3 with the character =
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testN3WithSameAs() {
|
||||||
|
|
||||||
|
String n3WithSameAs = " <http://example.com/bob> = <http://example.com/robert> .";
|
||||||
|
|
||||||
|
try{
|
||||||
|
Model m = ModelFactory.createDefaultModel();
|
||||||
|
m.read(n3WithSameAs, null, "N3");
|
||||||
|
fail( "If this test fails it means that jena now correctly parses = when reading N3.");
|
||||||
|
}catch(Exception ex ){
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -69,7 +69,7 @@
|
||||||
<p>${i18n().you_can} <a href="${urls.siteAdmin}" title="${i18n().add_content_manage_site}">${i18n().add_content_manage_site}</a>${i18n().from_site_admin_page}</p>
|
<p>${i18n().you_can} <a href="${urls.siteAdmin}" title="${i18n().add_content_manage_site}">${i18n().add_content_manage_site}</a>${i18n().from_site_admin_page}</p>
|
||||||
</#if>
|
</#if>
|
||||||
<#else>
|
<#else>
|
||||||
<p>${i18n().please} <a href="${urls.login}" title="${i18n().login_to_manage_site}">${i18n().log_in}</a> ${i18n().to_manage_content.}</p>
|
<p>${i18n().please} <a href="${urls.login}" title="${i18n().login_to_manage_site}">${i18n().log_in}</a> ${i18n().to_manage_content}.</p>
|
||||||
</#if>
|
</#if>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue