VIVO-112 more updates
This commit is contained in:
parent
140288a65e
commit
58bb33c5f7
4 changed files with 85 additions and 10 deletions
|
@ -52,6 +52,8 @@ local:authorInAuthorshipContext a :ConfigContext ;
|
|||
local:authorInAuthorshipConfig a :ObjectPropertyDisplayConfig ;
|
||||
:listViewConfigFile "listViewConfig-authorInAuthorship.xml"^^xsd:string ;
|
||||
:displayName "selected publications" ;
|
||||
vitro:collateBySubclassAnnot
|
||||
"true"^^xsd:boolean;
|
||||
vitro:displayRankAnnot 1;
|
||||
vitro:hiddenFromDisplayBelowRoleLevelAnnot role:public ;
|
||||
vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ;
|
||||
|
|
|
@ -8,9 +8,21 @@ import java.util.List;
|
|||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
import com.hp.hpl.jena.vocabulary.XSD;
|
||||
import com.hp.hpl.jena.query.Query;
|
||||
import com.hp.hpl.jena.query.QueryFactory;
|
||||
import com.hp.hpl.jena.query.QueryExecution;
|
||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
import com.hp.hpl.jena.sparql.resultset.ResultSetMem;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.PersonHasAdviseesValidator;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
|
||||
|
@ -31,7 +43,46 @@ public class AddEditorshipToPersonGenerator extends VivoBaseGenerator implements
|
|||
public AddEditorshipToPersonGenerator() {}
|
||||
|
||||
@Override
|
||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) throws Exception {
|
||||
|
||||
if( EditConfigurationUtils.getObjectUri(vreq) == null ){
|
||||
return doAddNew(vreq,session);
|
||||
}else{
|
||||
return doSkipToDocument(vreq);
|
||||
}
|
||||
}
|
||||
|
||||
private EditConfigurationVTwo doSkipToDocument(VitroRequest vreq) {
|
||||
Individual editorshipNode = EditConfigurationUtils.getObjectIndividual(vreq);
|
||||
|
||||
//try to get the document
|
||||
String documentQueryStr = "SELECT ?obj \n" +
|
||||
"WHERE { <" + editorshipNode.getURI() + "> <http://vivoweb.org/ontology/core#relates> ?obj . \n" +
|
||||
" ?obj a <http://purl.obolibrary.org/obo/IAO_0000030> . } \n";
|
||||
Query documentQuery = QueryFactory.create(documentQueryStr);
|
||||
QueryExecution qe = QueryExecutionFactory.create(documentQuery, ModelAccess.on(vreq).getJenaOntModel());
|
||||
try {
|
||||
ResultSetMem rs = new ResultSetMem(qe.execSelect());
|
||||
if(!rs.hasNext()){
|
||||
return doBadEditorshipNoPub( vreq );
|
||||
}else if( rs.size() > 1 ){
|
||||
return doBadEditorshipMultiplePubs(vreq);
|
||||
}else{
|
||||
//skip to document
|
||||
RDFNode objNode = rs.next().get("obj");
|
||||
if (!objNode.isResource() || objNode.isAnon()) {
|
||||
return doBadEditorshipNoPub( vreq );
|
||||
}
|
||||
EditConfigurationVTwo editConfiguration = new EditConfigurationVTwo();
|
||||
editConfiguration.setSkipToUrl(UrlBuilder.getIndividualProfileUrl(((Resource) objNode).getURI(), vreq));
|
||||
return editConfiguration;
|
||||
}
|
||||
} finally {
|
||||
qe.close();
|
||||
}
|
||||
}
|
||||
|
||||
protected EditConfigurationVTwo doAddNew(VitroRequest vreq,
|
||||
HttpSession session) throws Exception {
|
||||
|
||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||
|
@ -73,6 +124,10 @@ public class AddEditorshipToPersonGenerator extends VivoBaseGenerator implements
|
|||
setValidators( list("datatype:" + XSD.xstring.toString()) )
|
||||
);
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("documentLabelDisplay").
|
||||
setRangeDatatypeUri(XSD.xstring.toString() ));
|
||||
|
||||
conf.addValidator(new AntiXssValidation());
|
||||
addFormSpecificData(conf, vreq);
|
||||
|
||||
|
@ -145,6 +200,16 @@ public class AddEditorshipToPersonGenerator extends VivoBaseGenerator implements
|
|||
return EditModeUtils.getEditMode(vreq, predicates);
|
||||
}
|
||||
|
||||
private EditConfigurationVTwo doBadEditorshipMultiplePubs(VitroRequest vreq) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
private EditConfigurationVTwo doBadEditorshipNoPub(VitroRequest vreq) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<List<String>> getDocumentTypeLiteralOptions() {
|
||||
List<List<String>> literalOptions = new ArrayList<List<String>>();
|
||||
literalOptions.add(list("http://purl.org/ontology/bibo/Book", "Book"));
|
||||
|
|
|
@ -46,7 +46,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
|
||||
final static String collectionClass = bibo + "Periodical";
|
||||
final static String bookClass = bibo + "Book";
|
||||
final static String documentClass = bibo + "Document";
|
||||
final static String documentClass = "http://purl.obolibrary.org/obo/IAO_0000030";
|
||||
final static String conferenceClass = bibo + "Conference";
|
||||
final static String editorClass = foaf + "Person";
|
||||
final static String publisherClass = vivoCore + "Publisher";
|
||||
|
|
|
@ -11,7 +11,7 @@ import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.ContextNode
|
|||
|
||||
/**
|
||||
* Class that adds text from context nodes to Solr Documents for
|
||||
* core:InformationResource individuals.
|
||||
* obo:IAO_0000030 individuals.
|
||||
*
|
||||
* @author bdc34
|
||||
*
|
||||
|
@ -30,12 +30,13 @@ public class VivoInformationResourceContextNodeFields extends ContextNodeFields{
|
|||
+ " prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
|
||||
+ " prefix core: <http://vivoweb.org/ontology/core#> "
|
||||
+ " prefix foaf: <http://xmlns.com/foaf/0.1/> "
|
||||
+ " prefix obo: <http://purl.obolibrary.org/> "
|
||||
+ " prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> "
|
||||
+ " prefix localNav: <http://vitro.mannlib.cornell.edu/ns/localnav#> "
|
||||
+ " prefix bibo: <http://purl.org/ontology/bibo/> ";
|
||||
|
||||
|
||||
//queries for core:InformationResource
|
||||
//queries for obo:IAO_0000030
|
||||
static {
|
||||
|
||||
/* linked author labels */
|
||||
|
@ -43,8 +44,11 @@ public class VivoInformationResourceContextNodeFields extends ContextNodeFields{
|
|||
queriesForInformationResource
|
||||
.add(prefix
|
||||
+ "SELECT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {"
|
||||
+ " ?uri rdf:type core:InformationResource . "
|
||||
+ "?uri core:informationResourceInAuthorship ?a . ?a core:linkedAuthor ?b ."
|
||||
+ "?uri rdf:type obo:IAO_0000030 . "
|
||||
+ "?uri core:relatedBy ?a . "
|
||||
+ "?a rdf:type core:Authorship ."
|
||||
+ "?a core:relates ?b ."
|
||||
+ "?b rdf:type foaf:Person ."
|
||||
+ "?b rdfs:label ?ContextNodeProperty .}");
|
||||
|
||||
/* features */
|
||||
|
@ -52,7 +56,7 @@ public class VivoInformationResourceContextNodeFields extends ContextNodeFields{
|
|||
queriesForInformationResource
|
||||
.add(prefix
|
||||
+ "SELECT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {"
|
||||
+ "?uri rdf:type core:InformationResource . "
|
||||
+ "?uri rdf:type obo:IAO_0000030 . "
|
||||
+ "?uri core:features ?i . ?i rdfs:label ?ContextNodeProperty ."
|
||||
+ "}");
|
||||
|
||||
|
@ -61,8 +65,12 @@ public class VivoInformationResourceContextNodeFields extends ContextNodeFields{
|
|||
queriesForInformationResource
|
||||
.add(prefix
|
||||
+ "SELECT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {"
|
||||
+ "?uri rdf:type core:InformationResource . "
|
||||
+ "?uri bibo:editor ?e . ?e rdfs:label ?ContextNodeProperty ."
|
||||
+ "?uri rdf:type obo:IAO_0000030 . "
|
||||
+ "?uri core:relatedBy ?e . "
|
||||
+ "?e rdf:type core:Editorship ."
|
||||
+ "?e core:relates ?i ."
|
||||
+ "?i rdf:type foaf:Person ."
|
||||
+ "?i rdfs:label ?ContextNodeProperty ."
|
||||
+ "}");
|
||||
|
||||
/* subject area */
|
||||
|
@ -70,7 +78,7 @@ public class VivoInformationResourceContextNodeFields extends ContextNodeFields{
|
|||
queriesForInformationResource
|
||||
.add(prefix
|
||||
+ "SELECT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {"
|
||||
+ "?uri rdf:type core:InformationResource . "
|
||||
+ "?uri rdf:type obo:IAO_0000030 . "
|
||||
+ "?uri core:hasSubjectArea ?f . ?f rdfs:label ?ContextNodeProperty ."
|
||||
+ "}");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue