Merge branch 'develop' of https://github.com/vivo-project/Vitro into develop

This commit is contained in:
hudajkhan 2013-10-04 15:42:26 -04:00
commit ea01cd7b39
11 changed files with 109 additions and 14 deletions

View file

@ -113,10 +113,10 @@ public class DisplayByRolePermission extends Permission {
private boolean isAuthorized(DisplayObjectPropertyStatement action) {
ObjectPropertyStatement stmt = action.getObjectPropertyStatement();
String subjectUri = stmt.getSubjectURI();
Property predicate = stmt.getProperty();
String predicateUri = stmt.getPropertyURI();
String objectUri = stmt.getObjectURI();
return canDisplayResource(subjectUri)
&& canDisplayPredicate(predicate)
&& canDisplayPredicate(new Property(predicateUri))
&& canDisplayResource(objectUri);
}

View file

@ -25,6 +25,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
@ -51,7 +52,8 @@ public class ClassgroupRetryController extends BaseEditController {
action = epo.getAction();
}
VClassGroupDao cgDao = request.getUnfilteredWebappDaoFactory().getVClassGroupDao();
VClassGroupDao cgDao = ModelAccess.on(
getServletContext()).getWebappDaoFactory().getVClassGroupDao();
epo.setDataAccessObject(cgDao);

View file

@ -25,6 +25,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
public class PropertyGroupRetryController extends BaseEditController {
@ -50,7 +51,8 @@ public class PropertyGroupRetryController extends BaseEditController {
action = epo.getAction();
}
PropertyGroupDao pgDao = request.getUnfilteredWebappDaoFactory().getPropertyGroupDao();
PropertyGroupDao pgDao = ModelAccess.on(
getServletContext()).getWebappDaoFactory().getPropertyGroupDao();
epo.setDataAccessObject(pgDao);

View file

@ -2,6 +2,7 @@
package edu.cornell.mannlib.vitro.webapp.controller.individual;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
@ -11,10 +12,13 @@ import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.NodeIterator;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Statement;
@ -33,6 +37,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RdfResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
@ -71,6 +76,17 @@ public class IndividualRdfAssembler {
private static final String RICH_EXPORT_ROOT = "/WEB-INF/rich-export/";
private static final String INCLUDE_ALL = "all";
private static final String NS_DC = "http://purl.org/dc/elements/1.1/";
private static final String URI_RIGHTS = NS_DC + "rights";
private static final String URI_DATE = NS_DC + "date";
private static final String URI_PUBLISHER = NS_DC + "publisher";
private static final String NS_FOAF = "http://xmlns.com/foaf/0.1/";
private static final String URI_DOCUMENT = NS_FOAF + "Document";
private static final String URI_LABEL = VitroVocabulary.RDFS + "label";
private static final String URI_TYPE = VitroVocabulary.RDF_TYPE;
private final VitroRequest vreq;
private final ServletContext ctx;
private final String individualUri;
@ -118,6 +134,7 @@ public class IndividualRdfAssembler {
o.add(getStatementsAboutEntity());
o.add(getLabelsAndTypesOfRelatedObjects());
filterByPolicy(o);
addDocumentMetadata(o);
return o;
}
@ -268,4 +285,65 @@ public class IndividualRdfAssembler {
return richExportModel;
}
/**
* Add info about the RDF itself.
*
* It will look something like this:
*
* <pre>
* <http://vivo.cornell.edu/individual/n6628/n6628.rdf>
* rdfs:label "RDF description of Baker, Able - http://vivo.cornell.edu/individual/n6628" ;
* rdf:type foaf:Document ;
* dc:publisher <http://vivo.cornell.edu> ;
* dc:date "2007-07-13"^^xsd:date ;
* dc:rights <http://vivo.cornell.edu/termsOfUse> .
* </pre>
*/
private void addDocumentMetadata(OntModel o) {
String baseUrl = figureBaseUrl();
String documentUri = createDocumentUri();
String label = createDocumentLabel(o);
Literal dateLiteral = createDateLiteral(o);
Resource md = o.getResource(documentUri);
o.add(md, o.getProperty(URI_LABEL), label);
o.add(md, o.getProperty(URI_TYPE), o.getResource(URI_DOCUMENT));
o.add(md, o.getProperty(URI_PUBLISHER), o.getResource(baseUrl));
o.add(md, o.getProperty(URI_DATE), dateLiteral);
o.add(md, o.getProperty(URI_RIGHTS),
o.getResource(baseUrl + "/termsOfUse"));
}
private String figureBaseUrl() {
int cutHere = individualUri.indexOf("/individual");
return (cutHere > 0) ? individualUri.substring(0, cutHere)
: individualUri;
}
private String createDocumentUri() {
return vreq.getRequestURL().toString();
}
private String createDocumentLabel(OntModel o) {
String label = null;
NodeIterator nodes = o.listObjectsOfProperty(
o.getResource(individualUri), o.getProperty(URI_LABEL));
while (nodes.hasNext()) {
RDFNode n = nodes.nextNode();
if (n.isLiteral()) {
label = n.asLiteral().getString();
}
}
if (label == null) {
return "RDF description of " + individualUri;
} else {
return "RDF description of " + label + " - " + individualUri;
}
}
private Literal createDateLiteral(OntModel o) {
return o.createTypedLiteral(new Date(), XSDDatatype.XSDdate);
}
}

View file

@ -28,7 +28,7 @@ public class IndividualRequestAnalyzer {
.getLog(IndividualRequestAnalyzer.class);
private static Pattern RDF_REQUEST = Pattern.compile("^/individual/([^/]+)/\\1\\.(rdf|n3|ttl)$");
private static Pattern RDF_REQUEST = Pattern.compile("^/individual/([^/]+)/\\1\\.(rdf|n3|ttl|jsonld)$");
private static Pattern HTML_REQUEST = Pattern.compile("^/display/([^/]+)$");
private static Pattern LINKED_DATA_URL = Pattern.compile("^/individual/([^/]+)$");
@ -145,7 +145,7 @@ public class IndividualRequestAnalyzer {
IndividualController.ACCEPTED_CONTENT_TYPES);
if (RDFXML_MIMETYPE.equals(ctStr) || N3_MIMETYPE.equals(ctStr)
|| TTL_MIMETYPE.equals(ctStr)) {
|| TTL_MIMETYPE.equals(ctStr) || JSON_MIMETYPE.equals(ctStr)) {
return new ContentType(ctStr);
}
} catch (Throwable th) {
@ -167,6 +167,7 @@ public class IndividualRequestAnalyzer {
* /individual/localname/localname.rdf
* /individual/localname/localname.n3
* /individual/localname/localname.ttl
* /individual/localname/localname.jsonld
* </pre>
*
* @return null on failure.
@ -257,6 +258,7 @@ public class IndividualRequestAnalyzer {
* http://vivo.cornell.edu/individual/n23/n23.rdf
* http://vivo.cornell.edu/individual/n23/n23.n3
* http://vivo.cornell.edu/individual/n23/n23.ttl
* http://vivo.cornell.edu/individual/n23/n23.jsonld
*/
Matcher rdfMatch = RDF_REQUEST.matcher(url);
if (rdfMatch.matches() && rdfMatch.groupCount() == 2) {
@ -270,6 +272,9 @@ public class IndividualRequestAnalyzer {
if ("ttl".equals(rdfType)) {
return ContentType.TURTLE;
}
if ("jsonld".equals(rdfType)) {
return ContentType.JSON;
}
}
return null;

View file

@ -226,7 +226,8 @@ public abstract class RDFServiceJena extends RDFServiceImpl implements RDFServic
}
}
if (subjQueue.isEmpty()) {
throw new RuntimeException("No named subject in statement patterns");
log.warn("No named subject in statement patterns");
return stmts;
}
while(remaining.size() > 0) {
if(subjQueue.isEmpty()) {

View file

@ -295,7 +295,8 @@ public class ABoxRecomputer {
*/
protected Collection<String> getAllIndividualURIs() {
String queryString = "select ?s where {?s a ?type}";
String queryString = "SELECT DISTINCT ?s WHERE { GRAPH ?g { ?s a ?type } " +
" FILTER (!bound(?g) || !regex(str(?g),\"tbox\")) } ORDER BY ?s";
return getIndividualURIs(queryString);
}

View file

@ -228,7 +228,7 @@ public class PagedSearchController extends FreemarkerHttpServlet {
Map<String, Object> body = new HashMap<String, Object>();
String classGroupParam = vreq.getParameter(PARAM_CLASSGROUP);
log.debug("Query text is \""+ classGroupParam + "\"");
log.debug("ClassGroupParam is \""+ classGroupParam + "\"");
boolean classGroupFilterRequested = false;
if (!StringUtils.isEmpty(classGroupParam)) {
VClassGroup grp = grpDao.getGroupByURI(classGroupParam);

View file

@ -100,7 +100,7 @@ public class ContextNodeFields implements DocumentModifier{
}catch(Throwable t){
if( ! shutdown )
log.error(t,t);
log.error("problem while running query '" + subInUriQuery + "'",t);
}
if(log.isDebugEnabled()){

View file

@ -82,8 +82,14 @@ public class ApplicationConfigurationOntologyUtils {
String domainURI = (domainRes != null) ? domainRes.getURI() : null;
String rangeURI = qsoln.getResource("range").getURI();
if (appropriateDomain(domainRes, subject, tboxModel)) {
additionalProps.add(opDao.getObjectPropertyByURIs(
opURI, domainURI, rangeURI));
ObjectProperty faux = opDao.getObjectPropertyByURIs(
opURI, domainURI, rangeURI);
if (faux != null) {
additionalProps.add(faux);
} else {
log.error("Could not retrieve " + opURI + " qualified by " +
" domain " + domainURI + " and range " + rangeURI);
}
}
}
} finally {

View file

@ -36,7 +36,7 @@ edu.cornell.mannlib.vitro.webapp.servlet.setup.FileGraphSetup
edu.cornell.mannlib.vitro.webapp.servlet.setup.SimpleReasonerSetup
edu.cornell.mannlib.vitro.webapp.servlet.setup.UpdateKnowledgeBase
#edu.cornell.mannlib.vitro.webapp.servlet.setup.UpdateKnowledgeBase
# Must run after JenaDataSourceSetup
edu.cornell.mannlib.vitro.webapp.servlet.setup.ThemeInfoSetup