[VIVO-1690] - Remove trailing whitespace throughout project (#126)
* Remove trailing whitespace throughout project Resolves: https://jira.duraspace.org/browse/VIVO-1690 ** Along with: https://github.com/vivo-project/Vitro/pull/117
This commit is contained in:
parent
48dcf87199
commit
87092cec9c
685 changed files with 26805 additions and 26805 deletions
|
@ -1,397 +1,397 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.semservices.service.impl;
|
package edu.cornell.mannlib.semservices.service.impl;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.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.query.Query;
|
import org.apache.jena.query.Query;
|
||||||
import org.apache.jena.query.QueryExecution;
|
import org.apache.jena.query.QueryExecution;
|
||||||
import org.apache.jena.query.QueryExecutionFactory;
|
import org.apache.jena.query.QueryExecutionFactory;
|
||||||
import org.apache.jena.query.QueryFactory;
|
import org.apache.jena.query.QueryFactory;
|
||||||
import org.apache.jena.query.QuerySolution;
|
import org.apache.jena.query.QuerySolution;
|
||||||
import org.apache.jena.query.ResultSet;
|
import org.apache.jena.query.ResultSet;
|
||||||
import org.apache.jena.rdf.model.Literal;
|
import org.apache.jena.rdf.model.Literal;
|
||||||
import org.apache.jena.rdf.model.RDFNode;
|
import org.apache.jena.rdf.model.RDFNode;
|
||||||
import org.apache.jena.rdf.model.Resource;
|
import org.apache.jena.rdf.model.Resource;
|
||||||
import org.w3c.dom.Attr;
|
import org.w3c.dom.Attr;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.NamedNodeMap;
|
import org.w3c.dom.NamedNodeMap;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
|
||||||
import edu.cornell.mannlib.semservices.bo.Concept;
|
import edu.cornell.mannlib.semservices.bo.Concept;
|
||||||
import edu.cornell.mannlib.semservices.service.ExternalConceptService;
|
import edu.cornell.mannlib.semservices.service.ExternalConceptService;
|
||||||
import edu.cornell.mannlib.semservices.util.SKOSUtils;
|
import edu.cornell.mannlib.semservices.util.SKOSUtils;
|
||||||
import edu.cornell.mannlib.semservices.util.XMLUtils;
|
import edu.cornell.mannlib.semservices.util.XMLUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.json.JacksonUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.json.JacksonUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
||||||
|
|
||||||
public class AgrovocService implements ExternalConceptService {
|
public class AgrovocService implements ExternalConceptService {
|
||||||
|
|
||||||
protected final Log logger = LogFactory.getLog(getClass());
|
protected final Log logger = LogFactory.getLog(getClass());
|
||||||
private final String schemeUri = "http://aims.fao.org/aos/agrovoc/agrovocScheme";
|
private final String schemeUri = "http://aims.fao.org/aos/agrovoc/agrovocScheme";
|
||||||
private final String ontologyName = "agrovoc";
|
private final String ontologyName = "agrovoc";
|
||||||
private final String format = "SKOS";
|
private final String format = "SKOS";
|
||||||
private final String lang = "en";
|
private final String lang = "en";
|
||||||
private final String searchMode = "starts with";//Used to be Exact Match, or exact word or starts with
|
private final String searchMode = "starts with";//Used to be Exact Match, or exact word or starts with
|
||||||
protected final String dbpedia_endpoint = " http://dbpedia.org/sparql";
|
protected final String dbpedia_endpoint = " http://dbpedia.org/sparql";
|
||||||
// URL to get all the information for a concept
|
// URL to get all the information for a concept
|
||||||
|
|
||||||
protected final String conceptSkosMosBase = "http://agrovoc.uniroma2.it/agrovoc/rest/v1/";
|
protected final String conceptSkosMosBase = "http://agrovoc.uniroma2.it/agrovoc/rest/v1/";
|
||||||
protected final String conceptsSkosMosSearch = conceptSkosMosBase + "search?";
|
protected final String conceptsSkosMosSearch = conceptSkosMosBase + "search?";
|
||||||
protected final String conceptSkosMosURL = conceptSkosMosBase + "data?";
|
protected final String conceptSkosMosURL = conceptSkosMosBase + "data?";
|
||||||
@Override
|
@Override
|
||||||
public List<Concept> getConcepts(String term) throws Exception {
|
public List<Concept> getConcepts(String term) throws Exception {
|
||||||
List<Concept> conceptList = new ArrayList<>();
|
List<Concept> conceptList = new ArrayList<>();
|
||||||
|
|
||||||
//For the RDF webservices mechanism, utilize the following
|
//For the RDF webservices mechanism, utilize the following
|
||||||
/*
|
/*
|
||||||
String result = getTermExpansion(this.ontologyName, term,
|
String result = getTermExpansion(this.ontologyName, term,
|
||||||
this.searchMode, this.format, this.lang);
|
this.searchMode, this.format, this.lang);
|
||||||
|
|
||||||
// return empty conceptList if conceptUri is empty
|
// return empty conceptList if conceptUri is empty
|
||||||
if (StringUtils.isEmpty(result)) {
|
if (StringUtils.isEmpty(result)) {
|
||||||
return conceptList;
|
return conceptList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the list of the concept URIs in the RDF
|
// Get the list of the concept URIs in the RDF
|
||||||
List<String> conceptUris = getConceptURIsListFromRDF(result);
|
List<String> conceptUris = getConceptURIsListFromRDF(result);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//For the SKOSMos search mechanism, utilize this instead
|
//For the SKOSMos search mechanism, utilize this instead
|
||||||
String result = getSKOSMosSearchResults(term, this.lang);
|
String result = getSKOSMosSearchResults(term, this.lang);
|
||||||
List<String> conceptUris = getConceptURIsListFromSkosMosResult(result);
|
List<String> conceptUris = getConceptURIsListFromSkosMosResult(result);
|
||||||
if (conceptUris.size() == 0)
|
if (conceptUris.size() == 0)
|
||||||
return conceptList;
|
return conceptList;
|
||||||
int conceptCounter = 0;
|
int conceptCounter = 0;
|
||||||
|
|
||||||
HashSet<String> encounteredURI = new HashSet<>();
|
HashSet<String> encounteredURI = new HashSet<>();
|
||||||
|
|
||||||
// Loop through each of these URIs and load using the SKOSManager
|
// Loop through each of these URIs and load using the SKOSManager
|
||||||
for (String conceptUri : conceptUris) {
|
for (String conceptUri : conceptUris) {
|
||||||
conceptCounter++;
|
conceptCounter++;
|
||||||
if (StringUtils.isEmpty(conceptUri)) {
|
if (StringUtils.isEmpty(conceptUri)) {
|
||||||
// If the conceptURI is empty, keep going
|
// If the conceptURI is empty, keep going
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(encounteredURI.contains(conceptUri)) {
|
if(encounteredURI.contains(conceptUri)) {
|
||||||
//If we have already encountered this concept URI, do not redisplay or reprocess
|
//If we have already encountered this concept URI, do not redisplay or reprocess
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
encounteredURI.add(conceptUri);
|
encounteredURI.add(conceptUri);
|
||||||
|
|
||||||
// Test and see if the URI is valid
|
// Test and see if the URI is valid
|
||||||
URI uri = null;
|
URI uri = null;
|
||||||
try {
|
try {
|
||||||
uri = new URI(conceptUri);
|
uri = new URI(conceptUri);
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
logger.error("Error occurred with creating the URI ", e);
|
logger.error("Error occurred with creating the URI ", e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Returns concept information in the format specified, which is
|
// Returns concept information in the format specified, which is
|
||||||
// currently XML
|
// currently XML
|
||||||
// Utilizing Agrovoc's getConceptInfo returns alternate and
|
// Utilizing Agrovoc's getConceptInfo returns alternate and
|
||||||
// preferred labels but
|
// preferred labels but
|
||||||
// none of the exact match or close match descriptions
|
// none of the exact match or close match descriptions
|
||||||
String bestMatch = "false";
|
String bestMatch = "false";
|
||||||
//Assume the first result is considered the 'best match'
|
//Assume the first result is considered the 'best match'
|
||||||
//Although that is not something we are actually retrieving from the service itself explicitly
|
//Although that is not something we are actually retrieving from the service itself explicitly
|
||||||
if(conceptCounter == 1) {
|
if(conceptCounter == 1) {
|
||||||
bestMatch = "true";
|
bestMatch = "true";
|
||||||
}
|
}
|
||||||
Concept c = this.createConcept(bestMatch, conceptUri);
|
Concept c = this.createConcept(bestMatch, conceptUri);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
// Get definition from dbpedia references stored in the close
|
// Get definition from dbpedia references stored in the close
|
||||||
// Match list
|
// Match list
|
||||||
List<String> closeMatches = c.getCloseMatchURIList();
|
List<String> closeMatches = c.getCloseMatchURIList();
|
||||||
for (String closeMatch : closeMatches) {
|
for (String closeMatch : closeMatches) {
|
||||||
|
|
||||||
if (closeMatch.startsWith("http://dbpedia.org")) {
|
if (closeMatch.startsWith("http://dbpedia.org")) {
|
||||||
try {
|
try {
|
||||||
String description = getDbpediaDescription(closeMatch);
|
String description = getDbpediaDescription(closeMatch);
|
||||||
c.setDefinition(description);
|
c.setDefinition(description);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.error("An error occurred in the process of retrieving dbpedia description", ex);
|
logger.error("An error occurred in the process of retrieving dbpedia description", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conceptList.add(c);
|
conceptList.add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return conceptList;
|
return conceptList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public List<Concept> processResults(String term) throws Exception {
|
public List<Concept> processResults(String term) throws Exception {
|
||||||
return getConcepts(term);
|
return getConcepts(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Concept createConcept(String bestMatch, String skosConceptURI) {
|
public Concept createConcept(String bestMatch, String skosConceptURI) {
|
||||||
|
|
||||||
Concept concept = new Concept();
|
Concept concept = new Concept();
|
||||||
concept.setUri(skosConceptURI);
|
concept.setUri(skosConceptURI);
|
||||||
concept.setConceptId(stripConceptId(skosConceptURI));
|
concept.setConceptId(stripConceptId(skosConceptURI));
|
||||||
concept.setBestMatch(bestMatch);
|
concept.setBestMatch(bestMatch);
|
||||||
concept.setDefinedBy(schemeUri);
|
concept.setDefinedBy(schemeUri);
|
||||||
concept.setSchemeURI(this.schemeUri);
|
concept.setSchemeURI(this.schemeUri);
|
||||||
concept.setType("");
|
concept.setType("");
|
||||||
|
|
||||||
String encodedURI = URLEncoder.encode(skosConceptURI);
|
String encodedURI = URLEncoder.encode(skosConceptURI);
|
||||||
String encodedFormat = URLEncoder.encode("application/rdf+xml");
|
String encodedFormat = URLEncoder.encode("application/rdf+xml");
|
||||||
String url = conceptSkosMosURL + "uri=" + encodedURI + "&format="
|
String url = conceptSkosMosURL + "uri=" + encodedURI + "&format="
|
||||||
+ encodedFormat;
|
+ encodedFormat;
|
||||||
|
|
||||||
// Utilize the XML directly instead of the SKOS API
|
// Utilize the XML directly instead of the SKOS API
|
||||||
try {
|
try {
|
||||||
|
|
||||||
concept = SKOSUtils
|
concept = SKOSUtils
|
||||||
.createConceptUsingXMLFromURL(concept, url, "en", false);
|
.createConceptUsingXMLFromURL(concept, url, "en", false);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.debug("Error occurred for creating concept "
|
logger.debug("Error occurred for creating concept "
|
||||||
+ skosConceptURI, ex);
|
+ skosConceptURI, ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return concept;
|
return concept;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Concept> getConceptsByURIWithSparql(String uri)
|
public List<Concept> getConceptsByURIWithSparql(String uri)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// deprecating this method...just return an empty list
|
// deprecating this method...just return an empty list
|
||||||
List<Concept> conceptList = new ArrayList<>();
|
List<Concept> conceptList = new ArrayList<>();
|
||||||
return conceptList;
|
return conceptList;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getAgrovocTermCode(String rdf) throws Exception {
|
protected String getAgrovocTermCode(String rdf) throws Exception {
|
||||||
String termcode = "";
|
String termcode = "";
|
||||||
try {
|
try {
|
||||||
Document doc = XMLUtils.parse(rdf);
|
Document doc = XMLUtils.parse(rdf);
|
||||||
NodeList nodes = doc.getElementsByTagName("hasCodeAgrovoc");
|
NodeList nodes = doc.getElementsByTagName("hasCodeAgrovoc");
|
||||||
if (nodes.item(0) != null) {
|
if (nodes.item(0) != null) {
|
||||||
Node node = nodes.item(0);
|
Node node = nodes.item(0);
|
||||||
termcode = node.getTextContent();
|
termcode = node.getTextContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SAXException | IOException | ParserConfigurationException e) {
|
} catch (SAXException | IOException | ParserConfigurationException e) {
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
return termcode;
|
return termcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getConceptURIFromRDF(String rdf) {
|
protected String getConceptURIFromRDF(String rdf) {
|
||||||
String conceptUri = "";
|
String conceptUri = "";
|
||||||
try {
|
try {
|
||||||
Document doc = XMLUtils.parse(rdf);
|
Document doc = XMLUtils.parse(rdf);
|
||||||
NodeList nodes = doc.getElementsByTagName("skos:Concept");
|
NodeList nodes = doc.getElementsByTagName("skos:Concept");
|
||||||
Node node = nodes.item(0);
|
Node node = nodes.item(0);
|
||||||
|
|
||||||
NamedNodeMap attrs = node.getAttributes();
|
NamedNodeMap attrs = node.getAttributes();
|
||||||
Attr idAttr = (Attr) attrs.getNamedItem("rdf:about");
|
Attr idAttr = (Attr) attrs.getNamedItem("rdf:about");
|
||||||
conceptUri = idAttr.getTextContent();
|
conceptUri = idAttr.getTextContent();
|
||||||
} catch (IOException | ParserConfigurationException | SAXException e) {
|
} catch (IOException | ParserConfigurationException | SAXException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.err.println("rdf: " + rdf);
|
System.err.println("rdf: " + rdf);
|
||||||
}
|
}
|
||||||
return conceptUri;
|
return conceptUri;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// When utilizing the getTermExpansion method, will get a list of URIs back
|
// When utilizing the getTermExpansion method, will get a list of URIs back
|
||||||
// and not just one URI
|
// and not just one URI
|
||||||
protected List<String> getConceptURIsListFromRDF(String rdf) {
|
protected List<String> getConceptURIsListFromRDF(String rdf) {
|
||||||
List<String> conceptUris = new ArrayList<>();
|
List<String> conceptUris = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
Document doc = XMLUtils.parse(rdf);
|
Document doc = XMLUtils.parse(rdf);
|
||||||
NodeList nodes = doc.getElementsByTagName("skos:Concept");
|
NodeList nodes = doc.getElementsByTagName("skos:Concept");
|
||||||
int numberNodes = nodes.getLength();
|
int numberNodes = nodes.getLength();
|
||||||
int n;
|
int n;
|
||||||
for (n = 0; n < numberNodes; n++) {
|
for (n = 0; n < numberNodes; n++) {
|
||||||
Node node = nodes.item(n);
|
Node node = nodes.item(n);
|
||||||
NamedNodeMap attrs = node.getAttributes();
|
NamedNodeMap attrs = node.getAttributes();
|
||||||
Attr idAttr = (Attr) attrs.getNamedItem("rdf:about");
|
Attr idAttr = (Attr) attrs.getNamedItem("rdf:about");
|
||||||
String conceptUri = idAttr.getTextContent();
|
String conceptUri = idAttr.getTextContent();
|
||||||
conceptUris.add(conceptUri);
|
conceptUris.add(conceptUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (IOException | ParserConfigurationException | SAXException e) {
|
} catch (IOException | ParserConfigurationException | SAXException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.err.println("rdf: " + rdf);
|
System.err.println("rdf: " + rdf);
|
||||||
}
|
}
|
||||||
return conceptUris;
|
return conceptUris;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getDbpediaDescription(String uri) throws Exception {
|
protected String getDbpediaDescription(String uri) throws Exception {
|
||||||
String descriptionSource = " (Source: DBpedia)";
|
String descriptionSource = " (Source: DBpedia)";
|
||||||
String description = "";
|
String description = "";
|
||||||
String qs = ""
|
String qs = ""
|
||||||
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
||||||
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
|
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
|
||||||
+ "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n"
|
+ "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n"
|
||||||
+ "PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>\n"
|
+ "PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>\n"
|
||||||
+ "SELECT DISTINCT ?description WHERE { \n" + "<" + uri
|
+ "SELECT DISTINCT ?description WHERE { \n" + "<" + uri
|
||||||
+ "> rdfs:comment ?description . \n"
|
+ "> rdfs:comment ?description . \n"
|
||||||
+ "FILTER (LANG(?description)='en' ) \n" + "}";
|
+ "FILTER (LANG(?description)='en' ) \n" + "}";
|
||||||
// System.out.println(qs);
|
// System.out.println(qs);
|
||||||
List<HashMap> resultList = new ArrayList<>();
|
List<HashMap> resultList = new ArrayList<>();
|
||||||
QueryExecution qexec = null;
|
QueryExecution qexec = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Query query = QueryFactory.create(qs);
|
Query query = QueryFactory.create(qs);
|
||||||
qexec = QueryExecutionFactory.sparqlService(this.dbpedia_endpoint, query);
|
qexec = QueryExecutionFactory.sparqlService(this.dbpedia_endpoint, query);
|
||||||
qexec.setTimeout(5000, TimeUnit.MILLISECONDS);
|
qexec.setTimeout(5000, TimeUnit.MILLISECONDS);
|
||||||
resultList = new ArrayList<>();
|
resultList = new ArrayList<>();
|
||||||
ResultSet resultSet = qexec.execSelect();
|
ResultSet resultSet = qexec.execSelect();
|
||||||
int resultSetSize = 0;
|
int resultSetSize = 0;
|
||||||
while (resultSet.hasNext()) {
|
while (resultSet.hasNext()) {
|
||||||
resultSetSize++;
|
resultSetSize++;
|
||||||
QuerySolution solution = resultSet.nextSolution();
|
QuerySolution solution = resultSet.nextSolution();
|
||||||
Iterator varnames = solution.varNames();
|
Iterator varnames = solution.varNames();
|
||||||
HashMap<String, String> hm = new HashMap<>();
|
HashMap<String, String> hm = new HashMap<>();
|
||||||
while (varnames.hasNext()) {
|
while (varnames.hasNext()) {
|
||||||
String name = (String) varnames.next();
|
String name = (String) varnames.next();
|
||||||
RDFNode rdfnode = solution.get(name);
|
RDFNode rdfnode = solution.get(name);
|
||||||
// logger.info("rdf node name, type: "+ name
|
// logger.info("rdf node name, type: "+ name
|
||||||
// +", "+getRDFNodeType(rdfnode));
|
// +", "+getRDFNodeType(rdfnode));
|
||||||
if (rdfnode.isLiteral()) {
|
if (rdfnode.isLiteral()) {
|
||||||
Literal literal = rdfnode.asLiteral();
|
Literal literal = rdfnode.asLiteral();
|
||||||
String nodeval = literal.getString();
|
String nodeval = literal.getString();
|
||||||
hm.put(name, nodeval);
|
hm.put(name, nodeval);
|
||||||
} else if (rdfnode.isResource()) {
|
} else if (rdfnode.isResource()) {
|
||||||
Resource resource = rdfnode.asResource();
|
Resource resource = rdfnode.asResource();
|
||||||
String nodeval = resource.toString();
|
String nodeval = resource.toString();
|
||||||
hm.put(name, nodeval);
|
hm.put(name, nodeval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resultList.add(hm);
|
resultList.add(hm);
|
||||||
}
|
}
|
||||||
description = "";
|
description = "";
|
||||||
for (HashMap map : resultList) {
|
for (HashMap map : resultList) {
|
||||||
if (map.containsKey("description")) {
|
if (map.containsKey("description")) {
|
||||||
description = (String) map.get("description");
|
description = (String) map.get("description");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
// Adding source so it is clear that this description comes from DBPedia
|
// Adding source so it is clear that this description comes from DBPedia
|
||||||
return description + descriptionSource;
|
return description + descriptionSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param uri The URI
|
* @param uri The URI
|
||||||
*/
|
*/
|
||||||
protected String stripConceptId(String uri) {
|
protected String stripConceptId(String uri) {
|
||||||
String conceptId = "";
|
String conceptId = "";
|
||||||
int lastslash = uri.lastIndexOf('/');
|
int lastslash = uri.lastIndexOf('/');
|
||||||
conceptId = uri.substring(lastslash + 1, uri.length());
|
conceptId = uri.substring(lastslash + 1, uri.length());
|
||||||
return conceptId;
|
return conceptId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param str The String
|
* @param str The String
|
||||||
*/
|
*/
|
||||||
protected String extractConceptId(String str) {
|
protected String extractConceptId(String str) {
|
||||||
try {
|
try {
|
||||||
return str.substring(1, str.length() - 1);
|
return str.substring(1, str.length() - 1);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The code here utilizes the SKOSMOS REST API for Agrovoc
|
* The code here utilizes the SKOSMOS REST API for Agrovoc
|
||||||
* This returns JSON LD so we would parse JSON instead of RDF
|
* This returns JSON LD so we would parse JSON instead of RDF
|
||||||
* The code above can still be utilized if we need to employ the web services directly
|
* The code above can still be utilized if we need to employ the web services directly
|
||||||
*/
|
*/
|
||||||
//Get search results for a particular term and language code
|
//Get search results for a particular term and language code
|
||||||
private String getSKOSMosSearchResults(String term, String lang) {
|
private String getSKOSMosSearchResults(String term, String lang) {
|
||||||
String urlEncodedTerm = URLEncoder.encode(term);
|
String urlEncodedTerm = URLEncoder.encode(term);
|
||||||
//Utilize 'starts with' using the * operator at the end
|
//Utilize 'starts with' using the * operator at the end
|
||||||
String searchUrlString = this.conceptsSkosMosSearch + "query=" + urlEncodedTerm + "*" + "&lang=" + lang;
|
String searchUrlString = this.conceptsSkosMosSearch + "query=" + urlEncodedTerm + "*" + "&lang=" + lang;
|
||||||
URL searchURL = null;
|
URL searchURL = null;
|
||||||
try {
|
try {
|
||||||
searchURL = new URL(searchUrlString);
|
searchURL = new URL(searchUrlString);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Exception occurred in instantiating URL for "
|
logger.error("Exception occurred in instantiating URL for "
|
||||||
+ searchUrlString, e);
|
+ searchUrlString, e);
|
||||||
// If the url is having trouble, just return null for the concept
|
// If the url is having trouble, just return null for the concept
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String results = null;
|
String results = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
|
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(
|
BufferedReader in = new BufferedReader(new InputStreamReader(
|
||||||
searchURL.openStream()));
|
searchURL.openStream()));
|
||||||
String inputLine;
|
String inputLine;
|
||||||
while ((inputLine = in.readLine()) != null) {
|
while ((inputLine = in.readLine()) != null) {
|
||||||
sw.write(inputLine);
|
sw.write(inputLine);
|
||||||
}
|
}
|
||||||
in.close();
|
in.close();
|
||||||
|
|
||||||
results = sw.toString();
|
results = sw.toString();
|
||||||
logger.debug(results);
|
logger.debug(results);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.error("Error occurred in getting concept from the URL "
|
logger.error("Error occurred in getting concept from the URL "
|
||||||
+ searchUrlString, ex);
|
+ searchUrlString, ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//JSON-LD array
|
//JSON-LD array
|
||||||
private List<String> getConceptURIsListFromSkosMosResult(String results) {
|
private List<String> getConceptURIsListFromSkosMosResult(String results) {
|
||||||
List<String> conceptURIs = new ArrayList<>();
|
List<String> conceptURIs = new ArrayList<>();
|
||||||
ObjectNode json = (ObjectNode) JacksonUtils.parseJson(results);
|
ObjectNode json = (ObjectNode) JacksonUtils.parseJson(results);
|
||||||
//Format should be: { ..."results":["uri":uri...]
|
//Format should be: { ..."results":["uri":uri...]
|
||||||
if (json.has("results")) {
|
if (json.has("results")) {
|
||||||
ArrayNode jsonArray = (ArrayNode) json.get("results");
|
ArrayNode jsonArray = (ArrayNode) json.get("results");
|
||||||
int numberResults = jsonArray.size();
|
int numberResults = jsonArray.size();
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < numberResults; i++) {
|
for(i = 0; i < numberResults; i++) {
|
||||||
ObjectNode jsonObject = (ObjectNode) jsonArray.get(i);
|
ObjectNode jsonObject = (ObjectNode) jsonArray.get(i);
|
||||||
if(jsonObject.has("uri")) {
|
if(jsonObject.has("uri")) {
|
||||||
conceptURIs.add(jsonObject.get("uri").asText());
|
conceptURIs.add(jsonObject.get("uri").asText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return conceptURIs;
|
return conceptURIs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,360 +1,360 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.semservices.service.impl;
|
package edu.cornell.mannlib.semservices.service.impl;
|
||||||
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
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 com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
|
||||||
import edu.cornell.mannlib.semservices.bo.Concept;
|
import edu.cornell.mannlib.semservices.bo.Concept;
|
||||||
import edu.cornell.mannlib.semservices.exceptions.ConceptsNotFoundException;
|
import edu.cornell.mannlib.semservices.exceptions.ConceptsNotFoundException;
|
||||||
import edu.cornell.mannlib.semservices.service.ExternalConceptService;
|
import edu.cornell.mannlib.semservices.service.ExternalConceptService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.json.JacksonUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.json.JacksonUtils;
|
||||||
|
|
||||||
public class GemetService implements ExternalConceptService {
|
public class GemetService implements ExternalConceptService {
|
||||||
protected final Log logger = LogFactory.getLog(getClass());
|
protected final Log logger = LogFactory.getLog(getClass());
|
||||||
private final String GemetWS_address = "https://www.eionet.europa.eu/gemet/";
|
private final String GemetWS_address = "https://www.eionet.europa.eu/gemet/";
|
||||||
private final String narrowerUri = "http://www.w3.org/2004/02/skos/core%23narrower";
|
private final String narrowerUri = "http://www.w3.org/2004/02/skos/core%23narrower";
|
||||||
private final String broaderUri = "http://www.w3.org/2004/02/skos/core%23broader";
|
private final String broaderUri = "http://www.w3.org/2004/02/skos/core%23broader";
|
||||||
private final String relatedUri = "http://www.w3.org/2004/02/skos/core%23related";
|
private final String relatedUri = "http://www.w3.org/2004/02/skos/core%23related";
|
||||||
private final String definitionUri = "http://www.w3.org/2004/02/skos/core%23definition";
|
private final String definitionUri = "http://www.w3.org/2004/02/skos/core%23definition";
|
||||||
private final String prefLabelUri = "http://www.w3.org/2004/02/skos/core%23prefLabel";
|
private final String prefLabelUri = "http://www.w3.org/2004/02/skos/core%23prefLabel";
|
||||||
private final String scopeNoteUri = "http://www.w3.org/2004/02/skos/core%23scopeNote";
|
private final String scopeNoteUri = "http://www.w3.org/2004/02/skos/core%23scopeNote";
|
||||||
private final String altLabelUri = "http://www.w3.org/2004/02/skos/core%23altLabel";
|
private final String altLabelUri = "http://www.w3.org/2004/02/skos/core%23altLabel";
|
||||||
private final String exampleUri = "http://www.w3.org/2004/02/skos/core%23example";
|
private final String exampleUri = "http://www.w3.org/2004/02/skos/core%23example";
|
||||||
private final String acronymLabelUri = "http://www.w3.org/2004/02/skos/core%23acronymLabel";
|
private final String acronymLabelUri = "http://www.w3.org/2004/02/skos/core%23acronymLabel";
|
||||||
private final String endpoint = "http://cr.eionet.europa.eu/sparql";
|
private final String endpoint = "http://cr.eionet.europa.eu/sparql";
|
||||||
private final String schemeURI = "http://www.eionet.europa.eu/gemet/gemetThesaurus";
|
private final String schemeURI = "http://www.eionet.europa.eu/gemet/gemetThesaurus";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Concept> getConcepts(String term) throws Exception {
|
public List<Concept> getConcepts(String term) throws Exception {
|
||||||
List<Concept> conceptList = new ArrayList<Concept>();
|
List<Concept> conceptList = new ArrayList<Concept>();
|
||||||
try {
|
try {
|
||||||
String results = getConceptsMatchingKeyword(term);
|
String results = getConceptsMatchingKeyword(term);
|
||||||
//System.out.println(results);
|
//System.out.println(results);
|
||||||
conceptList = processOutput(results);
|
conceptList = processOutput(results);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
return new ArrayList<Concept>();
|
return new ArrayList<Concept>();
|
||||||
//ex.printStackTrace();
|
//ex.printStackTrace();
|
||||||
//throw ex;
|
//throw ex;
|
||||||
}
|
}
|
||||||
return conceptList;
|
return conceptList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Concept> processResults(String term) throws Exception {
|
public List<Concept> processResults(String term) throws Exception {
|
||||||
List<Concept> conceptList = new ArrayList<Concept>();
|
List<Concept> conceptList = new ArrayList<Concept>();
|
||||||
try {
|
try {
|
||||||
String results = getConceptsMatchingKeyword(term);
|
String results = getConceptsMatchingKeyword(term);
|
||||||
conceptList = processOutput(results);
|
conceptList = processOutput(results);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
//ex.printStackTrace();
|
//ex.printStackTrace();
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
return conceptList;
|
return conceptList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Concept> getConceptsByURIWithSparql(String uri)
|
public List<Concept> getConceptsByURIWithSparql(String uri)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// deprecating this method...just return an empty list
|
// deprecating this method...just return an empty list
|
||||||
List<Concept> conceptList = new ArrayList<Concept>();
|
List<Concept> conceptList = new ArrayList<Concept>();
|
||||||
return conceptList;
|
return conceptList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param results Results to process
|
* @param results Results to process
|
||||||
*/
|
*/
|
||||||
private List<Concept> processOutput(String results) throws Exception {
|
private List<Concept> processOutput(String results) throws Exception {
|
||||||
|
|
||||||
List<Concept> conceptList = new ArrayList<Concept>();
|
List<Concept> conceptList = new ArrayList<Concept>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ArrayNode jsonArray = (ArrayNode) JacksonUtils.parseJson(results);
|
ArrayNode jsonArray = (ArrayNode) JacksonUtils.parseJson(results);
|
||||||
if (jsonArray.size() == 0) {
|
if (jsonArray.size() == 0) {
|
||||||
throw new ConceptsNotFoundException();
|
throw new ConceptsNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < jsonArray.size(); i++) {
|
for (int i = 0; i < jsonArray.size(); i++) {
|
||||||
Concept concept = new Concept();
|
Concept concept = new Concept();
|
||||||
concept.setDefinedBy(schemeURI);
|
concept.setDefinedBy(schemeURI);
|
||||||
concept.setBestMatch("true");
|
concept.setBestMatch("true");
|
||||||
ObjectNode json = (ObjectNode) jsonArray.get(i);
|
ObjectNode json = (ObjectNode) jsonArray.get(i);
|
||||||
String uri = getJsonValue(json, "uri");
|
String uri = getJsonValue(json, "uri");
|
||||||
|
|
||||||
concept.setUri(uri);
|
concept.setUri(uri);
|
||||||
concept.setConceptId(stripConceptId(uri));
|
concept.setConceptId(stripConceptId(uri));
|
||||||
concept.setSchemeURI(schemeURI);
|
concept.setSchemeURI(schemeURI);
|
||||||
concept.setType("");
|
concept.setType("");
|
||||||
if (json.has("preferredLabel")) {
|
if (json.has("preferredLabel")) {
|
||||||
ObjectNode preferredLabelObj = (ObjectNode) json.get("preferredLabel");
|
ObjectNode preferredLabelObj = (ObjectNode) json.get("preferredLabel");
|
||||||
if (preferredLabelObj.has("string")) {
|
if (preferredLabelObj.has("string")) {
|
||||||
concept.setLabel(getJsonValue(preferredLabelObj,
|
concept.setLabel(getJsonValue(preferredLabelObj,
|
||||||
"string"));
|
"string"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (json.has("definition")) {
|
if (json.has("definition")) {
|
||||||
ObjectNode definitionObj = (ObjectNode) json.get("definition");
|
ObjectNode definitionObj = (ObjectNode) json.get("definition");
|
||||||
if (definitionObj.has("string")) {
|
if (definitionObj.has("string")) {
|
||||||
concept.setDefinition(getJsonValue(definitionObj,
|
concept.setDefinition(getJsonValue(definitionObj,
|
||||||
"string"));
|
"string"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String narrower = getRelatedConcepts(uri, "narrower");
|
String narrower = getRelatedConcepts(uri, "narrower");
|
||||||
List<String> narrowerURIList = getRelatedUris(narrower);
|
List<String> narrowerURIList = getRelatedUris(narrower);
|
||||||
concept.setNarrowerURIList(narrowerURIList);
|
concept.setNarrowerURIList(narrowerURIList);
|
||||||
|
|
||||||
String broader = getRelatedConcepts(uri, "broader");
|
String broader = getRelatedConcepts(uri, "broader");
|
||||||
List<String> broaderURIList = getRelatedUris(broader);
|
List<String> broaderURIList = getRelatedUris(broader);
|
||||||
concept.setBroaderURIList(broaderURIList);
|
concept.setBroaderURIList(broaderURIList);
|
||||||
|
|
||||||
/*String related = getRelatedConcepts(uri, "related");
|
/*String related = getRelatedConcepts(uri, "related");
|
||||||
List<String> relatedURIList = getRelatedUris(related);
|
List<String> relatedURIList = getRelatedUris(related);
|
||||||
for (String s: relatedURIList) {
|
for (String s: relatedURIList) {
|
||||||
System.out.println("related uri: "+s);
|
System.out.println("related uri: "+s);
|
||||||
}*/
|
}*/
|
||||||
//String altLabels = getAllTranslationsForConcept(uri, "nonPreferredLabels");
|
//String altLabels = getAllTranslationsForConcept(uri, "nonPreferredLabels");
|
||||||
|
|
||||||
conceptList.add(concept);
|
conceptList.add(concept);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex ) {
|
} catch (Exception ex ) {
|
||||||
//ex.printStackTrace();
|
//ex.printStackTrace();
|
||||||
logger.error("Could not get concepts", ex);
|
logger.error("Could not get concepts", ex);
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
return conceptList;
|
return conceptList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a string from a json object or an empty string if there is no value for the given key
|
* Get a string from a json object or an empty string if there is no value for the given key
|
||||||
* @param obj JSON Object
|
* @param obj JSON Object
|
||||||
* @param key Key to retrieve
|
* @param key Key to retrieve
|
||||||
*/
|
*/
|
||||||
protected String getJsonValue(ObjectNode obj, String key) {
|
protected String getJsonValue(ObjectNode obj, String key) {
|
||||||
if (obj.has(key)) {
|
if (obj.has(key)) {
|
||||||
return obj.get(key).asText();
|
return obj.get(key).asText();
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param concept_uri Concept URI
|
* @param concept_uri Concept URI
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected String getAvailableLangs(String concept_uri) throws Exception {
|
protected String getAvailableLangs(String concept_uri) throws Exception {
|
||||||
String result = "";
|
String result = "";
|
||||||
String serviceUrl = GemetWS_address + "getAvailableLanguages" +
|
String serviceUrl = GemetWS_address + "getAvailableLanguages" +
|
||||||
"?concept_uri=" + concept_uri;
|
"?concept_uri=" + concept_uri;
|
||||||
try {
|
try {
|
||||||
result = getGemetResults(serviceUrl);
|
result = getGemetResults(serviceUrl);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param concept_uri concept URI
|
* @param concept_uri concept URI
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected String getConcept(String concept_uri) throws Exception {
|
protected String getConcept(String concept_uri) throws Exception {
|
||||||
String result = "";
|
String result = "";
|
||||||
String serviceUrl = GemetWS_address + "getConcept" +
|
String serviceUrl = GemetWS_address + "getConcept" +
|
||||||
"?concept_uri=" + concept_uri +
|
"?concept_uri=" + concept_uri +
|
||||||
"&language=en";
|
"&language=en";
|
||||||
try {
|
try {
|
||||||
result = getGemetResults(serviceUrl);
|
result = getGemetResults(serviceUrl);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param concept_uri Concept URI
|
* @param concept_uri Concept URI
|
||||||
* @param property Property
|
* @param property Property
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected String getAllTranslationsForConcept(String concept_uri, String property) throws Exception {
|
protected String getAllTranslationsForConcept(String concept_uri, String property) throws Exception {
|
||||||
String result = "";
|
String result = "";
|
||||||
String property_uri = "";
|
String property_uri = "";
|
||||||
switch (property) {
|
switch (property) {
|
||||||
case "definition":
|
case "definition":
|
||||||
property_uri = definitionUri;
|
property_uri = definitionUri;
|
||||||
break;
|
break;
|
||||||
case "preferredLabel":
|
case "preferredLabel":
|
||||||
property_uri = prefLabelUri;
|
property_uri = prefLabelUri;
|
||||||
break;
|
break;
|
||||||
case "scopeNote":
|
case "scopeNote":
|
||||||
property_uri = scopeNoteUri;
|
property_uri = scopeNoteUri;
|
||||||
break;
|
break;
|
||||||
case "nonPreferredLabels":
|
case "nonPreferredLabels":
|
||||||
property_uri = altLabelUri;
|
property_uri = altLabelUri;
|
||||||
break;
|
break;
|
||||||
case "example":
|
case "example":
|
||||||
property_uri = exampleUri;
|
property_uri = exampleUri;
|
||||||
break;
|
break;
|
||||||
case "acronymLabel":
|
case "acronymLabel":
|
||||||
property_uri = acronymLabelUri;
|
property_uri = acronymLabelUri;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
String serviceUrl = GemetWS_address + "getAllTranslationsForConcept" +
|
String serviceUrl = GemetWS_address + "getAllTranslationsForConcept" +
|
||||||
"?concept_uri=" + concept_uri +
|
"?concept_uri=" + concept_uri +
|
||||||
"&property_uri=" + property_uri +
|
"&property_uri=" + property_uri +
|
||||||
"&language=en";
|
"&language=en";
|
||||||
try {
|
try {
|
||||||
result = getGemetResults(serviceUrl);
|
result = getGemetResults(serviceUrl);
|
||||||
List<String> props = getPropertyFromJson(result);
|
List<String> props = getPropertyFromJson(result);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param concept_uri Concept URI
|
* @param concept_uri Concept URI
|
||||||
* @param relation Relations
|
* @param relation Relations
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected String getRelatedConcepts(String concept_uri, String relation) throws Exception {
|
protected String getRelatedConcepts(String concept_uri, String relation) throws Exception {
|
||||||
String result = "";
|
String result = "";
|
||||||
String relation_uri = "";
|
String relation_uri = "";
|
||||||
switch (relation) {
|
switch (relation) {
|
||||||
case "broader":
|
case "broader":
|
||||||
relation_uri = broaderUri;
|
relation_uri = broaderUri;
|
||||||
break;
|
break;
|
||||||
case "narrower":
|
case "narrower":
|
||||||
relation_uri = narrowerUri;
|
relation_uri = narrowerUri;
|
||||||
break;
|
break;
|
||||||
case "related":
|
case "related":
|
||||||
relation_uri = relatedUri;
|
relation_uri = relatedUri;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
String serviceUrl = GemetWS_address + "getRelatedConcepts" +
|
String serviceUrl = GemetWS_address + "getRelatedConcepts" +
|
||||||
"?concept_uri=" + concept_uri +
|
"?concept_uri=" + concept_uri +
|
||||||
"&relation_uri=" + relation_uri +
|
"&relation_uri=" + relation_uri +
|
||||||
"&language=en";
|
"&language=en";
|
||||||
try {
|
try {
|
||||||
result = getGemetResults(serviceUrl);
|
result = getGemetResults(serviceUrl);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param keyword Keyword
|
* @param keyword Keyword
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected String getConceptsMatchingKeyword(String keyword) throws Exception {
|
protected String getConceptsMatchingKeyword(String keyword) throws Exception {
|
||||||
String result = "";
|
String result = "";
|
||||||
String encodedKeyword = URLEncoder.encode(keyword, "UTF-8");
|
String encodedKeyword = URLEncoder.encode(keyword, "UTF-8");
|
||||||
String serviceUrl = GemetWS_address + "getConceptsMatchingKeyword" +
|
String serviceUrl = GemetWS_address + "getConceptsMatchingKeyword" +
|
||||||
"?keyword=" + encodedKeyword +
|
"?keyword=" + encodedKeyword +
|
||||||
"&search_mode=0" +
|
"&search_mode=0" +
|
||||||
"&thesaurus_uri=http://www.eionet.europa.eu/gemet/concept/" +
|
"&thesaurus_uri=http://www.eionet.europa.eu/gemet/concept/" +
|
||||||
"&language=en";
|
"&language=en";
|
||||||
try {
|
try {
|
||||||
result = getGemetResults(serviceUrl);
|
result = getGemetResults(serviceUrl);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param url URI
|
* @param url URI
|
||||||
*/
|
*/
|
||||||
protected String getGemetResults(String url) throws Exception {
|
protected String getGemetResults(String url) throws Exception {
|
||||||
String results = "";
|
String results = "";
|
||||||
//System.out.println("url: "+url);
|
//System.out.println("url: "+url);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
URL serviceUrl = new URL(url);
|
URL serviceUrl = new URL(url);
|
||||||
|
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(serviceUrl.openStream()));
|
BufferedReader in = new BufferedReader(new InputStreamReader(serviceUrl.openStream()));
|
||||||
String inputLine;
|
String inputLine;
|
||||||
while ((inputLine = in.readLine()) != null) {
|
while ((inputLine = in.readLine()) != null) {
|
||||||
sw.write(inputLine);
|
sw.write(inputLine);
|
||||||
}
|
}
|
||||||
in.close();
|
in.close();
|
||||||
|
|
||||||
results = sw.toString();
|
results = sw.toString();
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.error("error occurred in servlet", ex);
|
logger.error("error occurred in servlet", ex);
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected List<String> getRelatedUris(String json) {
|
protected List<String> getRelatedUris(String json) {
|
||||||
List<String> uriList = new ArrayList<String>();
|
List<String> uriList = new ArrayList<String>();
|
||||||
String uri = "";
|
String uri = "";
|
||||||
ArrayNode jsonArray = (ArrayNode) JacksonUtils.parseJson(json);
|
ArrayNode jsonArray = (ArrayNode) JacksonUtils.parseJson(json);
|
||||||
if (jsonArray.size() == 0) {
|
if (jsonArray.size() == 0) {
|
||||||
return new ArrayList<String>();
|
return new ArrayList<String>();
|
||||||
}
|
}
|
||||||
for (int i = 0; i < jsonArray.size(); i++) {
|
for (int i = 0; i < jsonArray.size(); i++) {
|
||||||
ObjectNode jsonObj = (ObjectNode) jsonArray.get(i);
|
ObjectNode jsonObj = (ObjectNode) jsonArray.get(i);
|
||||||
uri = getJsonValue(jsonObj, "uri");
|
uri = getJsonValue(jsonObj, "uri");
|
||||||
uriList.add(uri);
|
uriList.add(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
return uriList;
|
return uriList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<String> getPropertyFromJson(String json) {
|
protected List<String> getPropertyFromJson(String json) {
|
||||||
List<String> props = new ArrayList<String>();
|
List<String> props = new ArrayList<String>();
|
||||||
ArrayNode jsonArray = (ArrayNode) JacksonUtils.parseJson(json);
|
ArrayNode jsonArray = (ArrayNode) JacksonUtils.parseJson(json);
|
||||||
if (jsonArray.size() == 0) {
|
if (jsonArray.size() == 0) {
|
||||||
return new ArrayList<String>();
|
return new ArrayList<String>();
|
||||||
}
|
}
|
||||||
for (int i = 0; i < jsonArray.size(); i++) {
|
for (int i = 0; i < jsonArray.size(); i++) {
|
||||||
System.out.println((jsonArray.get(i)).toString());
|
System.out.println((jsonArray.get(i)).toString());
|
||||||
}
|
}
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String stripConceptId(String uri) {
|
protected String stripConceptId(String uri) {
|
||||||
String conceptId = "";
|
String conceptId = "";
|
||||||
int lastslash = uri.lastIndexOf('/');
|
int lastslash = uri.lastIndexOf('/');
|
||||||
conceptId = uri.substring(lastslash + 1, uri.length());
|
conceptId = uri.substring(lastslash + 1, uri.length());
|
||||||
return conceptId;
|
return conceptId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class LCSHService implements ExternalConceptService {
|
||||||
private final String schemeUri = hostUri + "/authorities/subjects";
|
private final String schemeUri = hostUri + "/authorities/subjects";
|
||||||
private final String baseUri = hostUri + "/search/";
|
private final String baseUri = hostUri + "/search/";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Concept> getConcepts(String term) throws Exception {
|
public List<Concept> getConcepts(String term) throws Exception {
|
||||||
List<Concept> conceptList = new ArrayList<Concept>();
|
List<Concept> conceptList = new ArrayList<Concept>();
|
||||||
|
@ -111,19 +111,19 @@ public class LCSHService implements ExternalConceptService {
|
||||||
conceptList.add(c);
|
conceptList.add(c);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
}
|
}
|
||||||
return conceptList;
|
return conceptList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Load individual concept using a request
|
//Load individual concept using a request
|
||||||
//private
|
//private
|
||||||
|
|
||||||
public Concept createConcept(String bestMatch, String conceptURLString, String skosConceptURI) {
|
public Concept createConcept(String bestMatch, String conceptURLString, String skosConceptURI) {
|
||||||
|
|
||||||
Concept concept = new Concept();
|
Concept concept = new Concept();
|
||||||
|
|
||||||
log.debug("SKOSConceptURI is " + skosConceptURI);
|
log.debug("SKOSConceptURI is " + skosConceptURI);
|
||||||
// get skos version of uri
|
// get skos version of uri
|
||||||
|
|
||||||
|
@ -133,31 +133,31 @@ public class LCSHService implements ExternalConceptService {
|
||||||
concept.setDefinedBy(schemeUri);
|
concept.setDefinedBy(schemeUri);
|
||||||
concept.setSchemeURI(schemeUri);
|
concept.setSchemeURI(schemeUri);
|
||||||
concept.setType("");
|
concept.setType("");
|
||||||
|
|
||||||
//Utilize the XML directly instead of the SKOS API
|
//Utilize the XML directly instead of the SKOS API
|
||||||
try {
|
try {
|
||||||
//LCSH doesn't need a language tag right now as results in english
|
//LCSH doesn't need a language tag right now as results in english
|
||||||
//Also want to add skos notes as definition
|
//Also want to add skos notes as definition
|
||||||
concept = SKOSUtils.createConceptUsingXMLFromURL(concept, conceptURLString, null, true);
|
concept = SKOSUtils.createConceptUsingXMLFromURL(concept, conceptURLString, null, true);
|
||||||
|
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
log.debug("Error occurred for annotation retrieval for skos concept " + skosConceptURI, ex);
|
log.debug("Error occurred for annotation retrieval for skos concept " + skosConceptURI, ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return concept;
|
return concept;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String getSKOSURL(String uri) {
|
private String getSKOSURL(String uri) {
|
||||||
String skosURI = uri + skosSuffix;
|
String skosURI = uri + skosSuffix;
|
||||||
|
|
||||||
return skosURI;
|
return skosURI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public List<String> getConceptURISFromJSON(String results) {
|
public List<String> getConceptURISFromJSON(String results) {
|
||||||
List<String> uris = new ArrayList<String>();
|
List<String> uris = new ArrayList<String>();
|
||||||
|
@ -197,7 +197,7 @@ public class LCSHService implements ExternalConceptService {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("concept uri is " + conceptUri);
|
log.debug("concept uri is " + conceptUri);
|
||||||
uris.add(conceptUri);
|
uris.add(conceptUri);
|
||||||
}
|
}
|
||||||
|
@ -241,6 +241,6 @@ public class LCSHService implements ExternalConceptService {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,229 +1,229 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.semservices.service.impl;
|
package edu.cornell.mannlib.semservices.service.impl;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
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 com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
|
||||||
import edu.cornell.mannlib.semservices.bo.Concept;
|
import edu.cornell.mannlib.semservices.bo.Concept;
|
||||||
import edu.cornell.mannlib.semservices.exceptions.ConceptsNotFoundException;
|
import edu.cornell.mannlib.semservices.exceptions.ConceptsNotFoundException;
|
||||||
import edu.cornell.mannlib.semservices.service.ExternalConceptService;
|
import edu.cornell.mannlib.semservices.service.ExternalConceptService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.json.JacksonUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.json.JacksonUtils;
|
||||||
import org.apache.http.HttpVersion;
|
import org.apache.http.HttpVersion;
|
||||||
import org.apache.http.client.fluent.Form;
|
import org.apache.http.client.fluent.Form;
|
||||||
import org.apache.http.client.fluent.Request;
|
import org.apache.http.client.fluent.Request;
|
||||||
import org.apache.http.client.utils.URIBuilder;
|
import org.apache.http.client.utils.URIBuilder;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jaf30
|
* @author jaf30
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class UMLSService implements ExternalConceptService {
|
public class UMLSService implements ExternalConceptService {
|
||||||
protected final Log logger = LogFactory.getLog(getClass());
|
protected final Log logger = LogFactory.getLog(getClass());
|
||||||
|
|
||||||
private static String UTS_REST_API_URL = "https://uts-ws.nlm.nih.gov/rest";
|
private static String UTS_REST_API_URL = "https://uts-ws.nlm.nih.gov/rest";
|
||||||
private static String SEARCH_PATH = "/search/current";
|
private static String SEARCH_PATH = "/search/current";
|
||||||
private static String SEARCH_PARAMETER = "string";
|
private static String SEARCH_PARAMETER = "string";
|
||||||
private static String SEARCH_TYPE_PARAMETER = "searchType";
|
private static String SEARCH_TYPE_PARAMETER = "searchType";
|
||||||
private static String SEARCH_TYPE = "rightTruncation";
|
private static String SEARCH_TYPE = "rightTruncation";
|
||||||
private static String PAGE_SIZE_PARAMETER = "pageSize";
|
private static String PAGE_SIZE_PARAMETER = "pageSize";
|
||||||
private static String RETURN_TYPE_PARAMETER = "returnIdType";
|
private static String RETURN_TYPE_PARAMETER = "returnIdType";
|
||||||
private static String RETURN_TYPE = "concept";
|
private static String RETURN_TYPE = "concept";
|
||||||
private static String TICKET_PARAMETER = "ticket";
|
private static String TICKET_PARAMETER = "ticket";
|
||||||
|
|
||||||
private static String ticketGrantingTicketURL = null;
|
private static String ticketGrantingTicketURL = null;
|
||||||
|
|
||||||
private static long lastUpdate = -1;
|
private static long lastUpdate = -1;
|
||||||
|
|
||||||
private static String username = null;
|
private static String username = null;
|
||||||
private static String password = null;
|
private static String password = null;
|
||||||
private static String apikey = null;
|
private static String apikey = null;
|
||||||
|
|
||||||
private static String pageSize = "50";
|
private static String pageSize = "50";
|
||||||
|
|
||||||
private static String UMLS_AUTH_USER_URL = "https://utslogin.nlm.nih.gov/cas/v1/tickets";
|
private static String UMLS_AUTH_USER_URL = "https://utslogin.nlm.nih.gov/cas/v1/tickets";
|
||||||
private static String UMLS_AUTH_KEY_URL = "https://utslogin.nlm.nih.gov/cas/v1/api-key";
|
private static String UMLS_AUTH_KEY_URL = "https://utslogin.nlm.nih.gov/cas/v1/api-key";
|
||||||
private static String UTS_SERVICE_URL = "http://umlsks.nlm.nih.gov";
|
private static String UTS_SERVICE_URL = "http://umlsks.nlm.nih.gov";
|
||||||
|
|
||||||
{
|
{
|
||||||
if (username == null || apikey == null) {
|
if (username == null || apikey == null) {
|
||||||
final Properties properties = new Properties();
|
final Properties properties = new Properties();
|
||||||
try (InputStream stream = getClass().getResourceAsStream("/umls.properties")) {
|
try (InputStream stream = getClass().getResourceAsStream("/umls.properties")) {
|
||||||
properties.load(stream);
|
properties.load(stream);
|
||||||
username = properties.getProperty("username");
|
username = properties.getProperty("username");
|
||||||
password = properties.getProperty("password");
|
password = properties.getProperty("password");
|
||||||
apikey = properties.getProperty("apikey");
|
apikey = properties.getProperty("apikey");
|
||||||
|
|
||||||
String exPageSize = properties.getProperty("pagesize");
|
String exPageSize = properties.getProperty("pagesize");
|
||||||
try {
|
try {
|
||||||
if (!StringUtils.isEmpty(exPageSize)) {
|
if (!StringUtils.isEmpty(exPageSize)) {
|
||||||
int iPageSize = Integer.parseInt(exPageSize, 10);
|
int iPageSize = Integer.parseInt(exPageSize, 10);
|
||||||
if (iPageSize > 5 && iPageSize < 200) {
|
if (iPageSize > 5 && iPageSize < 200) {
|
||||||
pageSize = Integer.toString(iPageSize, 10);
|
pageSize = Integer.toString(iPageSize, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConfigured() {
|
public boolean isConfigured() {
|
||||||
return !(StringUtils.isEmpty(username) && StringUtils.isEmpty(apikey));
|
return !(StringUtils.isEmpty(username) && StringUtils.isEmpty(apikey));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Concept> getConcepts(String term) throws Exception {
|
public List<Concept> getConcepts(String term) throws Exception {
|
||||||
String ticket = getSingleUseTicket();
|
String ticket = getSingleUseTicket();
|
||||||
|
|
||||||
List<Concept> conceptList = new ArrayList<Concept>();
|
List<Concept> conceptList = new ArrayList<Concept>();
|
||||||
|
|
||||||
String results = null;
|
String results = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
URIBuilder b = new URIBuilder(UTS_REST_API_URL + SEARCH_PATH);
|
URIBuilder b = new URIBuilder(UTS_REST_API_URL + SEARCH_PATH);
|
||||||
b.addParameter(SEARCH_PARAMETER, term);
|
b.addParameter(SEARCH_PARAMETER, term);
|
||||||
b.addParameter(RETURN_TYPE_PARAMETER, RETURN_TYPE);
|
b.addParameter(RETURN_TYPE_PARAMETER, RETURN_TYPE);
|
||||||
b.addParameter(SEARCH_TYPE_PARAMETER, SEARCH_TYPE);
|
b.addParameter(SEARCH_TYPE_PARAMETER, SEARCH_TYPE);
|
||||||
b.addParameter(PAGE_SIZE_PARAMETER, pageSize);
|
b.addParameter(PAGE_SIZE_PARAMETER, pageSize);
|
||||||
b.addParameter(TICKET_PARAMETER, ticket);
|
b.addParameter(TICKET_PARAMETER, ticket);
|
||||||
|
|
||||||
results = Request.Get(b.build())
|
results = Request.Get(b.build())
|
||||||
.connectTimeout(3000)
|
.connectTimeout(3000)
|
||||||
.socketTimeout(3000)
|
.socketTimeout(3000)
|
||||||
.execute().returnContent().asString();
|
.execute().returnContent().asString();
|
||||||
|
|
||||||
conceptList = processOutput(results);
|
conceptList = processOutput(results);
|
||||||
return conceptList;
|
return conceptList;
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.error("error occurred in servlet", ex);
|
logger.error("error occurred in servlet", ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Concept> processResults(String term) throws Exception {
|
public List<Concept> processResults(String term) throws Exception {
|
||||||
return getConcepts(term);
|
return getConcepts(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param uri URI
|
* @param uri URI
|
||||||
*/
|
*/
|
||||||
public List<Concept> getConceptsByURIWithSparql(String uri) throws Exception {
|
public List<Concept> getConceptsByURIWithSparql(String uri) throws Exception {
|
||||||
// deprecating this method...just return an empty list
|
// deprecating this method...just return an empty list
|
||||||
List<Concept> conceptList = new ArrayList<Concept>();
|
List<Concept> conceptList = new ArrayList<Concept>();
|
||||||
return conceptList;
|
return conceptList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param results Results to process
|
* @param results Results to process
|
||||||
*/
|
*/
|
||||||
private List<Concept> processOutput(String results) throws Exception {
|
private List<Concept> processOutput(String results) throws Exception {
|
||||||
List<Concept> conceptList = new ArrayList<Concept>();
|
List<Concept> conceptList = new ArrayList<Concept>();
|
||||||
List<String> bestMatchIdList = new ArrayList<String>();
|
List<String> bestMatchIdList = new ArrayList<String>();
|
||||||
String bestMatchId = "";
|
String bestMatchId = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ObjectNode json = (ObjectNode) JacksonUtils.parseJson(results);
|
ObjectNode json = (ObjectNode) JacksonUtils.parseJson(results);
|
||||||
ArrayNode allArray = (ArrayNode) json.get("result").get("results");
|
ArrayNode allArray = (ArrayNode) json.get("result").get("results");
|
||||||
int len = allArray.size();
|
int len = allArray.size();
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
ObjectNode o = (ObjectNode) allArray.get(i);
|
ObjectNode o = (ObjectNode) allArray.get(i);
|
||||||
|
|
||||||
Concept concept = new Concept();
|
Concept concept = new Concept();
|
||||||
concept.setDefinedBy(UTS_SERVICE_URL);
|
concept.setDefinedBy(UTS_SERVICE_URL);
|
||||||
concept.setSchemeURI(UTS_SERVICE_URL);
|
concept.setSchemeURI(UTS_SERVICE_URL);
|
||||||
|
|
||||||
concept.setType(RETURN_TYPE);
|
concept.setType(RETURN_TYPE);
|
||||||
concept.setConceptId(getJsonValue(o, "ui"));
|
concept.setConceptId(getJsonValue(o, "ui"));
|
||||||
concept.setLabel(getJsonValue(o, "name"));
|
concept.setLabel(getJsonValue(o, "name"));
|
||||||
concept.setUri(getJsonValue(o, "uri"));
|
concept.setUri(getJsonValue(o, "uri"));
|
||||||
|
|
||||||
concept.setBestMatch("false");
|
concept.setBestMatch("false");
|
||||||
conceptList.add(concept);
|
conceptList.add(concept);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
logger.error("Could not get concepts", ex);
|
logger.error("Could not get concepts", ex);
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conceptList.size() == 0) {
|
if (conceptList.size() == 0) {
|
||||||
throw new ConceptsNotFoundException();
|
throw new ConceptsNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
return conceptList;
|
return conceptList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a string from a json object or an empty string if there is no value for the given key
|
* Get a string from a json object or an empty string if there is no value for the given key
|
||||||
*
|
*
|
||||||
* @param obj JSON Object
|
* @param obj JSON Object
|
||||||
* @param key Key to retrieve
|
* @param key Key to retrieve
|
||||||
*/
|
*/
|
||||||
protected String getJsonValue(ObjectNode obj, String key) {
|
protected String getJsonValue(ObjectNode obj, String key) {
|
||||||
if (obj.has(key)) {
|
if (obj.has(key)) {
|
||||||
return obj.get(key).asText();
|
return obj.get(key).asText();
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected String stripConceptId(String uri) {
|
protected String stripConceptId(String uri) {
|
||||||
String conceptId = "";
|
String conceptId = "";
|
||||||
int lastslash = uri.lastIndexOf('/');
|
int lastslash = uri.lastIndexOf('/');
|
||||||
conceptId = uri.substring(lastslash + 1, uri.length());
|
conceptId = uri.substring(lastslash + 1, uri.length());
|
||||||
return conceptId;
|
return conceptId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void getTicketGrantingTicket() {
|
private synchronized void getTicketGrantingTicket() {
|
||||||
if (StringUtils.isEmpty(username) && StringUtils.isEmpty(apikey)) {
|
if (StringUtils.isEmpty(username) && StringUtils.isEmpty(apikey)) {
|
||||||
throw new IllegalStateException("Unable to read umls.properties");
|
throw new IllegalStateException("Unable to read umls.properties");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ticketGrantingTicketURL == null || lastUpdate + 28700000L < System.currentTimeMillis()) {
|
if (ticketGrantingTicketURL == null || lastUpdate + 28700000L < System.currentTimeMillis()) {
|
||||||
try {
|
try {
|
||||||
if (!StringUtils.isEmpty(apikey)) {
|
if (!StringUtils.isEmpty(apikey)) {
|
||||||
ticketGrantingTicketURL = Request.Post(UMLS_AUTH_KEY_URL).useExpectContinue().version(HttpVersion.HTTP_1_1)
|
ticketGrantingTicketURL = Request.Post(UMLS_AUTH_KEY_URL).useExpectContinue().version(HttpVersion.HTTP_1_1)
|
||||||
.bodyForm(Form.form().add("apikey", apikey).build())
|
.bodyForm(Form.form().add("apikey", apikey).build())
|
||||||
.execute().returnResponse().getFirstHeader("location").getValue();
|
.execute().returnResponse().getFirstHeader("location").getValue();
|
||||||
} else {
|
} else {
|
||||||
ticketGrantingTicketURL = Request.Post(UMLS_AUTH_USER_URL).useExpectContinue().version(HttpVersion.HTTP_1_1)
|
ticketGrantingTicketURL = Request.Post(UMLS_AUTH_USER_URL).useExpectContinue().version(HttpVersion.HTTP_1_1)
|
||||||
.bodyForm(Form.form().add("username", username).add("password", password).build())
|
.bodyForm(Form.form().add("username", username).add("password", password).build())
|
||||||
.execute().returnResponse().getFirstHeader("location").getValue();
|
.execute().returnResponse().getFirstHeader("location").getValue();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException("Unable to get ticket granting ticket.");
|
throw new IllegalStateException("Unable to get ticket granting ticket.");
|
||||||
}
|
}
|
||||||
lastUpdate = System.currentTimeMillis();
|
lastUpdate = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSingleUseTicket() {
|
private String getSingleUseTicket() {
|
||||||
getTicketGrantingTicket();
|
getTicketGrantingTicket();
|
||||||
String ticket = "";
|
String ticket = "";
|
||||||
try {
|
try {
|
||||||
ticket = Request.Post(ticketGrantingTicketURL).useExpectContinue().version(HttpVersion.HTTP_1_1)
|
ticket = Request.Post(ticketGrantingTicketURL).useExpectContinue().version(HttpVersion.HTTP_1_1)
|
||||||
.bodyForm(Form.form().add("service", UTS_SERVICE_URL).build())
|
.bodyForm(Form.form().add("service", UTS_SERVICE_URL).build())
|
||||||
.execute().returnContent().asString();
|
.execute().returnContent().asString();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException("Unable to get ticket.");
|
throw new IllegalStateException("Unable to get ticket.");
|
||||||
}
|
}
|
||||||
return ticket;
|
return ticket;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller;
|
package edu.cornell.mannlib.vitro.webapp.controller;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -18,7 +18,7 @@ import javax.servlet.annotation.WebServlet;
|
||||||
|
|
||||||
@WebServlet(name = "AboutQrCodesController", urlPatterns = {"/qrcode/about"})
|
@WebServlet(name = "AboutQrCodesController", urlPatterns = {"/qrcode/about"})
|
||||||
public class AboutQrCodesController extends FreemarkerHttpServlet {
|
public class AboutQrCodesController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static final Log log = LogFactory.getLog(ExportQrCodeController.class);
|
private static final Log log = LogFactory.getLog(ExportQrCodeController.class);
|
||||||
private static final String TEMPLATE_DEFAULT = "aboutQrCodes.ftl";
|
private static final String TEMPLATE_DEFAULT = "aboutQrCodes.ftl";
|
||||||
|
@ -27,7 +27,7 @@ public class AboutQrCodesController extends FreemarkerHttpServlet {
|
||||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||||
try {
|
try {
|
||||||
Map<String, Object> body = new HashMap<String, Object>();
|
Map<String, Object> body = new HashMap<String, Object>();
|
||||||
|
|
||||||
return new TemplateResponseValues(TEMPLATE_DEFAULT, body);
|
return new TemplateResponseValues(TEMPLATE_DEFAULT, body);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller;
|
package edu.cornell.mannlib.vitro.webapp.controller;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -31,7 +31,7 @@ import javax.servlet.annotation.WebServlet;
|
||||||
|
|
||||||
@WebServlet(name = "ExportQrCodeController", urlPatterns = {"/qrcode"})
|
@WebServlet(name = "ExportQrCodeController", urlPatterns = {"/qrcode"})
|
||||||
public class ExportQrCodeController extends FreemarkerHttpServlet {
|
public class ExportQrCodeController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static final Log log = LogFactory.getLog(ExportQrCodeController.class);
|
private static final Log log = LogFactory.getLog(ExportQrCodeController.class);
|
||||||
private static final String TEMPLATE_DEFAULT = "foaf-person--exportQrCode.ftl";
|
private static final String TEMPLATE_DEFAULT = "foaf-person--exportQrCode.ftl";
|
||||||
|
@ -61,12 +61,12 @@ public class ExportQrCodeController extends FreemarkerHttpServlet {
|
||||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||||
try {
|
try {
|
||||||
Individual individual = getIndividualFromRequest(vreq);
|
Individual individual = getIndividualFromRequest(vreq);
|
||||||
|
|
||||||
qrData = generateQrData(individual, vreq);
|
qrData = generateQrData(individual, vreq);
|
||||||
|
|
||||||
DefaultObjectWrapper wrapper = new DefaultObjectWrapper();
|
DefaultObjectWrapper wrapper = new DefaultObjectWrapper();
|
||||||
wrapper.setExposureLevel(BeansWrapper.EXPOSE_SAFE);
|
wrapper.setExposureLevel(BeansWrapper.EXPOSE_SAFE);
|
||||||
|
|
||||||
Map<String, Object> body = new HashMap<String, Object>();
|
Map<String, Object> body = new HashMap<String, Object>();
|
||||||
body.put("individual", wrapper.wrap(IndividualTemplateModelBuilder.build(individual, vreq)));
|
body.put("individual", wrapper.wrap(IndividualTemplateModelBuilder.build(individual, vreq)));
|
||||||
body.put("qrData", qrData);
|
body.put("qrData", qrData);
|
||||||
|
@ -94,7 +94,7 @@ public class ExportQrCodeController extends FreemarkerHttpServlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> generateQrData(Individual individual, VitroRequest vreq) {
|
private Map<String, String> generateQrData(Individual individual, VitroRequest vreq) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String firstName = "";
|
String firstName = "";
|
||||||
String lastName = "";
|
String lastName = "";
|
||||||
|
@ -106,7 +106,7 @@ public class ExportQrCodeController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
Map<String,String> qrData = new HashMap<String,String>();
|
Map<String,String> qrData = new HashMap<String,String>();
|
||||||
|
|
||||||
for (Map<String, String> map: vcardData) {
|
for (Map<String, String> map: vcardData) {
|
||||||
firstName = map.get("firstName");
|
firstName = map.get("firstName");
|
||||||
lastName = map.get("lastName");
|
lastName = map.get("lastName");
|
||||||
preferredTitle = map.get("title");
|
preferredTitle = map.get("title");
|
||||||
|
@ -128,13 +128,13 @@ public class ExportQrCodeController extends FreemarkerHttpServlet {
|
||||||
String tempUrl = vreq.getRequestURL().toString();
|
String tempUrl = vreq.getRequestURL().toString();
|
||||||
String prefix = "http://";
|
String prefix = "http://";
|
||||||
tempUrl = tempUrl.substring(0, tempUrl.replace(prefix, "").indexOf("/") + prefix.length());
|
tempUrl = tempUrl.substring(0, tempUrl.replace(prefix, "").indexOf("/") + prefix.length());
|
||||||
String externalUrl = tempUrl ;
|
String externalUrl = tempUrl ;
|
||||||
qrData.put("externalUrl", externalUrl);
|
qrData.put("externalUrl", externalUrl);
|
||||||
|
|
||||||
String individualUri = individual.getURI();
|
String individualUri = individual.getURI();
|
||||||
String contextPath = vreq.getContextPath();
|
String contextPath = vreq.getContextPath();
|
||||||
qrData.put("exportQrCodeUrl", contextPath + "/qrcode?uri=" + UrlBuilder.urlEncode(individualUri));
|
qrData.put("exportQrCodeUrl", contextPath + "/qrcode?uri=" + UrlBuilder.urlEncode(individualUri));
|
||||||
|
|
||||||
qrData.put("aboutQrCodesUrl", contextPath + "/qrcode/about");
|
qrData.put("aboutQrCodesUrl", contextPath + "/qrcode/about");
|
||||||
return qrData;
|
return qrData;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -155,8 +155,8 @@ public class ExportQrCodeController extends FreemarkerHttpServlet {
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return vcardData;
|
return vcardData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class GeoFocusMapLocations extends AbstractAjaxResponder {
|
||||||
private static String GEO_FOCUS_QUERY = ""
|
private static String GEO_FOCUS_QUERY = ""
|
||||||
+ "PREFIX geo: <http://aims.fao.org/aos/geopolitical.owl#> \n"
|
+ "PREFIX geo: <http://aims.fao.org/aos/geopolitical.owl#> \n"
|
||||||
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
||||||
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
|
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
|
||||||
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
|
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
|
||||||
+ "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n"
|
+ "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n"
|
||||||
+ "PREFIX vivoc: <http://vivo.library.cornell.edu/ns/0.1#> \n"
|
+ "PREFIX vivoc: <http://vivo.library.cornell.edu/ns/0.1#> \n"
|
||||||
|
@ -52,7 +52,7 @@ public class GeoFocusMapLocations extends AbstractAjaxResponder {
|
||||||
+ " ?person rdf:type foaf:Person \n"
|
+ " ?person rdf:type foaf:Person \n"
|
||||||
+ "} } \n"
|
+ "} } \n"
|
||||||
+ "GROUP BY ?label ?location \n";
|
+ "GROUP BY ?label ?location \n";
|
||||||
|
|
||||||
public GeoFocusMapLocations(HttpServlet parent, VitroRequest vreq,
|
public GeoFocusMapLocations(HttpServlet parent, VitroRequest vreq,
|
||||||
HttpServletResponse resp) {
|
HttpServletResponse resp) {
|
||||||
super(parent, vreq, resp);
|
super(parent, vreq, resp);
|
||||||
|
@ -62,12 +62,12 @@ public class GeoFocusMapLocations extends AbstractAjaxResponder {
|
||||||
public String prepareResponse() throws IOException {
|
public String prepareResponse() throws IOException {
|
||||||
try {
|
try {
|
||||||
geoLocations = getGeoLocations(vreq);
|
geoLocations = getGeoLocations(vreq);
|
||||||
|
|
||||||
StringBuilder response = new StringBuilder("[");
|
StringBuilder response = new StringBuilder("[");
|
||||||
String geometry = "{\"geometry\": {\"type\": \"Point\",\"coordinates\": \"\"},";
|
String geometry = "{\"geometry\": {\"type\": \"Point\",\"coordinates\": \"\"},";
|
||||||
String typeProps = "\"type\": \"Feature\",\"properties\": {\"mapType\": \"\",";
|
String typeProps = "\"type\": \"Feature\",\"properties\": {\"mapType\": \"\",";
|
||||||
String previousLabel = "";
|
String previousLabel = "";
|
||||||
|
|
||||||
for (Map<String, String> map: geoLocations) {
|
for (Map<String, String> map: geoLocations) {
|
||||||
String label = map.get("label");
|
String label = map.get("label");
|
||||||
String html = map.get("count");
|
String html = map.get("count");
|
||||||
|
@ -79,7 +79,7 @@ public class GeoFocusMapLocations extends AbstractAjaxResponder {
|
||||||
Integer count = Integer.parseInt(map.get("count"));
|
Integer count = Integer.parseInt(map.get("count"));
|
||||||
String radius = String.valueOf(calculateRadius(count));
|
String radius = String.valueOf(calculateRadius(count));
|
||||||
String name = "";
|
String name = "";
|
||||||
|
|
||||||
if ( label != null && !label.equals(previousLabel) ) {
|
if ( label != null && !label.equals(previousLabel) ) {
|
||||||
if ( label.contains("Ivoire") ) {
|
if ( label.contains("Ivoire") ) {
|
||||||
name = "Ivory Coast";
|
name = "Ivory Coast";
|
||||||
|
@ -94,18 +94,18 @@ public class GeoFocusMapLocations extends AbstractAjaxResponder {
|
||||||
name = label;
|
name = label;
|
||||||
}
|
}
|
||||||
String tempStr = geometry; //+label
|
String tempStr = geometry; //+label
|
||||||
tempStr += typeProps //+ label
|
tempStr += typeProps //+ label
|
||||||
+ "\"popupContent\": \""
|
+ "\"popupContent\": \""
|
||||||
+ name
|
+ name
|
||||||
+ "\",\"html\":"
|
+ "\",\"html\":"
|
||||||
+ html
|
+ html
|
||||||
+ ",\"radius\":"
|
+ ",\"radius\":"
|
||||||
+ radius
|
+ radius
|
||||||
+ ",\"uri\": \""
|
+ ",\"uri\": \""
|
||||||
+ uri
|
+ uri
|
||||||
+ "\",\"local\": \""
|
+ "\",\"local\": \""
|
||||||
+ local
|
+ local
|
||||||
+ "\"}},";
|
+ "\"}},";
|
||||||
response.append(tempStr);
|
response.append(tempStr);
|
||||||
previousLabel = label;
|
previousLabel = label;
|
||||||
}
|
}
|
||||||
|
@ -123,9 +123,9 @@ public class GeoFocusMapLocations extends AbstractAjaxResponder {
|
||||||
return EMPTY_RESPONSE;
|
return EMPTY_RESPONSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Map<String,String>> getGeoLocations(VitroRequest vreq) {
|
private List<Map<String,String>> getGeoLocations(VitroRequest vreq) {
|
||||||
|
|
||||||
String queryStr = GEO_FOCUS_QUERY;
|
String queryStr = GEO_FOCUS_QUERY;
|
||||||
log.debug("queryStr = " + queryStr);
|
log.debug("queryStr = " + queryStr);
|
||||||
List<Map<String,String>> locations = new ArrayList<Map<String,String>>();
|
List<Map<String,String>> locations = new ArrayList<Map<String,String>>();
|
||||||
|
@ -137,12 +137,12 @@ public class GeoFocusMapLocations extends AbstractAjaxResponder {
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return locations;
|
return locations;
|
||||||
}
|
}
|
||||||
private Integer calculateRadius(Integer count) {
|
private Integer calculateRadius(Integer count) {
|
||||||
|
|
||||||
int radius = 8;
|
int radius = 8;
|
||||||
if ( count != null ) {
|
if ( count != null ) {
|
||||||
if ( count < 4 ) {
|
if ( count < 4 ) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class GeoFocusResearcherCount extends AbstractAjaxResponder {
|
||||||
+ " ?person a foaf:Person . \n"
|
+ " ?person a foaf:Person . \n"
|
||||||
+ " ?person core:geographicFocus ?focus \n"
|
+ " ?person core:geographicFocus ?focus \n"
|
||||||
+ "}" ;
|
+ "}" ;
|
||||||
|
|
||||||
public GeoFocusResearcherCount(HttpServlet parent, VitroRequest vreq,
|
public GeoFocusResearcherCount(HttpServlet parent, VitroRequest vreq,
|
||||||
HttpServletResponse resp) {
|
HttpServletResponse resp) {
|
||||||
super(parent, vreq, resp);
|
super(parent, vreq, resp);
|
||||||
|
@ -40,9 +40,9 @@ public class GeoFocusResearcherCount extends AbstractAjaxResponder {
|
||||||
public String prepareResponse() throws IOException {
|
public String prepareResponse() throws IOException {
|
||||||
try {
|
try {
|
||||||
geoFocusCount = getGeoFocusCount(vreq);
|
geoFocusCount = getGeoFocusCount(vreq);
|
||||||
|
|
||||||
StringBuilder response = new StringBuilder("{ ");
|
StringBuilder response = new StringBuilder("{ ");
|
||||||
|
|
||||||
for (Map<String, String> map: geoFocusCount) {
|
for (Map<String, String> map: geoFocusCount) {
|
||||||
String theCount = map.get("count");
|
String theCount = map.get("count");
|
||||||
response.append("\"count\": \"").append(theCount).append("\"");
|
response.append("\"count\": \"").append(theCount).append("\"");
|
||||||
|
@ -55,9 +55,9 @@ public class GeoFocusResearcherCount extends AbstractAjaxResponder {
|
||||||
return EMPTY_RESPONSE;
|
return EMPTY_RESPONSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Map<String,String>> getGeoFocusCount(VitroRequest vreq) {
|
private List<Map<String,String>> getGeoFocusCount(VitroRequest vreq) {
|
||||||
|
|
||||||
String queryStr = GEO_FOCUS_COUNT_QUERY;
|
String queryStr = GEO_FOCUS_COUNT_QUERY;
|
||||||
log.debug("queryStr = " + queryStr);
|
log.debug("queryStr = " + queryStr);
|
||||||
List<Map<String,String>> count = new ArrayList<Map<String,String>>();
|
List<Map<String,String>> count = new ArrayList<Map<String,String>>();
|
||||||
|
@ -69,8 +69,8 @@ public class GeoFocusResearcherCount extends AbstractAjaxResponder {
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class HomePageAjaxController extends VitroAjaxController {
|
||||||
}
|
}
|
||||||
else if ("getGeoFocusResearcherCount".equals(function)) {
|
else if ("getGeoFocusResearcherCount".equals(function)) {
|
||||||
new GeoFocusResearcherCount(this, vreq, resp).processRequest();
|
new GeoFocusResearcherCount(this, vreq, resp).processRequest();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
resp.getWriter().write("[]");
|
resp.getWriter().write("[]");
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class QrCodeDetails extends AbstractAjaxResponder {
|
||||||
+ " ?vTitle vcard:title ?title . \n"
|
+ " ?vTitle vcard:title ?title . \n"
|
||||||
+ " } \n"
|
+ " } \n"
|
||||||
+ "} " ;
|
+ "} " ;
|
||||||
|
|
||||||
public QrCodeDetails(HttpServlet parent, VitroRequest vreq,
|
public QrCodeDetails(HttpServlet parent, VitroRequest vreq,
|
||||||
HttpServletResponse resp) {
|
HttpServletResponse resp) {
|
||||||
super(parent, vreq, resp);
|
super(parent, vreq, resp);
|
||||||
|
@ -62,17 +62,17 @@ public class QrCodeDetails extends AbstractAjaxResponder {
|
||||||
String phoneNumber = "";
|
String phoneNumber = "";
|
||||||
String email = "";
|
String email = "";
|
||||||
String response = "[";
|
String response = "[";
|
||||||
|
|
||||||
vcardData = getVcardData(individual, vreq);
|
vcardData = getVcardData(individual, vreq);
|
||||||
|
|
||||||
for (Map<String, String> map: vcardData) {
|
for (Map<String, String> map: vcardData) {
|
||||||
firstName = map.get("firstName");
|
firstName = map.get("firstName");
|
||||||
lastName = map.get("lastName");
|
lastName = map.get("lastName");
|
||||||
preferredTitle = map.get("title");
|
preferredTitle = map.get("title");
|
||||||
phoneNumber = map.get("phone");
|
phoneNumber = map.get("phone");
|
||||||
email = map.get("email");
|
email = map.get("email");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
String tempUrl = vreq.getRequestURL().toString();
|
String tempUrl = vreq.getRequestURL().toString();
|
||||||
String prefix = "http://";
|
String prefix = "http://";
|
||||||
|
@ -121,7 +121,7 @@ public class QrCodeDetails extends AbstractAjaxResponder {
|
||||||
return EMPTY_RESPONSE;
|
return EMPTY_RESPONSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Map<String,String>> getVcardData(Individual individual, VitroRequest vreq) {
|
private List<Map<String,String>> getVcardData(Individual individual, VitroRequest vreq) {
|
||||||
String queryStr = QueryUtils.subUriForQueryVar(VCARD_DATA_QUERY, "subject", individual.getURI());
|
String queryStr = QueryUtils.subUriForQueryVar(VCARD_DATA_QUERY, "subject", individual.getURI());
|
||||||
log.debug("queryStr = " + queryStr);
|
log.debug("queryStr = " + queryStr);
|
||||||
|
@ -134,8 +134,8 @@ public class QrCodeDetails extends AbstractAjaxResponder {
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return vcardData;
|
return vcardData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,258 +1,258 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||||
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_ASSERTIONS;
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_ASSERTIONS;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.annotation.WebServlet;
|
import javax.servlet.annotation.WebServlet;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
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.rdf.model.Model;
|
import org.apache.jena.rdf.model.Model;
|
||||||
import org.apache.jena.rdf.model.RDFNode;
|
import org.apache.jena.rdf.model.RDFNode;
|
||||||
import org.apache.jena.rdf.model.ResourceFactory;
|
import org.apache.jena.rdf.model.ResourceFactory;
|
||||||
import org.apache.jena.rdf.model.Statement;
|
import org.apache.jena.rdf.model.Statement;
|
||||||
import org.apache.jena.rdf.model.StmtIterator;
|
import org.apache.jena.rdf.model.StmtIterator;
|
||||||
import org.apache.jena.shared.Lock;
|
import org.apache.jena.shared.Lock;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.edit.utils.LocalNamespaceClassUtils;
|
import edu.cornell.mannlib.vitro.webapp.controller.edit.utils.LocalNamespaceClassUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
/*
|
/*
|
||||||
* Custom controller for menu management. This will be replaced later once N3 Editing
|
* Custom controller for menu management. This will be replaced later once N3 Editing
|
||||||
* has been successfully refactored and integrated with menu management.
|
* has been successfully refactored and integrated with menu management.
|
||||||
*/
|
*/
|
||||||
@WebServlet(name = "InstitutionalInternalClassController", urlPatterns = {"/processInstitutionalInternalClass"} )
|
@WebServlet(name = "InstitutionalInternalClassController", urlPatterns = {"/processInstitutionalInternalClass"} )
|
||||||
public class InstitutionalInternalClassController extends FreemarkerHttpServlet {
|
public class InstitutionalInternalClassController extends FreemarkerHttpServlet {
|
||||||
private static final Log log = LogFactory.getLog(InstitutionalInternalClassController.class);
|
private static final Log log = LogFactory.getLog(InstitutionalInternalClassController.class);
|
||||||
|
|
||||||
private static final String EDIT_FORM = "/processInstitutionalInternalClass";
|
private static final String EDIT_FORM = "/processInstitutionalInternalClass";
|
||||||
public final static AuthorizationRequest REQUIRED_ACTIONS = SimplePermission.MANAGE_MENUS.ACTION;
|
public final static AuthorizationRequest REQUIRED_ACTIONS = SimplePermission.MANAGE_MENUS.ACTION;
|
||||||
private static final String DISPLAY_FORM = "/institutionalInternalClassForm.ftl";
|
private static final String DISPLAY_FORM = "/institutionalInternalClassForm.ftl";
|
||||||
private static HashMap<String, String> localNamespaces = new HashMap<String, String>();
|
private static HashMap<String, String> localNamespaces = new HashMap<String, String>();
|
||||||
private static HashMap<String, String> localNamespaceClasses = new HashMap<String, String>();
|
private static HashMap<String, String> localNamespaceClasses = new HashMap<String, String>();
|
||||||
private static final String CREATE_CLASS_PARAM = "createClass";
|
private static final String CREATE_CLASS_PARAM = "createClass";
|
||||||
private static final String REDIRECT_PAGE = "/siteAdmin";
|
private static final String REDIRECT_PAGE = "/siteAdmin";
|
||||||
@Override
|
@Override
|
||||||
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
||||||
return REQUIRED_ACTIONS;
|
return REQUIRED_ACTIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||||
|
|
||||||
//Based on existing of local namespaces and number of local classes present
|
//Based on existing of local namespaces and number of local classes present
|
||||||
//as well as command parameter, execute command
|
//as well as command parameter, execute command
|
||||||
|
|
||||||
Map<String, Object> data = new HashMap<String,Object>();
|
Map<String, Object> data = new HashMap<String,Object>();
|
||||||
//Get all local classes and namespace information
|
//Get all local classes and namespace information
|
||||||
retrieveLocalClasses(vreq, data);
|
retrieveLocalClasses(vreq, data);
|
||||||
if(isSubmission(vreq)){
|
if(isSubmission(vreq)){
|
||||||
processSubmission(vreq, data);
|
processSubmission(vreq, data);
|
||||||
} else if(isCreateNewClass(vreq)) {
|
} else if(isCreateNewClass(vreq)) {
|
||||||
//Local namespace(s) exist and user wishes to create a new class
|
//Local namespace(s) exist and user wishes to create a new class
|
||||||
//Either cmd = create new or no local classes exist at all and one must be created
|
//Either cmd = create new or no local classes exist at all and one must be created
|
||||||
processCreateNewClass(vreq, data);
|
processCreateNewClass(vreq, data);
|
||||||
} else if(isSelectExistingClass(vreq)) {
|
} else if(isSelectExistingClass(vreq)) {
|
||||||
//Local namespace(s) exist and user can select an existing class
|
//Local namespace(s) exist and user can select an existing class
|
||||||
processSelectExistingClass(vreq, data);
|
processSelectExistingClass(vreq, data);
|
||||||
} else if(isCreateOntologies(vreq)) {
|
} else if(isCreateOntologies(vreq)) {
|
||||||
//Not being handled expliclity but message will display indicating
|
//Not being handled expliclity but message will display indicating
|
||||||
//no local namespaces exist and one must be created
|
//no local namespaces exist and one must be created
|
||||||
processCreateOntologies(vreq, data);
|
processCreateOntologies(vreq, data);
|
||||||
} else {
|
} else {
|
||||||
log.error("Don't recognize the type of request.");
|
log.error("Don't recognize the type of request.");
|
||||||
}
|
}
|
||||||
//Retrieve local namespaces
|
//Retrieve local namespaces
|
||||||
|
|
||||||
|
|
||||||
//Check if existing local namespaces
|
//Check if existing local namespaces
|
||||||
|
|
||||||
data.put("formUrl", vreq.getContextPath() + EDIT_FORM);
|
data.put("formUrl", vreq.getContextPath() + EDIT_FORM);
|
||||||
data.put("cancelUrl", vreq.getContextPath() + REDIRECT_PAGE);
|
data.put("cancelUrl", vreq.getContextPath() + REDIRECT_PAGE);
|
||||||
|
|
||||||
//if no local namespaces, then provide message to display
|
//if no local namespaces, then provide message to display
|
||||||
//if existing namespace(s), then check
|
//if existing namespace(s), then check
|
||||||
//if single namespace, retrieve all classes belonging to that local namespace
|
//if single namespace, retrieve all classes belonging to that local namespace
|
||||||
//if multiple namespaces, generate select list with namespaces
|
//if multiple namespaces, generate select list with namespaces
|
||||||
//for instertion: VClassDaoJena.insertVClass
|
//for instertion: VClassDaoJena.insertVClass
|
||||||
//
|
//
|
||||||
if(isSubmission(vreq)){
|
if(isSubmission(vreq)){
|
||||||
return redirectToSiteAdmin();
|
return redirectToSiteAdmin();
|
||||||
}
|
}
|
||||||
return new TemplateResponseValues(DISPLAY_FORM, data);
|
return new TemplateResponseValues(DISPLAY_FORM, data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSubmission(VitroRequest vreq) {
|
private boolean isSubmission(VitroRequest vreq) {
|
||||||
String submit = vreq.getParameter("submitForm");
|
String submit = vreq.getParameter("submitForm");
|
||||||
return(submit!= null && !submit.isEmpty());
|
return(submit!= null && !submit.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processCreateOntologies(VitroRequest vreq, Map<String, Object> data) {
|
private void processCreateOntologies(VitroRequest vreq, Map<String, Object> data) {
|
||||||
data.put("submitAction", "");
|
data.put("submitAction", "");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCreateOntologies(VitroRequest vreq) {
|
private boolean isCreateOntologies(VitroRequest vreq) {
|
||||||
//no local namespaces
|
//no local namespaces
|
||||||
return (localNamespaces.size() == 0);
|
return (localNamespaces.size() == 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processCreateNewClass(VitroRequest vreq, Map<String, Object> data) {
|
private void processCreateNewClass(VitroRequest vreq, Map<String, Object> data) {
|
||||||
//this may need to be changed on the basis of how new classes interact with new ontologies
|
//this may need to be changed on the basis of how new classes interact with new ontologies
|
||||||
data.put("submitAction", "Create Class");
|
data.put("submitAction", "Create Class");
|
||||||
data.put("createNewClass", true);
|
data.put("createNewClass", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCreateNewClass(VitroRequest vreq) {
|
private boolean isCreateNewClass(VitroRequest vreq) {
|
||||||
String command = vreq.getParameter("cmd");
|
String command = vreq.getParameter("cmd");
|
||||||
if(command != null && command.equals(CREATE_CLASS_PARAM)) {
|
if(command != null && command.equals(CREATE_CLASS_PARAM)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//If local namespace exists but no classes in local namespaces, then need to enable creation of new classes
|
//If local namespace exists but no classes in local namespaces, then need to enable creation of new classes
|
||||||
return(localNamespaces.size() > 0 && localNamespaceClasses.size() == 0);
|
return(localNamespaces.size() > 0 && localNamespaceClasses.size() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processSelectExistingClass(VitroRequest vreq, Map<String, Object> data) {
|
private void processSelectExistingClass(VitroRequest vreq, Map<String, Object> data) {
|
||||||
//Check if local classes exist and use for selection
|
//Check if local classes exist and use for selection
|
||||||
data.put("useExistingLocalClass", true);
|
data.put("useExistingLocalClass", true);
|
||||||
data.put("submitAction", "Save");
|
data.put("submitAction", "Save");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSelectExistingClass(VitroRequest vreq) {
|
private boolean isSelectExistingClass(VitroRequest vreq) {
|
||||||
//Local namespaces exist and there are existing classes within those namespaces
|
//Local namespaces exist and there are existing classes within those namespaces
|
||||||
return (localNamespaces.size() > 0 && localNamespaceClasses.size() > 0);
|
return (localNamespaces.size() > 0 && localNamespaceClasses.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void retrieveLocalClasses(VitroRequest vreq, Map<String, Object> data) {
|
private void retrieveLocalClasses(VitroRequest vreq, Map<String, Object> data) {
|
||||||
localNamespaces = LocalNamespaceClassUtils.getLocalOntologyNamespaces(vreq);
|
localNamespaces = LocalNamespaceClassUtils.getLocalOntologyNamespaces(vreq);
|
||||||
//Get classes for local namespaces
|
//Get classes for local namespaces
|
||||||
localNamespaceClasses = LocalNamespaceClassUtils.getLocalNamespacesClasses(vreq, localNamespaces);
|
localNamespaceClasses = LocalNamespaceClassUtils.getLocalNamespacesClasses(vreq, localNamespaces);
|
||||||
data.put("existingLocalClasses", localNamespaceClasses);
|
data.put("existingLocalClasses", localNamespaceClasses);
|
||||||
data.put("existingLocalNamespaces", localNamespaces);
|
data.put("existingLocalNamespaces", localNamespaces);
|
||||||
String noLocalOntologiesMessage = "There are currently no local ontologies. You must create a new ontology";
|
String noLocalOntologiesMessage = "There are currently no local ontologies. You must create a new ontology";
|
||||||
data.put("noLocalOntologiesMessage", noLocalOntologiesMessage);
|
data.put("noLocalOntologiesMessage", noLocalOntologiesMessage);
|
||||||
if(localNamespaces.size() == 0) {
|
if(localNamespaces.size() == 0) {
|
||||||
data.put("ontologiesExist", false);
|
data.put("ontologiesExist", false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
data.put("ontologiesExist", true);
|
data.put("ontologiesExist", true);
|
||||||
if(localNamespaces.size() > 1) {
|
if(localNamespaces.size() > 1) {
|
||||||
data.put("multipleLocalNamespaces", true);
|
data.put("multipleLocalNamespaces", true);
|
||||||
} else {
|
} else {
|
||||||
data.put("multipleLocalNamespaces", false);
|
data.put("multipleLocalNamespaces", false);
|
||||||
data.put("existingLocalNamespace", localNamespaces.keySet().iterator().next());
|
data.put("existingLocalNamespace", localNamespaces.keySet().iterator().next());
|
||||||
}
|
}
|
||||||
//Get current internal class if it exists
|
//Get current internal class if it exists
|
||||||
data.put("existingInternalClass", retrieveCurrentInternalClass());
|
data.put("existingInternalClass", retrieveCurrentInternalClass());
|
||||||
}
|
}
|
||||||
//Place default namespace within data to pass back to template
|
//Place default namespace within data to pass back to template
|
||||||
String defaultNamespace = vreq.getWebappDaoFactory().getDefaultNamespace();
|
String defaultNamespace = vreq.getWebappDaoFactory().getDefaultNamespace();
|
||||||
data.put("defaultNamespace", defaultNamespace);
|
data.put("defaultNamespace", defaultNamespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Process submission on submitting form
|
//Process submission on submitting form
|
||||||
private void processSubmission(VitroRequest vreq, Map<String, Object> data) {
|
private void processSubmission(VitroRequest vreq, Map<String, Object> data) {
|
||||||
//If new class, need to generate new class
|
//If new class, need to generate new class
|
||||||
String classUri = null;
|
String classUri = null;
|
||||||
if(isNewClassSubmission(vreq)){
|
if(isNewClassSubmission(vreq)){
|
||||||
VClass v= generateNewVClass(vreq.getParameter("localClassName"), vreq.getParameter("existingLocalNamespaces"));
|
VClass v= generateNewVClass(vreq.getParameter("localClassName"), vreq.getParameter("existingLocalNamespaces"));
|
||||||
classUri = v.getURI();
|
classUri = v.getURI();
|
||||||
try {
|
try {
|
||||||
vreq.getWebappDaoFactory().getVClassDao().insertNewVClass(v);
|
vreq.getWebappDaoFactory().getVClassDao().insertNewVClass(v);
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
log.error("Insertion of new class " + vreq.getParameter("name") + " resulted in error ", ex);
|
log.error("Insertion of new class " + vreq.getParameter("name") + " resulted in error ", ex);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//Existing class so get URI from that
|
//Existing class so get URI from that
|
||||||
classUri = getExistingClassUri(vreq);
|
classUri = getExistingClassUri(vreq);
|
||||||
}
|
}
|
||||||
//If existing class, need to simply add a statement specifying existing class is an internal class
|
//If existing class, need to simply add a statement specifying existing class is an internal class
|
||||||
if(classUri != null && !classUri.isEmpty()) {
|
if(classUri != null && !classUri.isEmpty()) {
|
||||||
Model writeModel = ModelAccess.on(getServletContext()).getOntModel(TBOX_ASSERTIONS);
|
Model writeModel = ModelAccess.on(getServletContext()).getOntModel(TBOX_ASSERTIONS);
|
||||||
writeModel.enterCriticalSection(Lock.WRITE);
|
writeModel.enterCriticalSection(Lock.WRITE);
|
||||||
writeModel.notifyEvent(new EditEvent(null,true));
|
writeModel.notifyEvent(new EditEvent(null,true));
|
||||||
try {
|
try {
|
||||||
log.debug("Should be removing these statements " + writeModel.listStatements(null,
|
log.debug("Should be removing these statements " + writeModel.listStatements(null,
|
||||||
ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT),
|
ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT),
|
||||||
(RDFNode) null).toList().toString());
|
(RDFNode) null).toList().toString());
|
||||||
//remove existing internal classes if there are any as assuming only one
|
//remove existing internal classes if there are any as assuming only one
|
||||||
writeModel.removeAll(null,
|
writeModel.removeAll(null,
|
||||||
ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT),
|
ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT),
|
||||||
(RDFNode) null);
|
(RDFNode) null);
|
||||||
log.debug("Are there any statements left for internal class annotation: " + writeModel.listStatements(null,
|
log.debug("Are there any statements left for internal class annotation: " + writeModel.listStatements(null,
|
||||||
ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT),
|
ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT),
|
||||||
(RDFNode) null).toList().toString());
|
(RDFNode) null).toList().toString());
|
||||||
writeModel.add(
|
writeModel.add(
|
||||||
writeModel.createStatement(
|
writeModel.createStatement(
|
||||||
ResourceFactory.createResource(classUri),
|
ResourceFactory.createResource(classUri),
|
||||||
ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT),
|
ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT),
|
||||||
writeModel.createLiteral("true")));
|
writeModel.createLiteral("true")));
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
log.error("Error occurred in adding statement for " + classUri + " becoming internal class", ex);
|
log.error("Error occurred in adding statement for " + classUri + " becoming internal class", ex);
|
||||||
} finally {
|
} finally {
|
||||||
writeModel.notifyEvent(new EditEvent(null,true));
|
writeModel.notifyEvent(new EditEvent(null,true));
|
||||||
writeModel.leaveCriticalSection();
|
writeModel.leaveCriticalSection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private VClass generateNewVClass(String newClassName, String namespace) {
|
private VClass generateNewVClass(String newClassName, String namespace) {
|
||||||
VClass newClass = new VClass();
|
VClass newClass = new VClass();
|
||||||
newClass.setName(newClassName);
|
newClass.setName(newClassName);
|
||||||
newClass.setNamespace(namespace);
|
newClass.setNamespace(namespace);
|
||||||
String uri = namespace + newClassName.replaceAll(" ", "");
|
String uri = namespace + newClassName.replaceAll(" ", "");
|
||||||
newClass.setURI(uri);
|
newClass.setURI(uri);
|
||||||
//How to g
|
//How to g
|
||||||
return newClass;
|
return newClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNewClassSubmission(VitroRequest vreq) {
|
private boolean isNewClassSubmission(VitroRequest vreq) {
|
||||||
String localName = vreq.getParameter("localClassName");
|
String localName = vreq.getParameter("localClassName");
|
||||||
return (localName != null && !localName.isEmpty());
|
return (localName != null && !localName.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getExistingClassUri(VitroRequest vreq) {
|
private String getExistingClassUri(VitroRequest vreq) {
|
||||||
return vreq.getParameter("existingLocalClasses");
|
return vreq.getParameter("existingLocalClasses");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private RedirectResponseValues redirectToSiteAdmin() {
|
private RedirectResponseValues redirectToSiteAdmin() {
|
||||||
return new RedirectResponseValues(REDIRECT_PAGE, HttpServletResponse.SC_SEE_OTHER);
|
return new RedirectResponseValues(REDIRECT_PAGE, HttpServletResponse.SC_SEE_OTHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get current internal class
|
//Get current internal class
|
||||||
private String retrieveCurrentInternalClass() {
|
private String retrieveCurrentInternalClass() {
|
||||||
String internalClassUri = "";
|
String internalClassUri = "";
|
||||||
Model mainModel = ModelAccess.on(getServletContext()).getOntModel(TBOX_ASSERTIONS);
|
Model mainModel = ModelAccess.on(getServletContext()).getOntModel(TBOX_ASSERTIONS);
|
||||||
StmtIterator internalIt = mainModel.listStatements(null,
|
StmtIterator internalIt = mainModel.listStatements(null,
|
||||||
ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT),
|
ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT),
|
||||||
(RDFNode) null);
|
(RDFNode) null);
|
||||||
while(internalIt.hasNext()){
|
while(internalIt.hasNext()){
|
||||||
Statement s = internalIt.nextStatement();
|
Statement s = internalIt.nextStatement();
|
||||||
//The class IS an internal class so the subject is what we're looking for
|
//The class IS an internal class so the subject is what we're looking for
|
||||||
internalClassUri = s.getSubject().getURI();
|
internalClassUri = s.getSubject().getURI();
|
||||||
log.debug("Found internal class uri " + internalClassUri);
|
log.debug("Found internal class uri " + internalClassUri);
|
||||||
}
|
}
|
||||||
return internalClassUri;
|
return internalClassUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class ManageGrantsForIndividualController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(ManageGrantsForIndividualController.class.getName());
|
private static final Log log = LogFactory.getLog(ManageGrantsForIndividualController.class.getName());
|
||||||
private static final String TEMPLATE_NAME = "manageGrantsForIndividual.ftl";
|
private static final String TEMPLATE_NAME = "manageGrantsForIndividual.ftl";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
||||||
return SimplePermission.DO_FRONT_END_EDITING.ACTION;
|
return SimplePermission.DO_FRONT_END_EDITING.ACTION;
|
||||||
|
@ -54,17 +54,17 @@ public class ManageGrantsForIndividualController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
List<String> allSubclasses = getAllSubclasses(grants);
|
List<String> allSubclasses = getAllSubclasses(grants);
|
||||||
body.put("allSubclasses", allSubclasses);
|
body.put("allSubclasses", allSubclasses);
|
||||||
|
|
||||||
Individual subject = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri);
|
Individual subject = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri);
|
||||||
if( subject != null && subject.getName() != null ){
|
if( subject != null && subject.getName() != null ){
|
||||||
body.put("subjectName", subject.getName());
|
body.put("subjectName", subject.getName());
|
||||||
}else{
|
}else{
|
||||||
body.put("subjectName", null);
|
body.put("subjectName", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new TemplateResponseValues(TEMPLATE_NAME, body);
|
return new TemplateResponseValues(TEMPLATE_NAME, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String GRANT_QUERY = ""
|
private static String GRANT_QUERY = ""
|
||||||
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
|
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
|
||||||
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
||||||
|
@ -87,12 +87,12 @@ public class ManageGrantsForIndividualController extends FreemarkerHttpServlet {
|
||||||
+ " ?activity a core:Project . \n"
|
+ " ?activity a core:Project . \n"
|
||||||
+ " ?activity rdfs:label ?label2 . \n"
|
+ " ?activity rdfs:label ?label2 . \n"
|
||||||
+ " } \n"
|
+ " } \n"
|
||||||
+ " OPTIONAL { ?role core:hideFromDisplay ?hideThis } \n"
|
+ " OPTIONAL { ?role core:hideFromDisplay ?hideThis } \n"
|
||||||
+ "} ORDER BY ?subclass ?label2";
|
+ "} ORDER BY ?subclass ?label2";
|
||||||
|
|
||||||
HashMap<String, List<Map<String,String>>> getGrants(String subjectUri, VitroRequest vreq) {
|
HashMap<String, List<Map<String,String>>> getGrants(String subjectUri, VitroRequest vreq) {
|
||||||
VClassDao vcDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getVClassDao();
|
VClassDao vcDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getVClassDao();
|
||||||
|
|
||||||
String queryStr = QueryUtils.subUriForQueryVar(GRANT_QUERY, "subject", subjectUri);
|
String queryStr = QueryUtils.subUriForQueryVar(GRANT_QUERY, "subject", subjectUri);
|
||||||
log.debug("queryStr = " + queryStr);
|
log.debug("queryStr = " + queryStr);
|
||||||
HashMap<String, List<Map<String,String>>> subclassToGrants = new HashMap<String, List<Map<String,String>>>();
|
HashMap<String, List<Map<String,String>>> subclassToGrants = new HashMap<String, List<Map<String,String>>>();
|
||||||
|
@ -109,13 +109,13 @@ public class ManageGrantsForIndividualController extends FreemarkerHttpServlet {
|
||||||
subclassToGrants.put(subclass, new ArrayList<Map<String,String>>()); //list of grant information
|
subclassToGrants.put(subclass, new ArrayList<Map<String,String>>()); //list of grant information
|
||||||
}
|
}
|
||||||
List<Map<String,String>> grantsList = subclassToGrants.get(subclass);
|
List<Map<String,String>> grantsList = subclassToGrants.get(subclass);
|
||||||
grantsList.add(QueryUtils.querySolutionToStringValueMap(soln));
|
grantsList.add(QueryUtils.querySolutionToStringValueMap(soln));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return subclassToGrants;
|
return subclassToGrants;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class ManagePeopleForOrganizationController extends FreemarkerHttpServlet
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(ManagePeopleForOrganizationController.class.getName());
|
private static final Log log = LogFactory.getLog(ManagePeopleForOrganizationController.class.getName());
|
||||||
private static final String TEMPLATE_NAME = "managePeopleForOrganization.ftl";
|
private static final String TEMPLATE_NAME = "managePeopleForOrganization.ftl";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
||||||
return SimplePermission.DO_FRONT_END_EDITING.ACTION;
|
return SimplePermission.DO_FRONT_END_EDITING.ACTION;
|
||||||
|
@ -54,17 +54,17 @@ public class ManagePeopleForOrganizationController extends FreemarkerHttpServlet
|
||||||
|
|
||||||
List<String> allSubclasses = getAllSubclasses(people);
|
List<String> allSubclasses = getAllSubclasses(people);
|
||||||
body.put("allSubclasses", allSubclasses);
|
body.put("allSubclasses", allSubclasses);
|
||||||
|
|
||||||
Individual subject = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri);
|
Individual subject = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri);
|
||||||
if( subject != null && subject.getName() != null ){
|
if( subject != null && subject.getName() != null ){
|
||||||
body.put("subjectName", subject.getName());
|
body.put("subjectName", subject.getName());
|
||||||
}else{
|
}else{
|
||||||
body.put("subjectName", null);
|
body.put("subjectName", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new TemplateResponseValues(TEMPLATE_NAME, body);
|
return new TemplateResponseValues(TEMPLATE_NAME, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String PEOPLE_QUERY = ""
|
private static String PEOPLE_QUERY = ""
|
||||||
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
|
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
|
||||||
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
||||||
|
@ -88,8 +88,8 @@ public class ManagePeopleForOrganizationController extends FreemarkerHttpServlet
|
||||||
+ " } \n "
|
+ " } \n "
|
||||||
+ " OPTIONAL { ?position core:hideFromDisplay ?hideThis } \n "
|
+ " OPTIONAL { ?position core:hideFromDisplay ?hideThis } \n "
|
||||||
+ " FILTER ( !BOUND(?displayRank) || ?displayRank < 500 )"
|
+ " FILTER ( !BOUND(?displayRank) || ?displayRank < 500 )"
|
||||||
+ "} ORDER BY ?subclass ?name";
|
+ "} ORDER BY ?subclass ?name";
|
||||||
|
|
||||||
HashMap<String, List<Map<String,String>>> getPeople(String subjectUri, VitroRequest vreq) {
|
HashMap<String, List<Map<String,String>>> getPeople(String subjectUri, VitroRequest vreq) {
|
||||||
VClassDao vcDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getVClassDao();
|
VClassDao vcDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getVClassDao();
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ public class ManagePeopleForOrganizationController extends FreemarkerHttpServlet
|
||||||
VClass vClass = vcDao.getVClassByURI(subclassUriStr);
|
VClass vClass = vcDao.getVClassByURI(subclassUriStr);
|
||||||
String subclass = ((vClass.getName() == null) ? subclassUriStr : vClass.getName());
|
String subclass = ((vClass.getName() == null) ? subclassUriStr : vClass.getName());
|
||||||
if(!subclassToPeople.containsKey(subclass)) {
|
if(!subclassToPeople.containsKey(subclass)) {
|
||||||
subclassToPeople.put(subclass, new ArrayList<Map<String,String>>());
|
subclassToPeople.put(subclass, new ArrayList<Map<String,String>>());
|
||||||
}
|
}
|
||||||
List<Map<String,String>> peopleList = subclassToPeople.get(subclass);
|
List<Map<String,String>> peopleList = subclassToPeople.get(subclass);
|
||||||
peopleList.add(QueryUtils.querySolutionToStringValueMap(soln));
|
peopleList.add(QueryUtils.querySolutionToStringValueMap(soln));
|
||||||
|
@ -114,7 +114,7 @@ public class ManagePeopleForOrganizationController extends FreemarkerHttpServlet
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return subclassToPeople;
|
return subclassToPeople;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class ManagePublicationsForIndividualController extends FreemarkerHttpSer
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(ManagePublicationsForIndividualController.class.getName());
|
private static final Log log = LogFactory.getLog(ManagePublicationsForIndividualController.class.getName());
|
||||||
private static final String TEMPLATE_NAME = "managePublicationsForIndividual.ftl";
|
private static final String TEMPLATE_NAME = "managePublicationsForIndividual.ftl";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
||||||
return SimplePermission.DO_FRONT_END_EDITING.ACTION;
|
return SimplePermission.DO_FRONT_END_EDITING.ACTION;
|
||||||
|
@ -54,17 +54,17 @@ public class ManagePublicationsForIndividualController extends FreemarkerHttpSer
|
||||||
|
|
||||||
List<String> allSubclasses = getAllSubclasses(publications);
|
List<String> allSubclasses = getAllSubclasses(publications);
|
||||||
body.put("allSubclasses", allSubclasses);
|
body.put("allSubclasses", allSubclasses);
|
||||||
|
|
||||||
Individual subject = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri);
|
Individual subject = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri);
|
||||||
if( subject != null && subject.getName() != null ){
|
if( subject != null && subject.getName() != null ){
|
||||||
body.put("subjectName", subject.getName());
|
body.put("subjectName", subject.getName());
|
||||||
}else{
|
}else{
|
||||||
body.put("subjectName", null);
|
body.put("subjectName", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new TemplateResponseValues(TEMPLATE_NAME, body);
|
return new TemplateResponseValues(TEMPLATE_NAME, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String PUBLICATION_QUERY = ""
|
private static String PUBLICATION_QUERY = ""
|
||||||
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
|
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
|
||||||
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
||||||
|
@ -85,10 +85,10 @@ public class ManagePublicationsForIndividualController extends FreemarkerHttpSer
|
||||||
+ " ?pub a <http://purl.org/ontology/bibo/Document> . \n"
|
+ " ?pub a <http://purl.org/ontology/bibo/Document> . \n"
|
||||||
+ " ?pub vitro:mostSpecificType ?subclass . \n"
|
+ " ?pub vitro:mostSpecificType ?subclass . \n"
|
||||||
+ " } \n"
|
+ " } \n"
|
||||||
+ " } \n"
|
+ " } \n"
|
||||||
+ " OPTIONAL { ?authorship core:hideFromDisplay ?hideThis } \n"
|
+ " OPTIONAL { ?authorship core:hideFromDisplay ?hideThis } \n"
|
||||||
+ "} ORDER BY ?subclass ?title";
|
+ "} ORDER BY ?subclass ?title";
|
||||||
|
|
||||||
HashMap<String, List<Map<String,String>>> getPublications(String subjectUri, VitroRequest vreq) {
|
HashMap<String, List<Map<String,String>>> getPublications(String subjectUri, VitroRequest vreq) {
|
||||||
|
|
||||||
VClassDao vcDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getVClassDao();
|
VClassDao vcDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getVClassDao();
|
||||||
|
@ -118,8 +118,8 @@ public class ManagePublicationsForIndividualController extends FreemarkerHttpSer
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return subclassToPublications;
|
return subclassToPublications;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.harvester;
|
package edu.cornell.mannlib.vitro.webapp.controller.harvester;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -69,7 +69,7 @@ class CsvFileHarvestJob implements FileHarvestJob {
|
||||||
}
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JobType(String httpParameterName, String templateFileName, String scriptFileName, String xsltFileName, String friendlyName, String linkHeader, String noNewDataMessage, String[] rdfTypesForLinks) {
|
private JobType(String httpParameterName, String templateFileName, String scriptFileName, String xsltFileName, String friendlyName, String linkHeader, String noNewDataMessage, String[] rdfTypesForLinks) {
|
||||||
this.httpParameterName = httpParameterName;
|
this.httpParameterName = httpParameterName;
|
||||||
this.templateFileName = templateFileName;
|
this.templateFileName = templateFileName;
|
||||||
|
@ -80,13 +80,13 @@ class CsvFileHarvestJob implements FileHarvestJob {
|
||||||
this.noNewDataMessage = noNewDataMessage;
|
this.noNewDataMessage = noNewDataMessage;
|
||||||
this.rdfTypesForLinks = Arrays.copyOf(rdfTypesForLinks, rdfTypesForLinks.length);
|
this.rdfTypesForLinks = Arrays.copyOf(rdfTypesForLinks, rdfTypesForLinks.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CsvFileHarvestJob constructCsvFileHarvestJob(VitroRequest vreq, String namespace) {
|
private CsvFileHarvestJob constructCsvFileHarvestJob(VitroRequest vreq, String namespace) {
|
||||||
return new CsvFileHarvestJob(vreq, this.templateFileName, this.scriptFileName, this.xsltFileName, namespace, this.friendlyName, this.linkHeader, this.noNewDataMessage, this.rdfTypesForLinks);
|
return new CsvFileHarvestJob(vreq, this.templateFileName, this.scriptFileName, this.xsltFileName, namespace, this.friendlyName, this.linkHeader, this.noNewDataMessage, this.rdfTypesForLinks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger.
|
* Logger.
|
||||||
*/
|
*/
|
||||||
|
@ -139,17 +139,17 @@ class CsvFileHarvestJob implements FileHarvestJob {
|
||||||
* An array of rdf:type values which will be used for links.
|
* An array of rdf:type values which will be used for links.
|
||||||
*/
|
*/
|
||||||
private final String[] rdfTypesForLinks;
|
private final String[] rdfTypesForLinks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The session ID of this user session.
|
* The session ID of this user session.
|
||||||
*/
|
*/
|
||||||
private final String sessionId;
|
private final String sessionId;
|
||||||
|
|
||||||
|
|
||||||
public static CsvFileHarvestJob createJob(JobType jobType, VitroRequest vreq, String namespace) {
|
public static CsvFileHarvestJob createJob(JobType jobType, VitroRequest vreq, String namespace) {
|
||||||
return jobType.constructCsvFileHarvestJob(vreq, namespace);
|
return jobType.constructCsvFileHarvestJob(vreq, namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
* @param templateFileName just the name of the template file. The directory is assumed to be standard.
|
* @param templateFileName just the name of the template file. The directory is assumed to be standard.
|
||||||
|
@ -164,7 +164,7 @@ class CsvFileHarvestJob implements FileHarvestJob {
|
||||||
this.linkHeader = linkHeader;
|
this.linkHeader = linkHeader;
|
||||||
this.noNewDataMessage = noNewDataMessage;
|
this.noNewDataMessage = noNewDataMessage;
|
||||||
this.rdfTypesForLinks = Arrays.copyOf(rdfTypesForLinks, rdfTypesForLinks.length);
|
this.rdfTypesForLinks = Arrays.copyOf(rdfTypesForLinks, rdfTypesForLinks.length);
|
||||||
|
|
||||||
this.sessionId = this.vreq.getSession().getId();
|
this.sessionId = this.vreq.getSession().getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,27 +189,27 @@ class CsvFileHarvestJob implements FileHarvestJob {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private boolean[] getLinesEndingInComma(File file) throws IOException {
|
private boolean[] getLinesEndingInComma(File file) throws IOException {
|
||||||
ArrayList<Boolean> linesEndingInCommaList = new ArrayList<Boolean>();
|
ArrayList<Boolean> linesEndingInCommaList = new ArrayList<Boolean>();
|
||||||
|
|
||||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||||
|
|
||||||
for(String line = reader.readLine(); line != null; line = reader.readLine()) {
|
for(String line = reader.readLine(); line != null; line = reader.readLine()) {
|
||||||
boolean lineEndsInComma = line.endsWith(",");
|
boolean lineEndsInComma = line.endsWith(",");
|
||||||
linesEndingInCommaList.add(lineEndsInComma);
|
linesEndingInCommaList.add(lineEndsInComma);
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
boolean[] linesEndingInComma = new boolean[linesEndingInCommaList.size()];
|
boolean[] linesEndingInComma = new boolean[linesEndingInCommaList.size()];
|
||||||
for(int i = 0; i < linesEndingInComma.length; i++) {
|
for(int i = 0; i < linesEndingInComma.length; i++) {
|
||||||
linesEndingInComma[i] = linesEndingInCommaList.get(i);
|
linesEndingInComma[i] = linesEndingInCommaList.get(i);
|
||||||
}
|
}
|
||||||
return linesEndingInComma;
|
return linesEndingInComma;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public String validateUpload(File file) {
|
public String validateUpload(File file) {
|
||||||
|
@ -256,31 +256,31 @@ class CsvFileHarvestJob implements FileHarvestJob {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
private void prepareWorkspaceDirectory() {
|
private void prepareWorkspaceDirectory() {
|
||||||
String path = FileHarvestController.getFileHarvestRootPath() + "workspaces/" + this.sessionId;
|
String path = FileHarvestController.getFileHarvestRootPath() + "workspaces/" + this.sessionId;
|
||||||
File directory = new File(path);
|
File directory = new File(path);
|
||||||
if(!directory.exists())
|
if(!directory.exists())
|
||||||
directory.mkdirs();
|
directory.mkdirs();
|
||||||
|
|
||||||
File scriptTemplate = this.scriptFile;
|
File scriptTemplate = this.scriptFile;
|
||||||
String scriptTemplateContents = readFromFile(scriptTemplate);
|
String scriptTemplateContents = readFromFile(scriptTemplate);
|
||||||
String scriptTemplateReplacements = performScriptTemplateReplacements(scriptTemplateContents);
|
String scriptTemplateReplacements = performScriptTemplateReplacements(scriptTemplateContents);
|
||||||
File outputScriptFile = new File(path + "/" + scriptTemplate.getName());
|
File outputScriptFile = new File(path + "/" + scriptTemplate.getName());
|
||||||
writeToFile(outputScriptFile, scriptTemplateReplacements);
|
writeToFile(outputScriptFile, scriptTemplateReplacements);
|
||||||
|
|
||||||
File xsltTemplate = this.xsltFile;
|
File xsltTemplate = this.xsltFile;
|
||||||
String xsltTemplateContents = readFromFile(xsltTemplate);
|
String xsltTemplateContents = readFromFile(xsltTemplate);
|
||||||
String xsltTemplateReplacements = performXsltTemplateReplacements(xsltTemplateContents);
|
String xsltTemplateReplacements = performXsltTemplateReplacements(xsltTemplateContents);
|
||||||
File outputXsltFile = new File(path + "/" + xsltTemplate.getName());
|
File outputXsltFile = new File(path + "/" + xsltTemplate.getName());
|
||||||
writeToFile(outputXsltFile, xsltTemplateReplacements);
|
writeToFile(outputXsltFile, xsltTemplateReplacements);
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getScript()
|
public String getScript()
|
||||||
{
|
{
|
||||||
|
@ -302,7 +302,7 @@ class CsvFileHarvestJob implements FileHarvestJob {
|
||||||
|
|
||||||
if(harvestedDataPath.endsWith("/"))
|
if(harvestedDataPath.endsWith("/"))
|
||||||
harvestedDataPath = harvestedDataPath.substring(0, harvestedDataPath.length() - 1);
|
harvestedDataPath = harvestedDataPath.substring(0, harvestedDataPath.length() - 1);
|
||||||
|
|
||||||
replacements = replacements.replace("${WORKING_DIRECTORY}", workingDirectory);
|
replacements = replacements.replace("${WORKING_DIRECTORY}", workingDirectory);
|
||||||
replacements = replacements.replace("${UPLOADS_FOLDER}", fileDirectory);
|
replacements = replacements.replace("${UPLOADS_FOLDER}", fileDirectory);
|
||||||
replacements = replacements.replace("${HARVESTED_DATA_PATH}", harvestedDataPath);
|
replacements = replacements.replace("${HARVESTED_DATA_PATH}", harvestedDataPath);
|
||||||
|
@ -314,13 +314,13 @@ class CsvFileHarvestJob implements FileHarvestJob {
|
||||||
/*
|
/*
|
||||||
private String performXsltTemplateReplacements(String xsltTemplateContents) {
|
private String performXsltTemplateReplacements(String xsltTemplateContents) {
|
||||||
String replacements = xsltTemplateContents;
|
String replacements = xsltTemplateContents;
|
||||||
|
|
||||||
replacements = replacements.replace("", "");
|
replacements = replacements.replace("", "");
|
||||||
|
|
||||||
return replacements;
|
return replacements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void writeToFile(File file, String contents) {
|
private void writeToFile(File file, String contents) {
|
||||||
PrintWriter writer = null;
|
PrintWriter writer = null;
|
||||||
try {
|
try {
|
||||||
|
@ -333,7 +333,7 @@ class CsvFileHarvestJob implements FileHarvestJob {
|
||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private String readFromFile(File file) {
|
private String readFromFile(File file) {
|
||||||
String contents = null;
|
String contents = null;
|
||||||
|
@ -407,7 +407,7 @@ class CsvFileHarvestJob implements FileHarvestJob {
|
||||||
public String getNoNewDataMessage() {
|
public String getNoNewDataMessage() {
|
||||||
return this.noNewDataMessage;
|
return this.noNewDataMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class FileHarvestController extends FreemarkerHttpServlet {
|
||||||
private static final String TEMPLATE_DEFAULT = "fileharvest.ftl";
|
private static final String TEMPLATE_DEFAULT = "fileharvest.ftl";
|
||||||
|
|
||||||
private static final String NORMAL_TERMINATION_LAST_OUTPUT = "File Harvest completed successfully";
|
private static final String NORMAL_TERMINATION_LAST_OUTPUT = "File Harvest completed successfully";
|
||||||
|
|
||||||
private static final String PARAMETER_FIRST_UPLOAD = "firstUpload";
|
private static final String PARAMETER_FIRST_UPLOAD = "firstUpload";
|
||||||
private static final String PARAMETER_UPLOADED_FILE = "uploadedFile";
|
private static final String PARAMETER_UPLOADED_FILE = "uploadedFile";
|
||||||
private static final String PARAMETER_MODE = "mode";
|
private static final String PARAMETER_MODE = "mode";
|
||||||
|
@ -191,7 +191,7 @@ public class FileHarvestController extends FreemarkerHttpServlet {
|
||||||
*/
|
*/
|
||||||
public static String getHarvesterPath(HttpServletRequest req)
|
public static String getHarvesterPath(HttpServletRequest req)
|
||||||
{
|
{
|
||||||
String pathToHarvester = ConfigurationProperties.getBean(req).getProperty("harvester.location");
|
String pathToHarvester = ConfigurationProperties.getBean(req).getProperty("harvester.location");
|
||||||
if (pathToHarvester == null) {
|
if (pathToHarvester == null) {
|
||||||
log.error("The runtime.properties file does not contain a value for 'harvester.location'");
|
log.error("The runtime.properties file does not contain a value for 'harvester.location'");
|
||||||
return "";
|
return "";
|
||||||
|
@ -217,7 +217,7 @@ public class FileHarvestController extends FreemarkerHttpServlet {
|
||||||
*/
|
*/
|
||||||
private static String getUploadPathBase(ServletContext context) throws Exception
|
private static String getUploadPathBase(ServletContext context) throws Exception
|
||||||
{
|
{
|
||||||
String vitroHomeDirectoryName = ApplicationUtils.instance().getHomeDirectory().getPath().toString();
|
String vitroHomeDirectoryName = ApplicationUtils.instance().getHomeDirectory().getPath().toString();
|
||||||
return vitroHomeDirectoryName + "/" + FileStorageImplWrapper.FILE_STORAGE_SUBDIRECTORY + "/" + PATH_TO_UPLOADS;
|
return vitroHomeDirectoryName + "/" + FileStorageImplWrapper.FILE_STORAGE_SUBDIRECTORY + "/" + PATH_TO_UPLOADS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,7 +419,7 @@ public class FileHarvestController extends FreemarkerHttpServlet {
|
||||||
json = generateJson(true);
|
json = generateJson(true);
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response.getWriter().write(json.toString());
|
response.getWriter().write(json.toString());
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
|
@ -477,8 +477,8 @@ public class FileHarvestController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
//remove all entries in "sessionIdTo..." mappings for this session ID
|
//remove all entries in "sessionIdTo..." mappings for this session ID
|
||||||
clearSessionInfo(sessionId);
|
clearSessionInfo(sessionId);
|
||||||
|
|
||||||
if(sessionInfo.getAbnormalTermination())
|
if(sessionInfo.getAbnormalTermination())
|
||||||
abnormalTermination = true;
|
abnormalTermination = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,7 +500,7 @@ public class FileHarvestController extends FreemarkerHttpServlet {
|
||||||
json = generateJson(true);
|
json = generateJson(true);
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response.getWriter().write(json.toString());
|
response.getWriter().write(json.toString());
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
|
@ -543,9 +543,9 @@ public class FileHarvestController extends FreemarkerHttpServlet {
|
||||||
private static String getScriptFileLocation(HttpServletRequest req) {
|
private static String getScriptFileLocation(HttpServletRequest req) {
|
||||||
return getHarvesterPath(req) + PATH_TO_HARVESTER_SCRIPTS + "temp/";
|
return getHarvesterPath(req) + PATH_TO_HARVESTER_SCRIPTS + "temp/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private File createScriptFile(String scriptFileLocation, String script) throws IOException {
|
private File createScriptFile(String scriptFileLocation, String script) throws IOException {
|
||||||
File scriptDirectory = new File(scriptFileLocation);
|
File scriptDirectory = new File(scriptFileLocation);
|
||||||
if(!scriptDirectory.exists()) {
|
if(!scriptDirectory.exists()) {
|
||||||
|
@ -631,7 +631,7 @@ public class FileHarvestController extends FreemarkerHttpServlet {
|
||||||
Node node = descriptionNodes.item(i);
|
Node node = descriptionNodes.item(i);
|
||||||
|
|
||||||
ArrayList<String> types = getRdfTypes(node);
|
ArrayList<String> types = getRdfTypes(node);
|
||||||
|
|
||||||
boolean match = false;
|
boolean match = false;
|
||||||
String[] validRdfTypesForJob = job.getRdfTypesForLinks();
|
String[] validRdfTypesForJob = job.getRdfTypesForLinks();
|
||||||
for(String rdfType : validRdfTypesForJob) {
|
for(String rdfType : validRdfTypesForJob) {
|
||||||
|
@ -640,7 +640,7 @@ public class FileHarvestController extends FreemarkerHttpServlet {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(match) {
|
if(match) {
|
||||||
|
|
||||||
NamedNodeMap attributes = node.getAttributes();
|
NamedNodeMap attributes = node.getAttributes();
|
||||||
|
@ -795,7 +795,7 @@ public class FileHarvestController extends FreemarkerHttpServlet {
|
||||||
public boolean getAbnormalTermination() {
|
public boolean getAbnormalTermination() {
|
||||||
return abnormalTermination;
|
return abnormalTermination;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finish() {
|
public void finish() {
|
||||||
finished = true;
|
finished = true;
|
||||||
}
|
}
|
||||||
|
@ -833,7 +833,7 @@ public class FileHarvestController extends FreemarkerHttpServlet {
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
this.script = script;
|
this.script = script;
|
||||||
this.additionsFilePath = additionsFilePath;
|
this.additionsFilePath = additionsFilePath;
|
||||||
this.scriptFileLocation = scriptFileLocation;
|
this.scriptFileLocation = scriptFileLocation;
|
||||||
this.job = job;
|
this.job = job;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -863,7 +863,7 @@ public class FileHarvestController extends FreemarkerHttpServlet {
|
||||||
for(String line = processOutputReader.readLine(); line != null; line = processOutputReader.readLine()) {
|
for(String line = processOutputReader.readLine(); line != null; line = processOutputReader.readLine()) {
|
||||||
|
|
||||||
normalTerminationLineFound = line.endsWith(NORMAL_TERMINATION_LAST_OUTPUT); //set every read to ensure it's the last line
|
normalTerminationLineFound = line.endsWith(NORMAL_TERMINATION_LAST_OUTPUT); //set every read to ensure it's the last line
|
||||||
|
|
||||||
//don't add stuff to this list if the main thread is running a "transaction" of copying out the data to send to client and then clearing the list
|
//don't add stuff to this list if the main thread is running a "transaction" of copying out the data to send to client and then clearing the list
|
||||||
synchronized(unsentLogLines) {
|
synchronized(unsentLogLines) {
|
||||||
unsentLogLines.add(line);
|
unsentLogLines.add(line);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.harvester;
|
package edu.cornell.mannlib.vitro.webapp.controller.harvester;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles specifics of a file harvest.
|
* Handles specifics of a file harvest.
|
||||||
* @author mbarbieri
|
* @author mbarbieri
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -26,7 +26,7 @@ interface FileHarvestJob {
|
||||||
String getTemplateFilePath();
|
String getTemplateFilePath();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the console script which can be used to run the harvest job.
|
* Gets the console script which can be used to run the harvest job.
|
||||||
* @return the console script which can be used to run the harvest job
|
* @return the console script which can be used to run the harvest job
|
||||||
*/
|
*/
|
||||||
String getScript();
|
String getScript();
|
||||||
|
@ -44,30 +44,30 @@ interface FileHarvestJob {
|
||||||
String getPageHeader();
|
String getPageHeader();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A heading to be shown above the area where links to profiles of newly-harvested entities are listed.
|
* A heading to be shown above the area where links to profiles of newly-harvested entities are listed.
|
||||||
* @return a heading to be shown above the area where links to profiles of newly-harvested entities are listed
|
* @return a heading to be shown above the area where links to profiles of newly-harvested entities are listed
|
||||||
*/
|
*/
|
||||||
String getLinkHeader();
|
String getLinkHeader();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an array of fully-qualified rdf:type values. When the harvest run is complete, any new entities which have an rdf:type represented
|
* Get an array of fully-qualified rdf:type values. When the harvest run is complete, any new entities which have an rdf:type represented
|
||||||
* in this array will have a link displayed on the page allowing the user to visit the new profile.
|
* in this array will have a link displayed on the page allowing the user to visit the new profile.
|
||||||
* @return an array of types to be used in links
|
* @return an array of types to be used in links
|
||||||
*/
|
*/
|
||||||
String[] getRdfTypesForLinks();
|
String[] getRdfTypesForLinks();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the HTML to be shown on the page immediately next to the "Download" button for the template.
|
* Get the HTML to be shown on the page immediately next to the "Download" button for the template.
|
||||||
* @return the HTML to be shown on the page immediately next to the "Download" button for the template.
|
* @return the HTML to be shown on the page immediately next to the "Download" button for the template.
|
||||||
*/
|
*/
|
||||||
String getTemplateDownloadHelp();
|
String getTemplateDownloadHelp();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the HTML to be shown in the collapsible "Help" area in the "Fill in data" section of the page.
|
* Get the HTML to be shown in the collapsible "Help" area in the "Fill in data" section of the page.
|
||||||
* @return the HTML to be shown in the collapsible "Help" area in the "Fill in data" section of the page.
|
* @return the HTML to be shown in the collapsible "Help" area in the "Fill in data" section of the page.
|
||||||
*/
|
*/
|
||||||
String getTemplateFillInHelp();
|
String getTemplateFillInHelp();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the message to show to the user if there are no newly-harvested entities to show them.
|
* Get the message to show to the user if there are no newly-harvested entities to show them.
|
||||||
* @return the message to show to the user if there are no newly-harvested entities to show them
|
* @return the message to show to the user if there are no newly-harvested entities to show them
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.harvester;
|
package edu.cornell.mannlib.vitro.webapp.controller.harvester;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -47,7 +47,7 @@ import org.vivoweb.harvester.util.XPathTool;
|
||||||
* but that was troublesome for a few reasons, the most important being related to the simple fact that the
|
* but that was troublesome for a few reasons, the most important being related to the simple fact that the
|
||||||
* Harvester was designed to be used as a collection of command-line tools, and thus we have, for example, the
|
* Harvester was designed to be used as a collection of command-line tools, and thus we have, for example, the
|
||||||
* versatility of Score which would be very difficult to replicate without essentially allowing the user to
|
* versatility of Score which would be very difficult to replicate without essentially allowing the user to
|
||||||
* pass in a string to be parsed, which would defeat the purpose.
|
* pass in a string to be parsed, which would defeat the purpose.
|
||||||
*
|
*
|
||||||
* @author mbarbieri
|
* @author mbarbieri
|
||||||
*
|
*
|
||||||
|
@ -81,7 +81,7 @@ class Harvester {
|
||||||
public static void runPubmedHTTPFetch(Object ... args) {
|
public static void runPubmedHTTPFetch(Object ... args) {
|
||||||
PubmedHTTPFetch.main(stringsToArray(args));
|
PubmedHTTPFetch.main(stringsToArray(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
// qualify
|
// qualify
|
||||||
public static void runChangeNamespace(Object ... args) {
|
public static void runChangeNamespace(Object ... args) {
|
||||||
ChangeNamespace.main(stringsToArray(args));
|
ChangeNamespace.main(stringsToArray(args));
|
||||||
|
@ -101,7 +101,7 @@ class Harvester {
|
||||||
public static void runSplitProperty(Object ... args) {
|
public static void runSplitProperty(Object ... args) {
|
||||||
SplitProperty.main(stringsToArray(args));
|
SplitProperty.main(stringsToArray(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
// score
|
// score
|
||||||
public static void runMatch(Object ... args) {
|
public static void runMatch(Object ... args) {
|
||||||
Match.main(stringsToArray(args));
|
Match.main(stringsToArray(args));
|
||||||
|
@ -112,12 +112,12 @@ class Harvester {
|
||||||
public static void runScore(Object ... args) {
|
public static void runScore(Object ... args) {
|
||||||
Score.main(stringsToArray(args));
|
Score.main(stringsToArray(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
// transfer
|
// transfer
|
||||||
public static void runTransfer(Object ... args) {
|
public static void runTransfer(Object ... args) {
|
||||||
Transfer.main(stringsToArray(args));
|
Transfer.main(stringsToArray(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
// translate
|
// translate
|
||||||
public static void runGlozeTranslator(Object ... args) {
|
public static void runGlozeTranslator(Object ... args) {
|
||||||
GlozeTranslator.main(stringsToArray(args));
|
GlozeTranslator.main(stringsToArray(args));
|
||||||
|
@ -153,21 +153,21 @@ class Harvester {
|
||||||
/**
|
/**
|
||||||
* Convenience method to expand the ability to use Java's "..." arg list. Harvester scripts frequently declare sub-macros,
|
* Convenience method to expand the ability to use Java's "..." arg list. Harvester scripts frequently declare sub-macros,
|
||||||
* so for example you might have:
|
* so for example you might have:
|
||||||
*
|
*
|
||||||
* SCOREINPUT="-i $H2MODEL -ImodelName=$MODELNAME -IdbUrl=$MODELDBURL -IcheckEmpty=$CHECKEMPTY"
|
* SCOREINPUT="-i $H2MODEL -ImodelName=$MODELNAME -IdbUrl=$MODELDBURL -IcheckEmpty=$CHECKEMPTY"
|
||||||
* SCOREDATA="-s $H2MODEL -SmodelName=$SCOREDATANAME -SdbUrl=$SCOREDATADBURL -ScheckEmpty=$CHECKEMPTY"
|
* SCOREDATA="-s $H2MODEL -SmodelName=$SCOREDATANAME -SdbUrl=$SCOREDATADBURL -ScheckEmpty=$CHECKEMPTY"
|
||||||
* SCOREMODELS="$SCOREINPUT -v $VIVOCONFIG -VcheckEmpty=$CHECKEMPTY $SCOREDATA -t $TEMPCOPYDIR -b $SCOREBATCHSIZE"
|
* SCOREMODELS="$SCOREINPUT -v $VIVOCONFIG -VcheckEmpty=$CHECKEMPTY $SCOREDATA -t $TEMPCOPYDIR -b $SCOREBATCHSIZE"
|
||||||
* $Score $SCOREMODELS -AGrantNumber=$EQTEST -WGrantNumber=1.0 -FGrantNumber=$GRANTIDNUM -PGrantNumber=$GRANTIDNUM -n ${BASEURI}grant/
|
* $Score $SCOREMODELS -AGrantNumber=$EQTEST -WGrantNumber=1.0 -FGrantNumber=$GRANTIDNUM -PGrantNumber=$GRANTIDNUM -n ${BASEURI}grant/
|
||||||
*
|
*
|
||||||
* In order to mimic this functionality for easy use in Java, this method has been created. It takes a "..." arg list of Object
|
* In order to mimic this functionality for easy use in Java, this method has been created. It takes a "..." arg list of Object
|
||||||
* objects, and returns an array of Strings. For each object, if it's an array of Strings, each String is added to the output
|
* objects, and returns an array of Strings. For each object, if it's an array of Strings, each String is added to the output
|
||||||
* array. Otherwise, its toString() method is called and that value is added to the output array.
|
* array. Otherwise, its toString() method is called and that value is added to the output array.
|
||||||
*
|
*
|
||||||
* It is intended to be used with a combination of String and String[] values, in any arbitrary order.
|
* It is intended to be used with a combination of String and String[] values, in any arbitrary order.
|
||||||
*
|
*
|
||||||
* All static Harvester methods in this class take an Object arg list rather than a String arg list, and automatically call
|
* All static Harvester methods in this class take an Object arg list rather than a String arg list, and automatically call
|
||||||
* this method.
|
* this method.
|
||||||
*
|
*
|
||||||
* @param args an array of objects, which ought to be a combination of String and String[] values, in any arbitrary order
|
* @param args an array of objects, which ought to be a combination of String and String[] values, in any arbitrary order
|
||||||
* @return all the strings put together as one array
|
* @return all the strings put together as one array
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -40,73 +40,73 @@ public class AjaxVisualizationController extends FreemarkerHttpServlet {
|
||||||
public static final String URL_ENCODING_SCHEME = "UTF-8";
|
public static final String URL_ENCODING_SCHEME = "UTF-8";
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(AjaxVisualizationController.class.getName());
|
private static final Log log = LogFactory.getLog(AjaxVisualizationController.class.getName());
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
public static ServletContext servletContext;
|
public static ServletContext servletContext;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Based on the query parameters passed via URI get the appropriate visualization
|
* Based on the query parameters passed via URI get the appropriate visualization
|
||||||
* request handler.
|
* request handler.
|
||||||
* */
|
* */
|
||||||
VisualizationRequestHandler visRequestHandler =
|
VisualizationRequestHandler visRequestHandler =
|
||||||
getVisualizationRequestHandler(vreq);
|
getVisualizationRequestHandler(vreq);
|
||||||
|
|
||||||
if (visRequestHandler != null) {
|
if (visRequestHandler != null) {
|
||||||
|
|
||||||
AuthorizationRequest requiredPrivileges = visRequestHandler.getRequiredPrivileges();
|
AuthorizationRequest requiredPrivileges = visRequestHandler.getRequiredPrivileges();
|
||||||
if (requiredPrivileges != null) {
|
if (requiredPrivileges != null) {
|
||||||
return requiredPrivileges;
|
return requiredPrivileges;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.requiredActions(vreq);
|
return super.requiredActions(vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
|
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
VitroRequest vreq = new VitroRequest(request);
|
||||||
|
|
||||||
Object ajaxResponse = processAjaxRequest(vreq);
|
Object ajaxResponse = processAjaxRequest(vreq);
|
||||||
|
|
||||||
if (ajaxResponse instanceof TemplateResponseValues) {
|
if (ajaxResponse instanceof TemplateResponseValues) {
|
||||||
|
|
||||||
TemplateResponseValues trv = (TemplateResponseValues) ajaxResponse;
|
TemplateResponseValues trv = (TemplateResponseValues) ajaxResponse;
|
||||||
try {
|
try {
|
||||||
writeTemplate(trv.getTemplateName(), trv.getMap(), vreq, response);
|
writeTemplate(trv.getTemplateName(), trv.getMap(), vreq, response);
|
||||||
} catch (TemplateProcessingException e) {
|
} catch (TemplateProcessingException e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
response.getWriter().write(ajaxResponse.toString());
|
response.getWriter().write(ajaxResponse.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object processAjaxRequest(VitroRequest vreq) {
|
private Object processAjaxRequest(VitroRequest vreq) {
|
||||||
/*
|
/*
|
||||||
* Based on the query parameters passed via URI get the appropriate visualization
|
* Based on the query parameters passed via URI get the appropriate visualization
|
||||||
* request handler.
|
* request handler.
|
||||||
* */
|
* */
|
||||||
VisualizationRequestHandler visRequestHandler =
|
VisualizationRequestHandler visRequestHandler =
|
||||||
getVisualizationRequestHandler(vreq);
|
getVisualizationRequestHandler(vreq);
|
||||||
|
|
||||||
if (visRequestHandler != null) {
|
if (visRequestHandler != null) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pass the query to the selected visualization request handler & render the
|
* Pass the query to the selected visualization request handler & render the
|
||||||
* visualization. Since the visualization content is directly added to the response
|
* visualization. Since the visualization content is directly added to the response
|
||||||
* object we are side-effecting this method.
|
* object we are side-effecting this method.
|
||||||
* */
|
* */
|
||||||
return renderVisualization(vreq, visRequestHandler);
|
return renderVisualization(vreq, visRequestHandler);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return UtilityFunctions.handleMalformedParameters(
|
return UtilityFunctions.handleMalformedParameters(
|
||||||
"Visualization Query Error",
|
"Visualization Query Error",
|
||||||
"Inappropriate query parameters were submitted.",
|
"Inappropriate query parameters were submitted.",
|
||||||
|
@ -117,70 +117,70 @@ public class AjaxVisualizationController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
private Object renderVisualization(VitroRequest vitroRequest,
|
private Object renderVisualization(VitroRequest vitroRequest,
|
||||||
VisualizationRequestHandler visRequestHandler) {
|
VisualizationRequestHandler visRequestHandler) {
|
||||||
|
|
||||||
Model model = vitroRequest.getJenaOntModel(); // getModel()
|
Model model = vitroRequest.getJenaOntModel(); // getModel()
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
|
|
||||||
String errorMessage = "This service is not supporeted by the current "
|
String errorMessage = "This service is not supporeted by the current "
|
||||||
+ "webapp configuration. A jena model is required in the "
|
+ "webapp configuration. A jena model is required in the "
|
||||||
+ "servlet context.";
|
+ "servlet context.";
|
||||||
|
|
||||||
log.error(errorMessage);
|
log.error(errorMessage);
|
||||||
|
|
||||||
return UtilityFunctions.handleMalformedParameters("Visualization Query Error",
|
return UtilityFunctions.handleMalformedParameters("Visualization Query Error",
|
||||||
errorMessage,
|
errorMessage,
|
||||||
vitroRequest);
|
vitroRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Dataset dataset = setupJENADataSource(vitroRequest);
|
Dataset dataset = setupJENADataSource(vitroRequest);
|
||||||
|
|
||||||
if (dataset != null && visRequestHandler != null) {
|
if (dataset != null && visRequestHandler != null) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return visRequestHandler.generateAjaxVisualization(vitroRequest,
|
return visRequestHandler.generateAjaxVisualization(vitroRequest,
|
||||||
log,
|
log,
|
||||||
dataset);
|
dataset);
|
||||||
} catch (JsonProcessingException|MalformedQueryParametersException e) {
|
} catch (JsonProcessingException|MalformedQueryParametersException e) {
|
||||||
return UtilityFunctions.handleMalformedParameters(
|
return UtilityFunctions.handleMalformedParameters(
|
||||||
"Ajax Visualization Query Error - Individual Publication Count",
|
"Ajax Visualization Query Error - Individual Publication Count",
|
||||||
e.getMessage(),
|
e.getMessage(),
|
||||||
vitroRequest);
|
vitroRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
String errorMessage = "Data Model Empty &/or Inappropriate "
|
String errorMessage = "Data Model Empty &/or Inappropriate "
|
||||||
+ "query parameters were submitted. ";
|
+ "query parameters were submitted. ";
|
||||||
|
|
||||||
log.error(errorMessage);
|
log.error(errorMessage);
|
||||||
|
|
||||||
return UtilityFunctions.handleMalformedParameters("Visualization Query Error",
|
return UtilityFunctions.handleMalformedParameters("Visualization Query Error",
|
||||||
errorMessage,
|
errorMessage,
|
||||||
vitroRequest);
|
vitroRequest);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private VisualizationRequestHandler getVisualizationRequestHandler(
|
private VisualizationRequestHandler getVisualizationRequestHandler(
|
||||||
VitroRequest vitroRequest) {
|
VitroRequest vitroRequest) {
|
||||||
|
|
||||||
String visType = vitroRequest.getParameter(VisualizationFrameworkConstants
|
String visType = vitroRequest.getParameter(VisualizationFrameworkConstants
|
||||||
.VIS_TYPE_KEY);
|
.VIS_TYPE_KEY);
|
||||||
VisualizationRequestHandler visRequestHandler = null;
|
VisualizationRequestHandler visRequestHandler = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
visRequestHandler = VisualizationsDependencyInjector
|
visRequestHandler = VisualizationsDependencyInjector
|
||||||
.getVisualizationIDsToClassMap(
|
.getVisualizationIDsToClassMap(
|
||||||
getServletContext()).get(visType);
|
getServletContext()).get(visType);
|
||||||
|
|
||||||
} catch (NullPointerException nullKeyException) {
|
} catch (NullPointerException nullKeyException) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return visRequestHandler;
|
return visRequestHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,55 +38,55 @@ public class DataVisualizationController extends VitroHttpServlet {
|
||||||
public static final String URL_ENCODING_SCHEME = "UTF-8";
|
public static final String URL_ENCODING_SCHEME = "UTF-8";
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(DataVisualizationController.class.getName());
|
private static final Log log = LogFactory.getLog(DataVisualizationController.class.getName());
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
public static final String FILE_CONTENT_TYPE_KEY = "fileContentType";
|
public static final String FILE_CONTENT_TYPE_KEY = "fileContentType";
|
||||||
public static final String FILE_CONTENT_KEY = "fileContent";
|
public static final String FILE_CONTENT_KEY = "fileContent";
|
||||||
public static final String FILE_NAME_KEY = "fileName";
|
public static final String FILE_NAME_KEY = "fileName";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
|
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
VitroRequest vreq = new VitroRequest(request);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Based on the query parameters passed via URI get the appropriate visualization
|
* Based on the query parameters passed via URI get the appropriate visualization
|
||||||
* request handler.
|
* request handler.
|
||||||
* */
|
* */
|
||||||
VisualizationRequestHandler visRequestHandler =
|
VisualizationRequestHandler visRequestHandler =
|
||||||
getVisualizationRequestHandler(vreq);
|
getVisualizationRequestHandler(vreq);
|
||||||
|
|
||||||
|
|
||||||
if (visRequestHandler != null) {
|
if (visRequestHandler != null) {
|
||||||
|
|
||||||
if (visRequestHandler.getRequiredPrivileges() != null) {
|
if (visRequestHandler.getRequiredPrivileges() != null) {
|
||||||
if (!isAuthorizedToDisplayPage(request, response, visRequestHandler.getRequiredPrivileges())) {
|
if (!isAuthorizedToDisplayPage(request, response, visRequestHandler.getRequiredPrivileges())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pass the query to the selected visualization request handler & render the vis.
|
* Pass the query to the selected visualization request handler & render the vis.
|
||||||
* Since the visualization content is directly added to the response object we are side-
|
* Since the visualization content is directly added to the response object we are side-
|
||||||
* effecting this method.
|
* effecting this method.
|
||||||
* */
|
* */
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Map<String, String> dataResponse = renderVisualization(vreq, visRequestHandler);
|
Map<String, String> dataResponse = renderVisualization(vreq, visRequestHandler);
|
||||||
|
|
||||||
response.setContentType(dataResponse.get(FILE_CONTENT_TYPE_KEY));
|
response.setContentType(dataResponse.get(FILE_CONTENT_TYPE_KEY));
|
||||||
|
|
||||||
if (dataResponse.containsKey(FILE_NAME_KEY)) {
|
if (dataResponse.containsKey(FILE_NAME_KEY)) {
|
||||||
response.setHeader("Content-Disposition",
|
response.setHeader("Content-Disposition",
|
||||||
"attachment;filename=" + dataResponse.get(FILE_NAME_KEY));
|
"attachment;filename=" + dataResponse.get(FILE_NAME_KEY));
|
||||||
}
|
}
|
||||||
|
|
||||||
response.getWriter().write(dataResponse.get(FILE_CONTENT_KEY));
|
response.getWriter().write(dataResponse.get(FILE_CONTENT_KEY));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} catch (MalformedQueryParametersException e) {
|
} catch (MalformedQueryParametersException e) {
|
||||||
|
|
||||||
UtilityFunctions.handleMalformedParameters(e.getMessage(),
|
UtilityFunctions.handleMalformedParameters(e.getMessage(),
|
||||||
|
@ -95,37 +95,37 @@ public class DataVisualizationController extends VitroHttpServlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
UtilityFunctions.handleMalformedParameters(
|
UtilityFunctions.handleMalformedParameters(
|
||||||
"Inappropriate query parameters were submitted.",
|
"Inappropriate query parameters were submitted.",
|
||||||
response,
|
response,
|
||||||
log);
|
log);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Map<String, String> renderVisualization(
|
private Map<String, String> renderVisualization(
|
||||||
VitroRequest vitroRequest,
|
VitroRequest vitroRequest,
|
||||||
VisualizationRequestHandler visRequestHandler)
|
VisualizationRequestHandler visRequestHandler)
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
|
|
||||||
Model model = vitroRequest.getJenaOntModel(); // getModel()
|
Model model = vitroRequest.getJenaOntModel(); // getModel()
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
|
|
||||||
String errorMessage = "This service is not supporeted by the current "
|
String errorMessage = "This service is not supporeted by the current "
|
||||||
+ "webapp configuration. A jena model is required in the "
|
+ "webapp configuration. A jena model is required in the "
|
||||||
+ "servlet context.";
|
+ "servlet context.";
|
||||||
|
|
||||||
log.error(errorMessage);
|
log.error(errorMessage);
|
||||||
|
|
||||||
throw new MalformedQueryParametersException(errorMessage);
|
throw new MalformedQueryParametersException(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dataset dataset = setupJENADataSource(vitroRequest);
|
Dataset dataset = setupJENADataSource(vitroRequest);
|
||||||
|
|
||||||
if (dataset != null && visRequestHandler != null) {
|
if (dataset != null && visRequestHandler != null) {
|
||||||
try {
|
try {
|
||||||
return visRequestHandler.generateDataVisualization(vitroRequest,
|
return visRequestHandler.generateDataVisualization(vitroRequest,
|
||||||
|
@ -134,7 +134,7 @@ public class DataVisualizationController extends VitroHttpServlet {
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String errorMessage = "Data Model Empty &/or Inappropriate "
|
String errorMessage = "Data Model Empty &/or Inappropriate "
|
||||||
+ "query parameters were submitted. ";
|
+ "query parameters were submitted. ";
|
||||||
|
|
||||||
|
@ -143,21 +143,21 @@ public class DataVisualizationController extends VitroHttpServlet {
|
||||||
|
|
||||||
private VisualizationRequestHandler getVisualizationRequestHandler(
|
private VisualizationRequestHandler getVisualizationRequestHandler(
|
||||||
VitroRequest vitroRequest) {
|
VitroRequest vitroRequest) {
|
||||||
|
|
||||||
String visType = vitroRequest.getParameter(VisualizationFrameworkConstants
|
String visType = vitroRequest.getParameter(VisualizationFrameworkConstants
|
||||||
.VIS_TYPE_KEY);
|
.VIS_TYPE_KEY);
|
||||||
VisualizationRequestHandler visRequestHandler = null;
|
VisualizationRequestHandler visRequestHandler = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
visRequestHandler = VisualizationsDependencyInjector
|
visRequestHandler = VisualizationsDependencyInjector
|
||||||
.getVisualizationIDsToClassMap(getServletContext())
|
.getVisualizationIDsToClassMap(getServletContext())
|
||||||
.get(visType);
|
.get(visType);
|
||||||
|
|
||||||
} catch (NullPointerException nullKeyException) {
|
} catch (NullPointerException nullKeyException) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return visRequestHandler;
|
return visRequestHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequestHandler;
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequestHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Services a standard visualization request, which involves templates. This will return a simple
|
* Services a standard visualization request, which involves templates. This will return a simple
|
||||||
* error message and a 501 if there is no jena Model.
|
* error message and a 501 if there is no jena Model.
|
||||||
*
|
*
|
||||||
* @author cdtank
|
* @author cdtank
|
||||||
|
@ -41,22 +41,22 @@ public class ShortURLVisualizationController extends FreemarkerHttpServlet {
|
||||||
public static final String URL_ENCODING_SCHEME = "UTF-8";
|
public static final String URL_ENCODING_SCHEME = "UTF-8";
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(ShortURLVisualizationController.class.getName());
|
private static final Log log = LogFactory.getLog(ShortURLVisualizationController.class.getName());
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
public static ServletContext servletContext;
|
public static ServletContext servletContext;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
||||||
/*
|
/*
|
||||||
* Based on the query parameters passed via URI get the appropriate visualization
|
* Based on the query parameters passed via URI get the appropriate visualization
|
||||||
* request handler.
|
* request handler.
|
||||||
* */
|
* */
|
||||||
VisualizationRequestHandler visRequestHandler =
|
VisualizationRequestHandler visRequestHandler =
|
||||||
getVisualizationRequestHandler(vreq);
|
getVisualizationRequestHandler(vreq);
|
||||||
|
|
||||||
if (visRequestHandler != null) {
|
if (visRequestHandler != null) {
|
||||||
|
|
||||||
AuthorizationRequest requiredPrivileges = visRequestHandler.getRequiredPrivileges();
|
AuthorizationRequest requiredPrivileges = visRequestHandler.getRequiredPrivileges();
|
||||||
if (requiredPrivileges != null) {
|
if (requiredPrivileges != null) {
|
||||||
return requiredPrivileges;
|
return requiredPrivileges;
|
||||||
|
@ -64,161 +64,161 @@ public class ShortURLVisualizationController extends FreemarkerHttpServlet {
|
||||||
}
|
}
|
||||||
return super.requiredActions(vreq);
|
return super.requiredActions(vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Based on the query parameters passed via URI get the appropriate visualization
|
* Based on the query parameters passed via URI get the appropriate visualization
|
||||||
* request handler.
|
* request handler.
|
||||||
* */
|
* */
|
||||||
VisualizationRequestHandler visRequestHandler =
|
VisualizationRequestHandler visRequestHandler =
|
||||||
getVisualizationRequestHandler(vreq);
|
getVisualizationRequestHandler(vreq);
|
||||||
|
|
||||||
servletContext = getServletContext();
|
servletContext = getServletContext();
|
||||||
|
|
||||||
if (visRequestHandler != null) {
|
if (visRequestHandler != null) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pass the query to the selected visualization request handler & render the vis.
|
* Pass the query to the selected visualization request handler & render the vis.
|
||||||
* Since the visualization content is directly added to the response object we are side-
|
* Since the visualization content is directly added to the response object we are side-
|
||||||
* effecting this method.
|
* effecting this method.
|
||||||
* */
|
* */
|
||||||
return renderVisualization(vreq, visRequestHandler);
|
return renderVisualization(vreq, visRequestHandler);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return UtilityFunctions.handleMalformedParameters(
|
return UtilityFunctions.handleMalformedParameters(
|
||||||
"Visualization Query Error",
|
"Visualization Query Error",
|
||||||
"Inappropriate query parameters were submitted.",
|
"Inappropriate query parameters were submitted.",
|
||||||
vreq);
|
vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ResponseValues renderVisualization(VitroRequest vitroRequest,
|
private ResponseValues renderVisualization(VitroRequest vitroRequest,
|
||||||
VisualizationRequestHandler visRequestHandler) {
|
VisualizationRequestHandler visRequestHandler) {
|
||||||
|
|
||||||
Model model = vitroRequest.getJenaOntModel(); // getModel()
|
Model model = vitroRequest.getJenaOntModel(); // getModel()
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
|
|
||||||
String errorMessage = "This service is not supporeted by the current "
|
String errorMessage = "This service is not supporeted by the current "
|
||||||
+ "webapp configuration. A jena model is required in the "
|
+ "webapp configuration. A jena model is required in the "
|
||||||
+ "servlet context.";
|
+ "servlet context.";
|
||||||
|
|
||||||
log.error(errorMessage);
|
log.error(errorMessage);
|
||||||
|
|
||||||
return UtilityFunctions.handleMalformedParameters("Visualization Query Error",
|
return UtilityFunctions.handleMalformedParameters("Visualization Query Error",
|
||||||
errorMessage,
|
errorMessage,
|
||||||
vitroRequest);
|
vitroRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dataset dataset = setupJENADataSource(vitroRequest);
|
Dataset dataset = setupJENADataSource(vitroRequest);
|
||||||
|
|
||||||
if (dataset != null && visRequestHandler != null) {
|
if (dataset != null && visRequestHandler != null) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<String> matchedPatternGroups = extractShortURLParameters(vitroRequest);
|
List<String> matchedPatternGroups = extractShortURLParameters(vitroRequest);
|
||||||
|
|
||||||
Map<String, String> parametersForVis = getParamatersForVis(matchedPatternGroups, vitroRequest);
|
Map<String, String> parametersForVis = getParamatersForVis(matchedPatternGroups, vitroRequest);
|
||||||
|
|
||||||
return visRequestHandler.generateVisualizationForShortURLRequests(
|
return visRequestHandler.generateVisualizationForShortURLRequests(
|
||||||
parametersForVis,
|
parametersForVis,
|
||||||
vitroRequest,
|
vitroRequest,
|
||||||
log,
|
log,
|
||||||
dataset);
|
dataset);
|
||||||
|
|
||||||
} catch (MalformedQueryParametersException e) {
|
} catch (MalformedQueryParametersException e) {
|
||||||
return UtilityFunctions.handleMalformedParameters(
|
return UtilityFunctions.handleMalformedParameters(
|
||||||
"Standard Visualization Query Error - Individual Publication Count",
|
"Standard Visualization Query Error - Individual Publication Count",
|
||||||
e.getMessage(),
|
e.getMessage(),
|
||||||
vitroRequest);
|
vitroRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
String errorMessage = "Data Model Empty &/or Inappropriate "
|
String errorMessage = "Data Model Empty &/or Inappropriate "
|
||||||
+ "query parameters were submitted. ";
|
+ "query parameters were submitted. ";
|
||||||
|
|
||||||
log.error(errorMessage);
|
log.error(errorMessage);
|
||||||
|
|
||||||
return UtilityFunctions.handleMalformedParameters("Visualization Query Error",
|
return UtilityFunctions.handleMalformedParameters("Visualization Query Error",
|
||||||
errorMessage,
|
errorMessage,
|
||||||
vitroRequest);
|
vitroRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> getParamatersForVis(List<String> matchedPatternGroups,
|
private Map<String, String> getParamatersForVis(List<String> matchedPatternGroups,
|
||||||
VitroRequest vitroRequest) {
|
VitroRequest vitroRequest) {
|
||||||
|
|
||||||
Map<String, String> parameters = new HashMap<String, String>();
|
Map<String, String> parameters = new HashMap<String, String>();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need to convert the short-form URI into a long form. So we use the
|
* We need to convert the short-form URI into a long form. So we use the
|
||||||
* default namespace to construct one.
|
* default namespace to construct one.
|
||||||
* Since VIVO allows non-default namespaces, there are chances that short URLs
|
* Since VIVO allows non-default namespaces, there are chances that short URLs
|
||||||
* will have a "uri" parameter instead of individual uri being part of the formal
|
* will have a "uri" parameter instead of individual uri being part of the formal
|
||||||
* url.
|
* url.
|
||||||
* */
|
* */
|
||||||
String subjectURI = null;
|
String subjectURI = null;
|
||||||
if (matchedPatternGroups.size() <= 1) {
|
if (matchedPatternGroups.size() <= 1) {
|
||||||
|
|
||||||
subjectURI = vitroRequest.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
|
subjectURI = vitroRequest.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
subjectURI = vitroRequest.getWebappDaoFactory().getDefaultNamespace()
|
subjectURI = vitroRequest.getWebappDaoFactory().getDefaultNamespace()
|
||||||
+ matchedPatternGroups.get(1);
|
+ matchedPatternGroups.get(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
subjectURI = StringEscapeUtils.ESCAPE_HTML4.translate(subjectURI);
|
subjectURI = StringEscapeUtils.ESCAPE_HTML4.translate(subjectURI);
|
||||||
parameters.put(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, subjectURI);
|
parameters.put(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, subjectURI);
|
||||||
|
|
||||||
if (VisualizationFrameworkConstants.COAUTHORSHIP_VIS_SHORT_URL
|
if (VisualizationFrameworkConstants.COAUTHORSHIP_VIS_SHORT_URL
|
||||||
.equalsIgnoreCase(matchedPatternGroups.get(0))) {
|
.equalsIgnoreCase(matchedPatternGroups.get(0))) {
|
||||||
|
|
||||||
parameters.put(VisualizationFrameworkConstants.VIS_MODE_KEY,
|
parameters.put(VisualizationFrameworkConstants.VIS_MODE_KEY,
|
||||||
VisualizationFrameworkConstants.COAUTHOR_VIS_MODE);
|
VisualizationFrameworkConstants.COAUTHOR_VIS_MODE);
|
||||||
|
|
||||||
} else if (VisualizationFrameworkConstants.COINVESTIGATOR_VIS_SHORT_URL
|
} else if (VisualizationFrameworkConstants.COINVESTIGATOR_VIS_SHORT_URL
|
||||||
.equalsIgnoreCase(matchedPatternGroups.get(0))) {
|
.equalsIgnoreCase(matchedPatternGroups.get(0))) {
|
||||||
|
|
||||||
parameters.put(VisualizationFrameworkConstants.VIS_MODE_KEY,
|
parameters.put(VisualizationFrameworkConstants.VIS_MODE_KEY,
|
||||||
VisualizationFrameworkConstants.COPI_VIS_MODE);
|
VisualizationFrameworkConstants.COPI_VIS_MODE);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Currently temporal vis for both grants & publications do not require use of
|
* Currently temporal vis for both grants & publications do not require use of
|
||||||
* vis_modes in their request handlers, so no need to provide anything other than
|
* vis_modes in their request handlers, so no need to provide anything other than
|
||||||
* the URI.
|
* the URI.
|
||||||
* */
|
* */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return parameters;
|
return parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private VisualizationRequestHandler getVisualizationRequestHandler(
|
private VisualizationRequestHandler getVisualizationRequestHandler(
|
||||||
VitroRequest vitroRequest) {
|
VitroRequest vitroRequest) {
|
||||||
|
|
||||||
String visType = null;
|
String visType = null;
|
||||||
|
|
||||||
VisualizationRequestHandler visRequestHandler = null;
|
VisualizationRequestHandler visRequestHandler = null;
|
||||||
|
|
||||||
List<String> matchedPatternGroups = extractShortURLParameters(vitroRequest);
|
List<String> matchedPatternGroups = extractShortURLParameters(vitroRequest);
|
||||||
|
|
||||||
if (matchedPatternGroups.size() > 0) {
|
if (matchedPatternGroups.size() > 0) {
|
||||||
|
|
||||||
// System.out.println(matchedPatternGroups.get(0) + " --> " + matchedPatternGroups.get(1));
|
// System.out.println(matchedPatternGroups.get(0) + " --> " + matchedPatternGroups.get(1));
|
||||||
//
|
//
|
||||||
// System.out.println(vitroRequest.getRequestURI()
|
// System.out.println(vitroRequest.getRequestURI()
|
||||||
// + " -- " + vitroRequest.getContextPath()
|
// + " -- " + vitroRequest.getContextPath()
|
||||||
// + " -- " + vitroRequest.getContextPath().length()
|
// + " -- " + vitroRequest.getContextPath().length()
|
||||||
// + " -- " + vitroRequest.getRequestURI().substring(vitroRequest.getContextPath().length()));
|
// + " -- " + vitroRequest.getRequestURI().substring(vitroRequest.getContextPath().length()));
|
||||||
|
|
||||||
visType = matchedPatternGroups.get(0);
|
visType = matchedPatternGroups.get(0);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
visRequestHandler = VisualizationsDependencyInjector
|
visRequestHandler = VisualizationsDependencyInjector
|
||||||
.getVisualizationIDsToClassMap(getServletContext())
|
.getVisualizationIDsToClassMap(getServletContext())
|
||||||
|
@ -228,9 +228,9 @@ public class ShortURLVisualizationController extends FreemarkerHttpServlet {
|
||||||
* Let the default flow take care of returning a null.
|
* Let the default flow take care of returning a null.
|
||||||
* */
|
* */
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return visRequestHandler;
|
return visRequestHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,15 +244,15 @@ public class ShortURLVisualizationController extends FreemarkerHttpServlet {
|
||||||
*/
|
*/
|
||||||
private List<String> extractShortURLParameters(VitroRequest vitroRequest) {
|
private List<String> extractShortURLParameters(VitroRequest vitroRequest) {
|
||||||
|
|
||||||
List<String> matchedGroups = new ArrayList<String>();
|
List<String> matchedGroups = new ArrayList<String>();
|
||||||
String subURIString = vitroRequest.getRequestURI().substring(vitroRequest.getContextPath().length()+1);
|
String subURIString = vitroRequest.getRequestURI().substring(vitroRequest.getContextPath().length()+1);
|
||||||
String[] urlParams = StringEscapeUtils.ESCAPE_HTML4.translate(subURIString).split("/");
|
String[] urlParams = StringEscapeUtils.ESCAPE_HTML4.translate(subURIString).split("/");
|
||||||
|
|
||||||
if (urlParams.length > 1
|
if (urlParams.length > 1
|
||||||
&& urlParams[0].equalsIgnoreCase("vis")) {
|
&& urlParams[0].equalsIgnoreCase("vis")) {
|
||||||
matchedGroups.addAll(Arrays.asList(urlParams).subList(1, urlParams.length));
|
matchedGroups.addAll(Arrays.asList(urlParams).subList(1, urlParams.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
return matchedGroups;
|
return matchedGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequestHandler;
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequestHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Services a standard visualization request, which involves templates. This will return a simple
|
* Services a standard visualization request, which involves templates. This will return a simple
|
||||||
* error message and a 501 if there is no jena Model.
|
* error message and a 501 if there is no jena Model.
|
||||||
*
|
*
|
||||||
* @author cdtank
|
* @author cdtank
|
||||||
|
@ -34,22 +34,22 @@ public class StandardVisualizationController extends FreemarkerHttpServlet {
|
||||||
public static final String URL_ENCODING_SCHEME = "UTF-8";
|
public static final String URL_ENCODING_SCHEME = "UTF-8";
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(StandardVisualizationController.class.getName());
|
private static final Log log = LogFactory.getLog(StandardVisualizationController.class.getName());
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
public static ServletContext servletContext;
|
public static ServletContext servletContext;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
||||||
/*
|
/*
|
||||||
* Based on the query parameters passed via URI get the appropriate visualization
|
* Based on the query parameters passed via URI get the appropriate visualization
|
||||||
* request handler.
|
* request handler.
|
||||||
* */
|
* */
|
||||||
VisualizationRequestHandler visRequestHandler =
|
VisualizationRequestHandler visRequestHandler =
|
||||||
getVisualizationRequestHandler(vreq);
|
getVisualizationRequestHandler(vreq);
|
||||||
|
|
||||||
if (visRequestHandler != null) {
|
if (visRequestHandler != null) {
|
||||||
|
|
||||||
AuthorizationRequest requiredPrivileges = visRequestHandler.getRequiredPrivileges();
|
AuthorizationRequest requiredPrivileges = visRequestHandler.getRequiredPrivileges();
|
||||||
if (requiredPrivileges != null) {
|
if (requiredPrivileges != null) {
|
||||||
return requiredPrivileges;
|
return requiredPrivileges;
|
||||||
|
@ -57,93 +57,93 @@ public class StandardVisualizationController extends FreemarkerHttpServlet {
|
||||||
}
|
}
|
||||||
return super.requiredActions(vreq);
|
return super.requiredActions(vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||||
/*
|
/*
|
||||||
* Based on the query parameters passed via URI get the appropriate visualization
|
* Based on the query parameters passed via URI get the appropriate visualization
|
||||||
* request handler.
|
* request handler.
|
||||||
* */
|
* */
|
||||||
VisualizationRequestHandler visRequestHandler =
|
VisualizationRequestHandler visRequestHandler =
|
||||||
getVisualizationRequestHandler(vreq);
|
getVisualizationRequestHandler(vreq);
|
||||||
|
|
||||||
servletContext = getServletContext();
|
servletContext = getServletContext();
|
||||||
|
|
||||||
if (visRequestHandler != null) {
|
if (visRequestHandler != null) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pass the query to the selected visualization request handler & render the vis.
|
* Pass the query to the selected visualization request handler & render the vis.
|
||||||
* Since the visualization content is directly added to the response object we are side-
|
* Since the visualization content is directly added to the response object we are side-
|
||||||
* effecting this method.
|
* effecting this method.
|
||||||
* */
|
* */
|
||||||
return renderVisualization(vreq, visRequestHandler);
|
return renderVisualization(vreq, visRequestHandler);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return UtilityFunctions.handleMalformedParameters(
|
return UtilityFunctions.handleMalformedParameters(
|
||||||
"Visualization Query Error",
|
"Visualization Query Error",
|
||||||
"Inappropriate query parameters were submitted.",
|
"Inappropriate query parameters were submitted.",
|
||||||
vreq);
|
vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ResponseValues renderVisualization(VitroRequest vitroRequest,
|
private ResponseValues renderVisualization(VitroRequest vitroRequest,
|
||||||
VisualizationRequestHandler visRequestHandler) {
|
VisualizationRequestHandler visRequestHandler) {
|
||||||
|
|
||||||
Model model = vitroRequest.getJenaOntModel(); // getModel()
|
Model model = vitroRequest.getJenaOntModel(); // getModel()
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
|
|
||||||
String errorMessage = "This service is not supporeted by the current "
|
String errorMessage = "This service is not supporeted by the current "
|
||||||
+ "webapp configuration. A jena model is required in the "
|
+ "webapp configuration. A jena model is required in the "
|
||||||
+ "servlet context.";
|
+ "servlet context.";
|
||||||
|
|
||||||
log.error(errorMessage);
|
log.error(errorMessage);
|
||||||
|
|
||||||
return UtilityFunctions.handleMalformedParameters("Visualization Query Error",
|
return UtilityFunctions.handleMalformedParameters("Visualization Query Error",
|
||||||
errorMessage,
|
errorMessage,
|
||||||
vitroRequest);
|
vitroRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Dataset dataset = setupJENADataSource(vitroRequest);
|
Dataset dataset = setupJENADataSource(vitroRequest);
|
||||||
|
|
||||||
if (dataset != null && visRequestHandler != null) {
|
if (dataset != null && visRequestHandler != null) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return visRequestHandler.generateStandardVisualization(vitroRequest,
|
return visRequestHandler.generateStandardVisualization(vitroRequest,
|
||||||
log,
|
log,
|
||||||
dataset);
|
dataset);
|
||||||
} catch (MalformedQueryParametersException e) {
|
} catch (MalformedQueryParametersException e) {
|
||||||
return UtilityFunctions.handleMalformedParameters(
|
return UtilityFunctions.handleMalformedParameters(
|
||||||
"Standard Visualization Query Error - Individual Publication Count",
|
"Standard Visualization Query Error - Individual Publication Count",
|
||||||
e.getMessage(),
|
e.getMessage(),
|
||||||
vitroRequest);
|
vitroRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
String errorMessage = "Data Model Empty &/or Inappropriate "
|
String errorMessage = "Data Model Empty &/or Inappropriate "
|
||||||
+ "query parameters were submitted. ";
|
+ "query parameters were submitted. ";
|
||||||
|
|
||||||
log.error(errorMessage);
|
log.error(errorMessage);
|
||||||
|
|
||||||
return UtilityFunctions.handleMalformedParameters("Visualization Query Error",
|
return UtilityFunctions.handleMalformedParameters("Visualization Query Error",
|
||||||
errorMessage,
|
errorMessage,
|
||||||
vitroRequest);
|
vitroRequest);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private VisualizationRequestHandler getVisualizationRequestHandler(
|
private VisualizationRequestHandler getVisualizationRequestHandler(
|
||||||
VitroRequest vitroRequest) {
|
VitroRequest vitroRequest) {
|
||||||
|
|
||||||
String visType = vitroRequest.getParameter(VisualizationFrameworkConstants
|
String visType = vitroRequest.getParameter(VisualizationFrameworkConstants
|
||||||
.VIS_TYPE_KEY);
|
.VIS_TYPE_KEY);
|
||||||
VisualizationRequestHandler visRequestHandler = null;
|
VisualizationRequestHandler visRequestHandler = null;
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
visRequestHandler = VisualizationsDependencyInjector
|
visRequestHandler = VisualizationsDependencyInjector
|
||||||
.getVisualizationIDsToClassMap(getServletContext())
|
.getVisualizationIDsToClassMap(getServletContext())
|
||||||
|
@ -152,7 +152,7 @@ public class StandardVisualizationController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return visRequestHandler;
|
return visRequestHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,141 +1,141 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.visualization;
|
package edu.cornell.mannlib.vitro.webapp.controller.visualization;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class VisualizationFrameworkConstants {
|
public class VisualizationFrameworkConstants {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Contains the location of bean containing info on all the visualizations
|
* Contains the location of bean containing info on all the visualizations
|
||||||
* available in that instance. Currently it is stored under
|
* available in that instance. Currently it is stored under
|
||||||
* "productMods/WEB-INF..."
|
* "productMods/WEB-INF..."
|
||||||
*/
|
*/
|
||||||
public static final String RELATIVE_LOCATION_OF_VISUALIZATIONS_BEAN =
|
public static final String RELATIVE_LOCATION_OF_VISUALIZATIONS_BEAN =
|
||||||
"/WEB-INF/visualization/visualizations-beans-injection.xml";
|
"/WEB-INF/visualization/visualizations-beans-injection.xml";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Freemarker Version
|
* Freemarker Version
|
||||||
* */
|
* */
|
||||||
public static final String RELATIVE_LOCATION_OF_FM_VISUALIZATIONS_BEAN =
|
public static final String RELATIVE_LOCATION_OF_FM_VISUALIZATIONS_BEAN =
|
||||||
"/WEB-INF/visualization/visualizations-beans-injection-fm.xml";
|
"/WEB-INF/visualization/visualizations-beans-injection-fm.xml";
|
||||||
|
|
||||||
public static final String ERROR_TEMPLATE = "/visualization/visualizationError.ftl";
|
public static final String ERROR_TEMPLATE = "/visualization/visualizationError.ftl";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Vis URL prefix that is seen by all the users
|
* Vis URL prefix that is seen by all the users
|
||||||
*/
|
*/
|
||||||
public static final String VISUALIZATION_URL_PREFIX = "/visualization";
|
public static final String VISUALIZATION_URL_PREFIX = "/visualization";
|
||||||
public static final String SHORT_URL_VISUALIZATION_REQUEST_PREFIX = "/vis";
|
public static final String SHORT_URL_VISUALIZATION_REQUEST_PREFIX = "/vis";
|
||||||
|
|
||||||
public static final String FREEMARKERIZED_VISUALIZATION_URL_PREFIX = "/visualization";
|
public static final String FREEMARKERIZED_VISUALIZATION_URL_PREFIX = "/visualization";
|
||||||
public static final String AJAX_VISUALIZATION_SERVICE_URL_PREFIX = "/visualizationAjax";
|
public static final String AJAX_VISUALIZATION_SERVICE_URL_PREFIX = "/visualizationAjax";
|
||||||
public static final String DATA_VISUALIZATION_SERVICE_URL_PREFIX = "/visualizationData";
|
public static final String DATA_VISUALIZATION_SERVICE_URL_PREFIX = "/visualizationData";
|
||||||
|
|
||||||
public static final String INDIVIDUAL_URL_PREFIX = "/individual";
|
public static final String INDIVIDUAL_URL_PREFIX = "/individual";
|
||||||
|
|
||||||
|
|
||||||
public static final Pattern SHORT_URL_REQUEST_PATTERN = Pattern
|
public static final Pattern SHORT_URL_REQUEST_PATTERN = Pattern
|
||||||
.compile("^"
|
.compile("^"
|
||||||
+ SHORT_URL_VISUALIZATION_REQUEST_PREFIX
|
+ SHORT_URL_VISUALIZATION_REQUEST_PREFIX
|
||||||
+ "/([\\w-]+)/([^/]*)$");
|
+ "/([\\w-]+)/([^/]*)$");
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These represent possible query keys in a URI for visualization purposes.
|
* These represent possible query keys in a URI for visualization purposes.
|
||||||
* Examples,
|
* Examples,
|
||||||
* 1. http://vivo.indiana.edu/visualization?uri=http://vivoweb.org/ontology/core/Person10979&vis=person_level&render_mode=standalone
|
* 1. http://vivo.indiana.edu/visualization?uri=http://vivoweb.org/ontology/core/Person10979&vis=person_level&render_mode=standalone
|
||||||
* 2. http://vivo.indiana.edu/visualization?uri=http://vivoweb.org/ontology/core/Person72&vis=person_pub_count&render_mode=dynamic&container=vis_container
|
* 2. http://vivo.indiana.edu/visualization?uri=http://vivoweb.org/ontology/core/Person72&vis=person_pub_count&render_mode=dynamic&container=vis_container
|
||||||
* */
|
* */
|
||||||
public static final String VIS_TYPE_KEY = "vis";
|
public static final String VIS_TYPE_KEY = "vis";
|
||||||
public static final String VIS_CONTAINER_KEY = "container";
|
public static final String VIS_CONTAINER_KEY = "container";
|
||||||
public static final String INDIVIDUAL_URI_KEY = "uri";
|
public static final String INDIVIDUAL_URI_KEY = "uri";
|
||||||
public static final String VIS_MODE_KEY = "vis_mode";
|
public static final String VIS_MODE_KEY = "vis_mode";
|
||||||
public static final String RENDER_MODE_KEY = "render_mode";
|
public static final String RENDER_MODE_KEY = "render_mode";
|
||||||
public static final String OUTPUT_FORMAT_KEY = "output";
|
public static final String OUTPUT_FORMAT_KEY = "output";
|
||||||
public static final String REQUESTING_TEMPLATE_KEY = "template"; /* tlw72 - added in 1.6 for multi-view support */
|
public static final String REQUESTING_TEMPLATE_KEY = "template"; /* tlw72 - added in 1.6 for multi-view support */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These values represent possible render modes.
|
* These values represent possible render modes.
|
||||||
* */
|
* */
|
||||||
public static final String STANDALONE_RENDER_MODE = "standalone";
|
public static final String STANDALONE_RENDER_MODE = "standalone";
|
||||||
public static final String DYNAMIC_RENDER_MODE = "dynamic";
|
public static final String DYNAMIC_RENDER_MODE = "dynamic";
|
||||||
public static final String DATA_RENDER_MODE = "data";
|
public static final String DATA_RENDER_MODE = "data";
|
||||||
public static final String PDF_RENDER_MODE = "pdf";
|
public static final String PDF_RENDER_MODE = "pdf";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These values represent possible sub-vis modes.
|
* These values represent possible sub-vis modes.
|
||||||
* */
|
* */
|
||||||
public static final String IMAGE_VIS_MODE = "image";
|
public static final String IMAGE_VIS_MODE = "image";
|
||||||
public static final String SHORT_SPARKLINE_VIS_MODE = "short";
|
public static final String SHORT_SPARKLINE_VIS_MODE = "short";
|
||||||
public static final String FULL_SPARKLINE_VIS_MODE = "full";
|
public static final String FULL_SPARKLINE_VIS_MODE = "full";
|
||||||
public static final String COPI_VIS_MODE = "copi";
|
public static final String COPI_VIS_MODE = "copi";
|
||||||
public static final String COAUTHOR_VIS_MODE = "coauthor";
|
public static final String COAUTHOR_VIS_MODE = "coauthor";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Vis modes for CoauthorshipRequest Handler
|
* Vis modes for CoauthorshipRequest Handler
|
||||||
* */
|
* */
|
||||||
public static final String COAUTHORS_COUNT_PER_YEAR_VIS_MODE = "coauthors_count_per_year";
|
public static final String COAUTHORS_COUNT_PER_YEAR_VIS_MODE = "coauthors_count_per_year";
|
||||||
public static final String COAUTHORS_LIST_VIS_MODE = "coauthors";
|
public static final String COAUTHORS_LIST_VIS_MODE = "coauthors";
|
||||||
public static final String COAUTHOR_NETWORK_STREAM_VIS_MODE = "coauthor_network_stream";
|
public static final String COAUTHOR_NETWORK_STREAM_VIS_MODE = "coauthor_network_stream";
|
||||||
public static final String COAUTHOR_NETWORK_DOWNLOAD_VIS_MODE = "coauthor_network_download";
|
public static final String COAUTHOR_NETWORK_DOWNLOAD_VIS_MODE = "coauthor_network_download";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Vis modes for CoPIRequest Handler
|
* Vis modes for CoPIRequest Handler
|
||||||
* */
|
* */
|
||||||
public static final String COPIS_COUNT_PER_YEAR_VIS_MODE = "copis_count_per_year";
|
public static final String COPIS_COUNT_PER_YEAR_VIS_MODE = "copis_count_per_year";
|
||||||
public static final String COPIS_LIST_VIS_MODE = "copis";
|
public static final String COPIS_LIST_VIS_MODE = "copis";
|
||||||
public static final String COPI_NETWORK_STREAM_VIS_MODE = "copi_network_stream";
|
public static final String COPI_NETWORK_STREAM_VIS_MODE = "copi_network_stream";
|
||||||
public static final String COPI_NETWORK_DOWNLOAD_VIS_MODE = "copi_network_download";
|
public static final String COPI_NETWORK_DOWNLOAD_VIS_MODE = "copi_network_download";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Vis modes for Map of Science Handler
|
* Vis modes for Map of Science Handler
|
||||||
* */
|
* */
|
||||||
public static final String DISCIPLINE_TO_ACTIVTY_VIS_MODE = "discipline";
|
public static final String DISCIPLINE_TO_ACTIVTY_VIS_MODE = "discipline";
|
||||||
public static final String SUBDISCIPLINE_TO_ACTIVTY_VIS_MODE = "subdiscipline";
|
public static final String SUBDISCIPLINE_TO_ACTIVTY_VIS_MODE = "subdiscipline";
|
||||||
public static final String SCIENCE_UNLOCATED_JOURNALS_VIS_MODE = "unlocated_journals";
|
public static final String SCIENCE_UNLOCATED_JOURNALS_VIS_MODE = "unlocated_journals";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These values represent possible utilities vis modes.
|
* These values represent possible utilities vis modes.
|
||||||
* */
|
* */
|
||||||
public static final String PROFILE_INFO_UTILS_VIS_MODE = "PROFILE_INFO";
|
public static final String PROFILE_INFO_UTILS_VIS_MODE = "PROFILE_INFO";
|
||||||
public static final String PROFILE_UTILS_VIS_MODE = "PROFILE_URL";
|
public static final String PROFILE_UTILS_VIS_MODE = "PROFILE_URL";
|
||||||
public static final String COAUTHOR_UTILS_VIS_MODE = "COAUTHORSHIP_URL";
|
public static final String COAUTHOR_UTILS_VIS_MODE = "COAUTHORSHIP_URL";
|
||||||
public static final String PERSON_LEVEL_UTILS_VIS_MODE = "PERSON_LEVEL_URL";
|
public static final String PERSON_LEVEL_UTILS_VIS_MODE = "PERSON_LEVEL_URL";
|
||||||
public static final String COPI_UTILS_VIS_MODE = "COPI_URL";
|
public static final String COPI_UTILS_VIS_MODE = "COPI_URL";
|
||||||
public static final String IMAGE_UTILS_VIS_MODE = "IMAGE_URL";
|
public static final String IMAGE_UTILS_VIS_MODE = "IMAGE_URL";
|
||||||
public static final String ARE_PUBLICATIONS_AVAILABLE_UTILS_VIS_MODE = "SHOW_AUTHORSHIP_LINK";
|
public static final String ARE_PUBLICATIONS_AVAILABLE_UTILS_VIS_MODE = "SHOW_AUTHORSHIP_LINK";
|
||||||
public static final String ARE_GRANTS_AVAILABLE_UTILS_VIS_MODE = "SHOW_GRANTS_LINK";
|
public static final String ARE_GRANTS_AVAILABLE_UTILS_VIS_MODE = "SHOW_GRANTS_LINK";
|
||||||
public static final String UNIVERSITY_COMPARISON_VIS_MODE = "UNIVERSITY";
|
public static final String UNIVERSITY_COMPARISON_VIS_MODE = "UNIVERSITY";
|
||||||
public static final String SCHOOL_COMPARISON_VIS_MODE = "SCHOOL";
|
public static final String SCHOOL_COMPARISON_VIS_MODE = "SCHOOL";
|
||||||
public static final String DEPARTMENT_COMPARISON_VIS_MODE = "DEPARTMENT";
|
public static final String DEPARTMENT_COMPARISON_VIS_MODE = "DEPARTMENT";
|
||||||
public static final String HIGHEST_LEVEL_ORGANIZATION_VIS_MODE = "HIGHEST_LEVEL_ORGANIZATION";
|
public static final String HIGHEST_LEVEL_ORGANIZATION_VIS_MODE = "HIGHEST_LEVEL_ORGANIZATION";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These values represent possible visualizations provided as values to the "vis" url key.
|
* These values represent possible visualizations provided as values to the "vis" url key.
|
||||||
* */
|
* */
|
||||||
public static final String PERSON_PUBLICATION_COUNT_VIS = "person_pub_count";
|
public static final String PERSON_PUBLICATION_COUNT_VIS = "person_pub_count";
|
||||||
public static final String PERSON_GRANT_COUNT_VIS = "person_grant_count";
|
public static final String PERSON_GRANT_COUNT_VIS = "person_grant_count";
|
||||||
public static final String PDF_REPORT_VIS = "pdf_report";
|
public static final String PDF_REPORT_VIS = "pdf_report";
|
||||||
public static final String COLLEGE_PUBLICATION_COUNT_VIS = "college_pub_count";
|
public static final String COLLEGE_PUBLICATION_COUNT_VIS = "college_pub_count";
|
||||||
public static final String COAUTHORSHIP_VIS = "coauthorship";
|
public static final String COAUTHORSHIP_VIS = "coauthorship";
|
||||||
public static final String PERSON_LEVEL_VIS = "person_level";
|
public static final String PERSON_LEVEL_VIS = "person_level";
|
||||||
public static final String COAUTHORSHIP_VIS_SHORT_URL = "author-network";
|
public static final String COAUTHORSHIP_VIS_SHORT_URL = "author-network";
|
||||||
public static final String COINVESTIGATOR_VIS_SHORT_URL = "investigator-network";
|
public static final String COINVESTIGATOR_VIS_SHORT_URL = "investigator-network";
|
||||||
public static final String UTILITIES_VIS = "utilities";
|
public static final String UTILITIES_VIS = "utilities";
|
||||||
public static final String ENTITY_COMPARISON_VIS = "entity_comparison";
|
public static final String ENTITY_COMPARISON_VIS = "entity_comparison";
|
||||||
public static final String PUBLICATION_TEMPORAL_VIS_SHORT_URL = "publication-graph";
|
public static final String PUBLICATION_TEMPORAL_VIS_SHORT_URL = "publication-graph";
|
||||||
public static final String MAP_OF_SCIENCE_VIS_SHORT_URL = "map-of-science";
|
public static final String MAP_OF_SCIENCE_VIS_SHORT_URL = "map-of-science";
|
||||||
public static final String GRANT_TEMPORAL_VIS_SHORT_URL = "grant-graph";
|
public static final String GRANT_TEMPORAL_VIS_SHORT_URL = "grant-graph";
|
||||||
public static final String CO_PI_VIS = "coprincipalinvestigator";
|
public static final String CO_PI_VIS = "coprincipalinvestigator";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These values represent possible data serialization formats corresponding to
|
* These values represent possible data serialization formats corresponding to
|
||||||
* output format key.
|
* output format key.
|
||||||
* */
|
* */
|
||||||
public static final String JSON_OUTPUT_FORMAT = "json";
|
public static final String JSON_OUTPUT_FORMAT = "json";
|
||||||
public static final String CSV_OUTPUT_FORMAT = "csv";
|
public static final String CSV_OUTPUT_FORMAT = "csv";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.visualization;
|
package edu.cornell.mannlib.vitro.webapp.controller.visualization;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequestHandler;
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequestHandler;
|
||||||
|
|
||||||
public class VisualizationInjector {
|
public class VisualizationInjector {
|
||||||
private Map<String, VisualizationRequestHandler> visualizationIDToClass;
|
private Map<String, VisualizationRequestHandler> visualizationIDToClass;
|
||||||
|
|
||||||
public Map<String, VisualizationRequestHandler> getVisualizationIDToClass() {
|
public Map<String, VisualizationRequestHandler> getVisualizationIDToClass() {
|
||||||
return visualizationIDToClass;
|
return visualizationIDToClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVisualizations(Map<String, VisualizationRequestHandler> visualizationIDToClass) {
|
public void setVisualizations(Map<String, VisualizationRequestHandler> visualizationIDToClass) {
|
||||||
this.visualizationIDToClass = visualizationIDToClass;
|
this.visualizationIDToClass = visualizationIDToClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,18 +12,18 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequestHandler;
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequestHandler;
|
||||||
|
|
||||||
public class VisualizationsDependencyInjector {
|
public class VisualizationsDependencyInjector {
|
||||||
|
|
||||||
private static Map<String, VisualizationRequestHandler> visualizationIDsToClass;
|
private static Map<String, VisualizationRequestHandler> visualizationIDsToClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used to inject vis dependencies i.e. the vis algorithms that are
|
* This method is used to inject vis dependencies i.e. the vis algorithms that are
|
||||||
* being implemented into the vis controller. Modified Dependency Injection pattern is
|
* being implemented into the vis controller. Modified Dependency Injection pattern is
|
||||||
* used here. XML file containing the location of all the vis is saved in accessible folder.
|
* used here. XML file containing the location of all the vis is saved in accessible folder.
|
||||||
* @param servletContext Servlet context
|
* @param servletContext Servlet context
|
||||||
*/
|
*/
|
||||||
private synchronized static Map<String, VisualizationRequestHandler> initVisualizations(
|
private synchronized static Map<String, VisualizationRequestHandler> initVisualizations(
|
||||||
ServletContext servletContext) {
|
ServletContext servletContext) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A visualization request has already been made causing the visualizationIDsToClass to be
|
* A visualization request has already been made causing the visualizationIDsToClass to be
|
||||||
* initiated & populated with visualization ids to its request handlers.
|
* initiated & populated with visualization ids to its request handlers.
|
||||||
|
@ -31,26 +31,26 @@ public class VisualizationsDependencyInjector {
|
||||||
if (visualizationIDsToClass != null) {
|
if (visualizationIDsToClass != null) {
|
||||||
return visualizationIDsToClass;
|
return visualizationIDsToClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
String resourcePath =
|
String resourcePath =
|
||||||
servletContext
|
servletContext
|
||||||
.getRealPath(VisualizationFrameworkConstants
|
.getRealPath(VisualizationFrameworkConstants
|
||||||
.RELATIVE_LOCATION_OF_FM_VISUALIZATIONS_BEAN);
|
.RELATIVE_LOCATION_OF_FM_VISUALIZATIONS_BEAN);
|
||||||
|
|
||||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||||
"file:" + resourcePath);
|
"file:" + resourcePath);
|
||||||
|
|
||||||
BeanFactory factory = context;
|
BeanFactory factory = context;
|
||||||
|
|
||||||
VisualizationInjector visualizationInjector =
|
VisualizationInjector visualizationInjector =
|
||||||
(VisualizationInjector) factory.getBean("visualizationInjector");
|
(VisualizationInjector) factory.getBean("visualizationInjector");
|
||||||
|
|
||||||
visualizationIDsToClass = visualizationInjector.getVisualizationIDToClass();
|
visualizationIDsToClass = visualizationInjector.getVisualizationIDToClass();
|
||||||
|
|
||||||
|
|
||||||
return visualizationIDsToClass;
|
return visualizationIDsToClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, VisualizationRequestHandler> getVisualizationIDsToClassMap(
|
public static Map<String, VisualizationRequestHandler> getVisualizationIDsToClassMap(
|
||||||
ServletContext servletContext) {
|
ServletContext servletContext) {
|
||||||
if (visualizationIDsToClass != null) {
|
if (visualizationIDsToClass != null) {
|
||||||
|
|
|
@ -15,25 +15,25 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmis
|
||||||
public class AutocompleteRequiredInputValidator implements N3ValidatorVTwo {
|
public class AutocompleteRequiredInputValidator implements N3ValidatorVTwo {
|
||||||
|
|
||||||
private static String MISSING_LABEL_ERROR = "Please select an existing value or enter a new value in the Name field.";
|
private static String MISSING_LABEL_ERROR = "Please select an existing value or enter a new value in the Name field.";
|
||||||
|
|
||||||
private String uriReceiver;
|
private String uriReceiver;
|
||||||
private String labelInput;
|
private String labelInput;
|
||||||
|
|
||||||
public AutocompleteRequiredInputValidator(String uriReceiver, String labelInput) {
|
public AutocompleteRequiredInputValidator(String uriReceiver, String labelInput) {
|
||||||
this.uriReceiver = uriReceiver;
|
this.uriReceiver = uriReceiver;
|
||||||
this.labelInput = labelInput;
|
this.labelInput = labelInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> validate(EditConfigurationVTwo editConfig,
|
public Map<String, String> validate(EditConfigurationVTwo editConfig,
|
||||||
MultiValueEditSubmission editSub) {
|
MultiValueEditSubmission editSub) {
|
||||||
Map<String,List<String>> urisFromForm = editSub.getUrisFromForm();
|
Map<String,List<String>> urisFromForm = editSub.getUrisFromForm();
|
||||||
Map<String,List<Literal>> literalsFromForm = editSub.getLiteralsFromForm();
|
Map<String,List<Literal>> literalsFromForm = editSub.getLiteralsFromForm();
|
||||||
|
|
||||||
Map<String,String> errors = new HashMap<String,String>();
|
Map<String,String> errors = new HashMap<String,String>();
|
||||||
|
|
||||||
List<String> selectedUri = urisFromForm.get(uriReceiver);
|
List<String> selectedUri = urisFromForm.get(uriReceiver);
|
||||||
|
|
||||||
// If there's a presentationUri, then we're done. If not, check to see if the label exists.
|
// If there's a presentationUri, then we're done. If not, check to see if the label exists.
|
||||||
// If that's null, too, it's an error.
|
// If that's null, too, it's an error.
|
||||||
if (allListElementsEmpty(selectedUri) || selectedUri.contains(">SUBMITTED VALUE WAS BLANK<")) {
|
if (allListElementsEmpty(selectedUri) || selectedUri.contains(">SUBMITTED VALUE WAS BLANK<")) {
|
||||||
|
@ -50,11 +50,11 @@ public class AutocompleteRequiredInputValidator implements N3ValidatorVTwo {
|
||||||
else {
|
else {
|
||||||
errors.put(labelInput, MISSING_LABEL_ERROR);
|
errors.put(labelInput, MISSING_LABEL_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.size() != 0 ? errors : null;
|
return errors.size() != 0 ? errors : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean allListElementsEmpty(List<String> checkList) {
|
private boolean allListElementsEmpty(List<String> checkList) {
|
||||||
if(checkList == null)
|
if(checkList == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -18,19 +18,19 @@ public class FirstAndLastNameValidator implements N3ValidatorVTwo {
|
||||||
private static String MISSING_LAST_NAME_ERROR = "You must enter a value in the Last Name field.";
|
private static String MISSING_LAST_NAME_ERROR = "You must enter a value in the Last Name field.";
|
||||||
private static String MALFORMED_LAST_NAME_ERROR = "The last name field may not contain a comma. Please enter first name in First Name field.";
|
private static String MALFORMED_LAST_NAME_ERROR = "The last name field may not contain a comma. Please enter first name in First Name field.";
|
||||||
private String uriReceiver;
|
private String uriReceiver;
|
||||||
|
|
||||||
public FirstAndLastNameValidator(String uriReceiver) {
|
public FirstAndLastNameValidator(String uriReceiver) {
|
||||||
this.uriReceiver = uriReceiver;
|
this.uriReceiver = uriReceiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> validate(EditConfigurationVTwo editConfig,
|
public Map<String, String> validate(EditConfigurationVTwo editConfig,
|
||||||
MultiValueEditSubmission editSub) {
|
MultiValueEditSubmission editSub) {
|
||||||
Map<String,List<String>> urisFromForm = editSub.getUrisFromForm();
|
Map<String,List<String>> urisFromForm = editSub.getUrisFromForm();
|
||||||
Map<String,List<Literal>> literalsFromForm = editSub.getLiteralsFromForm();
|
Map<String,List<Literal>> literalsFromForm = editSub.getLiteralsFromForm();
|
||||||
|
|
||||||
Map<String,String> errors = new HashMap<String,String>();
|
Map<String,String> errors = new HashMap<String,String>();
|
||||||
|
|
||||||
List<String> personUri = urisFromForm.get(uriReceiver);
|
List<String> personUri = urisFromForm.get(uriReceiver);
|
||||||
if (allListElementsEmpty(personUri) || personUri.contains(">SUBMITTED VALUE WAS BLANK<")) {
|
if (allListElementsEmpty(personUri) || personUri.contains(">SUBMITTED VALUE WAS BLANK<")) {
|
||||||
personUri = null;
|
personUri = null;
|
||||||
|
@ -40,7 +40,7 @@ public class FirstAndLastNameValidator implements N3ValidatorVTwo {
|
||||||
if (personUri != null) {
|
if (personUri != null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Expecting only one first name in this case
|
//Expecting only one first name in this case
|
||||||
//To Do: update logic if multiple first names considered
|
//To Do: update logic if multiple first names considered
|
||||||
Literal firstName = null;
|
Literal firstName = null;
|
||||||
|
@ -48,8 +48,8 @@ public class FirstAndLastNameValidator implements N3ValidatorVTwo {
|
||||||
if(firstNameList != null && firstNameList.size() > 0) {
|
if(firstNameList != null && firstNameList.size() > 0) {
|
||||||
firstName = firstNameList.get(0);
|
firstName = firstNameList.get(0);
|
||||||
}
|
}
|
||||||
if( firstName != null &&
|
if( firstName != null &&
|
||||||
firstName.getLexicalForm() != null &&
|
firstName.getLexicalForm() != null &&
|
||||||
"".equals(firstName.getLexicalForm()) )
|
"".equals(firstName.getLexicalForm()) )
|
||||||
firstName = null;
|
firstName = null;
|
||||||
|
|
||||||
|
@ -70,17 +70,17 @@ public class FirstAndLastNameValidator implements N3ValidatorVTwo {
|
||||||
if (lastName == null) {
|
if (lastName == null) {
|
||||||
errors.put("lastName", MISSING_LAST_NAME_ERROR);
|
errors.put("lastName", MISSING_LAST_NAME_ERROR);
|
||||||
// Don't reject space in the last name: de Vries, etc.
|
// Don't reject space in the last name: de Vries, etc.
|
||||||
} else if (lastNameValue.contains(",")) {
|
} else if (lastNameValue.contains(",")) {
|
||||||
errors.put("lastName", MALFORMED_LAST_NAME_ERROR);
|
errors.put("lastName", MALFORMED_LAST_NAME_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstName == null) {
|
if (firstName == null) {
|
||||||
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
|
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.size() != 0 ? errors : null;
|
return errors.size() != 0 ? errors : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean allListElementsEmpty(List<String> checkList) {
|
private boolean allListElementsEmpty(List<String> checkList) {
|
||||||
if(checkList == null)
|
if(checkList == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -4,7 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class N3TransitionToV2Mapping extends HashMap<String, String>{
|
public class N3TransitionToV2Mapping extends HashMap<String, String>{
|
||||||
public N3TransitionToV2Mapping(){
|
public N3TransitionToV2Mapping(){
|
||||||
Map<String,String> map = this;
|
Map<String,String> map = this;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ public class N3TransitionToV2Mapping extends HashMap<String, String>{
|
||||||
|
|
||||||
// vivo forms:
|
// vivo forms:
|
||||||
|
|
||||||
map.put("addAuthorsToInformationResource.jsp",
|
map.put("addAuthorsToInformationResource.jsp",
|
||||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddAuthorsToInformationResourceGenerator.class.getName());
|
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddAuthorsToInformationResourceGenerator.class.getName());
|
||||||
map.put("manageWebpagesForIndividual.jsp",
|
map.put("manageWebpagesForIndividual.jsp",
|
||||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManageWebpagesForIndividualGenerator.class.getName());
|
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManageWebpagesForIndividualGenerator.class.getName());
|
||||||
|
@ -24,7 +24,7 @@ public class N3TransitionToV2Mapping extends HashMap<String, String>{
|
||||||
map.put("personHasEducationalTraining.jsp",
|
map.put("personHasEducationalTraining.jsp",
|
||||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.PersonHasEducationalTraining.class.getName());
|
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.PersonHasEducationalTraining.class.getName());
|
||||||
map.put("personHasPositionHistory.jsp",
|
map.put("personHasPositionHistory.jsp",
|
||||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.PersonHasPositionHistoryGenerator.class.getName());
|
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.PersonHasPositionHistoryGenerator.class.getName());
|
||||||
map.put("addGrantRoleToPerson.jsp",
|
map.put("addGrantRoleToPerson.jsp",
|
||||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddGrantRoleToPersonGenerator.class.getName());
|
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddGrantRoleToPersonGenerator.class.getName());
|
||||||
map.put("addEditWebpageForm.jsp",
|
map.put("addEditWebpageForm.jsp",
|
||||||
|
@ -34,12 +34,12 @@ public class N3TransitionToV2Mapping extends HashMap<String, String>{
|
||||||
|
|
||||||
// map.put("terminologyAnnotation.jsp",
|
// map.put("terminologyAnnotation.jsp",
|
||||||
// edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.TerminologyAnnotationGenerator.class.getName());
|
// edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.TerminologyAnnotationGenerator.class.getName());
|
||||||
//
|
//
|
||||||
// map.put("redirectToPublication.jsp",
|
// map.put("redirectToPublication.jsp",
|
||||||
// edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.RedirectToPublicationGenerator.class.getName());
|
// edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.RedirectToPublicationGenerator.class.getName());
|
||||||
// map.put("unsupportedBrowserMessage.jsp",
|
// map.put("unsupportedBrowserMessage.jsp",
|
||||||
// edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.UnsupportedBrowserMessage.class.getName());
|
// edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.UnsupportedBrowserMessage.class.getName());
|
||||||
//
|
//
|
||||||
// vivo 2 stage role forms:
|
// vivo 2 stage role forms:
|
||||||
|
|
||||||
map.put("addAttendeeRoleToPerson.jsp",
|
map.put("addAttendeeRoleToPerson.jsp",
|
||||||
|
@ -57,7 +57,7 @@ public class N3TransitionToV2Mapping extends HashMap<String, String>{
|
||||||
map.put("addOutreachRoleToPerson.jsp",
|
map.put("addOutreachRoleToPerson.jsp",
|
||||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddOutreachProviderRoleToPersonGenerator.class.getName());
|
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddOutreachProviderRoleToPersonGenerator.class.getName());
|
||||||
map.put("addPresenterRoleToPerson.jsp",
|
map.put("addPresenterRoleToPerson.jsp",
|
||||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddPresenterRoleToPersonGenerator.class.getName());
|
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddPresenterRoleToPersonGenerator.class.getName());
|
||||||
map.put("addResearcherRoleToPerson.jsp",
|
map.put("addResearcherRoleToPerson.jsp",
|
||||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddResearcherRoleToPersonGenerator.class.getName());
|
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddResearcherRoleToPersonGenerator.class.getName());
|
||||||
map.put("addReviewerRoleToPerson.jsp",
|
map.put("addReviewerRoleToPerson.jsp",
|
||||||
|
@ -68,6 +68,6 @@ public class N3TransitionToV2Mapping extends HashMap<String, String>{
|
||||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddServiceProviderRoleToPersonGenerator.class.getName());
|
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddServiceProviderRoleToPersonGenerator.class.getName());
|
||||||
map.put("addTeacherRoleToPerson.jsp",
|
map.put("addTeacherRoleToPerson.jsp",
|
||||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddTeacherRoleToPersonGenerator.class.getName());
|
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddTeacherRoleToPersonGenerator.class.getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class PersonHasPublicationValidator implements N3ValidatorVTwo {
|
||||||
private static String MISSING_FIRST_NAME_ERROR = "You must enter a value in the First Name field.";
|
private static String MISSING_FIRST_NAME_ERROR = "You must enter a value in the First Name field.";
|
||||||
private static String MISSING_LAST_NAME_ERROR = "You must enter a value in the Last Name field.";
|
private static String MISSING_LAST_NAME_ERROR = "You must enter a value in the Last Name field.";
|
||||||
private static String MALFORMED_LAST_NAME_ERROR = "The last name field may not contain a comma. Please enter first name in First Name field.";
|
private static String MALFORMED_LAST_NAME_ERROR = "The last name field may not contain a comma. Please enter first name in First Name field.";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> validate(EditConfigurationVTwo editConfig,
|
public Map<String, String> validate(EditConfigurationVTwo editConfig,
|
||||||
MultiValueEditSubmission editSub) {
|
MultiValueEditSubmission editSub) {
|
||||||
|
@ -30,11 +30,11 @@ public class PersonHasPublicationValidator implements N3ValidatorVTwo {
|
||||||
Map<String,List<String>> urisFromForm = editSub.getUrisFromForm();
|
Map<String,List<String>> urisFromForm = editSub.getUrisFromForm();
|
||||||
Map<String,List<Literal>> literalsFromForm = editSub.getLiteralsFromForm();
|
Map<String,List<Literal>> literalsFromForm = editSub.getLiteralsFromForm();
|
||||||
|
|
||||||
Map<String,String> errors = new HashMap<String,String>();
|
Map<String,String> errors = new HashMap<String,String>();
|
||||||
|
|
||||||
// The Editor field is optional for all publication subclasses. Validation is only necessary if the user only enters a
|
// The Editor field is optional for all publication subclasses. Validation is only necessary if the user only enters a
|
||||||
// last name or only enters a first name
|
// last name or only enters a first name
|
||||||
|
|
||||||
//Expecting only one first name in this case
|
//Expecting only one first name in this case
|
||||||
//To Do: update logic if multiple first names considered
|
//To Do: update logic if multiple first names considered
|
||||||
List<Literal> firstNameList = literalsFromForm.get("firstName");
|
List<Literal> firstNameList = literalsFromForm.get("firstName");
|
||||||
|
@ -42,8 +42,8 @@ public class PersonHasPublicationValidator implements N3ValidatorVTwo {
|
||||||
if(firstNameList != null && firstNameList.size() > 0) {
|
if(firstNameList != null && firstNameList.size() > 0) {
|
||||||
firstName = firstNameList.get(0);
|
firstName = firstNameList.get(0);
|
||||||
}
|
}
|
||||||
if ( firstName != null &&
|
if ( firstName != null &&
|
||||||
firstName.getLexicalForm() != null &&
|
firstName.getLexicalForm() != null &&
|
||||||
"".equals(firstName.getLexicalForm()) )
|
"".equals(firstName.getLexicalForm()) )
|
||||||
firstName = null;
|
firstName = null;
|
||||||
|
|
||||||
|
@ -67,22 +67,22 @@ public class PersonHasPublicationValidator implements N3ValidatorVTwo {
|
||||||
else if ( firstName == null && lastName != null) {
|
else if ( firstName == null && lastName != null) {
|
||||||
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
|
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
|
||||||
}
|
}
|
||||||
else if (lastNameValue.contains(",")) {
|
else if (lastNameValue.contains(",")) {
|
||||||
errors.put("lastName", MALFORMED_LAST_NAME_ERROR);
|
errors.put("lastName", MALFORMED_LAST_NAME_ERROR);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.size() != 0 ? errors : null;
|
return errors.size() != 0 ? errors : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getFirstElement(List checkList) {
|
private Object getFirstElement(List checkList) {
|
||||||
if(checkList == null || checkList.size() == 0) {
|
if(checkList == null || checkList.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return checkList.get(0);
|
return checkList.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,19 +19,19 @@ public class PublicationHasAuthorValidator implements N3ValidatorVTwo {
|
||||||
private static String MISSING_FIRST_NAME_ERROR = "Must specify the author's first name.";
|
private static String MISSING_FIRST_NAME_ERROR = "Must specify the author's first name.";
|
||||||
private static String MISSING_LAST_NAME_ERROR = "Must specify the author's last name.";
|
private static String MISSING_LAST_NAME_ERROR = "Must specify the author's last name.";
|
||||||
private static String MALFORMED_LAST_NAME_ERROR = "Last name may not contain a comma. Please enter first name in first name field.";
|
private static String MALFORMED_LAST_NAME_ERROR = "Last name may not contain a comma. Please enter first name in first name field.";
|
||||||
;
|
;
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> validate(EditConfigurationVTwo editConfig,
|
public Map<String, String> validate(EditConfigurationVTwo editConfig,
|
||||||
MultiValueEditSubmission editSub) {
|
MultiValueEditSubmission editSub) {
|
||||||
Map<String,List<String>> urisFromForm = editSub.getUrisFromForm();
|
Map<String,List<String>> urisFromForm = editSub.getUrisFromForm();
|
||||||
Map<String,List<Literal>> literalsFromForm = editSub.getLiteralsFromForm();
|
Map<String,List<Literal>> literalsFromForm = editSub.getLiteralsFromForm();
|
||||||
|
|
||||||
Map<String,String> errors = new HashMap<String,String>();
|
Map<String,String> errors = new HashMap<String,String>();
|
||||||
|
|
||||||
List<String> personUri = urisFromForm.get("personUri");
|
List<String> personUri = urisFromForm.get("personUri");
|
||||||
List<String> orgUri = urisFromForm.get("orgUri");
|
List<String> orgUri = urisFromForm.get("orgUri");
|
||||||
List<Literal> orgNameList = literalsFromForm.get("orgName");
|
List<Literal> orgNameList = literalsFromForm.get("orgName");
|
||||||
|
|
||||||
if (allListElementsEmpty(personUri)) {
|
if (allListElementsEmpty(personUri)) {
|
||||||
personUri = null;
|
personUri = null;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class PublicationHasAuthorValidator implements N3ValidatorVTwo {
|
||||||
if (personUri != null || orgUri != null || orgName != null ) {
|
if (personUri != null || orgUri != null || orgName != null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Expecting only one first name in this case
|
//Expecting only one first name in this case
|
||||||
//To Do: update logic if multiple first names considered
|
//To Do: update logic if multiple first names considered
|
||||||
Literal firstName = null;
|
Literal firstName = null;
|
||||||
|
@ -55,8 +55,8 @@ public class PublicationHasAuthorValidator implements N3ValidatorVTwo {
|
||||||
if(firstNameList != null && firstNameList.size() > 0) {
|
if(firstNameList != null && firstNameList.size() > 0) {
|
||||||
firstName = firstNameList.get(0);
|
firstName = firstNameList.get(0);
|
||||||
}
|
}
|
||||||
if( firstName != null &&
|
if( firstName != null &&
|
||||||
firstName.getLexicalForm() != null &&
|
firstName.getLexicalForm() != null &&
|
||||||
"".equals(firstName.getLexicalForm()) )
|
"".equals(firstName.getLexicalForm()) )
|
||||||
firstName = null;
|
firstName = null;
|
||||||
|
|
||||||
|
@ -77,17 +77,17 @@ public class PublicationHasAuthorValidator implements N3ValidatorVTwo {
|
||||||
if (lastName == null) {
|
if (lastName == null) {
|
||||||
errors.put("lastName", MISSING_LAST_NAME_ERROR);
|
errors.put("lastName", MISSING_LAST_NAME_ERROR);
|
||||||
// Don't reject space in the last name: de Vries, etc.
|
// Don't reject space in the last name: de Vries, etc.
|
||||||
} else if (lastNameValue.contains(",")) {
|
} else if (lastNameValue.contains(",")) {
|
||||||
errors.put("lastName", MALFORMED_LAST_NAME_ERROR);
|
errors.put("lastName", MALFORMED_LAST_NAME_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstName == null) {
|
if (firstName == null) {
|
||||||
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
|
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.size() != 0 ? errors : null;
|
return errors.size() != 0 ? errors : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean allListElementsEmpty(List<String> checkList) {
|
private boolean allListElementsEmpty(List<String> checkList) {
|
||||||
if(checkList == null)
|
if(checkList == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,67 +1,67 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantFieldOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantFieldOptions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
||||||
|
|
||||||
public class AddAttendeeRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
public class AddAttendeeRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
||||||
|
|
||||||
private static String TEMPLATE = "addAttendeeRoleToPerson.ftl";
|
private static String TEMPLATE = "addAttendeeRoleToPerson.ftl";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getTemplate(){ return TEMPLATE; }
|
String getTemplate(){ return TEMPLATE; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getRoleType() {
|
String getRoleType() {
|
||||||
return "http://vivoweb.org/ontology/core#AttendeeRole";
|
return "http://vivoweb.org/ontology/core#AttendeeRole";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Editor role involves hard-coded options for the "right side" of the role or activity. */
|
/** Editor role involves hard-coded options for the "right side" of the role or activity. */
|
||||||
@Override
|
@Override
|
||||||
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
||||||
return new ConstantFieldOptions(
|
return new ConstantFieldOptions(
|
||||||
"", "Select type",
|
"", "Select type",
|
||||||
"http://purl.org/NET/c4dm/event.owl#Event", "Event",
|
"http://purl.org/NET/c4dm/event.owl#Event", "Event",
|
||||||
"http://vivoweb.org/ontology/core#Competition", "Competition",
|
"http://vivoweb.org/ontology/core#Competition", "Competition",
|
||||||
"http://purl.org/ontology/bibo/Conference", "Conference",
|
"http://purl.org/ontology/bibo/Conference", "Conference",
|
||||||
"http://vivoweb.org/ontology/core#Course", "Course",
|
"http://vivoweb.org/ontology/core#Course", "Course",
|
||||||
"http://vivoweb.org/ontology/core#Exhibit", "Exhibit",
|
"http://vivoweb.org/ontology/core#Exhibit", "Exhibit",
|
||||||
"http://purl.org/ontology/bibo/Hearing", "Hearing",
|
"http://purl.org/ontology/bibo/Hearing", "Hearing",
|
||||||
"http://purl.org/ontology/bibo/Interview", "Interview",
|
"http://purl.org/ontology/bibo/Interview", "Interview",
|
||||||
"http://vivoweb.org/ontology/core#Meeting", "Meeting",
|
"http://vivoweb.org/ontology/core#Meeting", "Meeting",
|
||||||
"http://purl.org/ontology/bibo/Performance", "Performance",
|
"http://purl.org/ontology/bibo/Performance", "Performance",
|
||||||
"http://vivoweb.org/ontology/core#Presentation", "Presentation",
|
"http://vivoweb.org/ontology/core#Presentation", "Presentation",
|
||||||
"http://vivoweb.org/ontology/core#InvitedTalk", "Invited Talk",
|
"http://vivoweb.org/ontology/core#InvitedTalk", "Invited Talk",
|
||||||
"http://purl.org/ontology/bibo/Workshop", "Workshop",
|
"http://purl.org/ontology/bibo/Workshop", "Workshop",
|
||||||
"http://vivoweb.org/ontology/core#EventSeries", "Event Series",
|
"http://vivoweb.org/ontology/core#EventSeries", "Event Series",
|
||||||
"http://vivoweb.org/ontology/core#ConferenceSeries", "Conference Series",
|
"http://vivoweb.org/ontology/core#ConferenceSeries", "Conference Series",
|
||||||
"http://vivoweb.org/ontology/core#SeminarSeries", "Seminar Series",
|
"http://vivoweb.org/ontology/core#SeminarSeries", "Seminar Series",
|
||||||
"http://vivoweb.org/ontology/core#WorkshopSeries", "Workshop Series"
|
"http://vivoweb.org/ontology/core#WorkshopSeries", "Workshop Series"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isShowRoleLabelField() {
|
boolean isShowRoleLabelField() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use the methods below to change the date/time precision in the
|
* Use the methods below to change the date/time precision in the
|
||||||
* custom form associated with this generator. When not used, the
|
* custom form associated with this generator. When not used, the
|
||||||
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
||||||
* MINUTE, TIME and NONE.
|
* MINUTE, TIME and NONE.
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
public String getStartDatePrecision() {
|
public String getStartDatePrecision() {
|
||||||
String precision = VitroVocabulary.Precision.MONTH.uri();
|
String precision = VitroVocabulary.Precision.MONTH.uri();
|
||||||
return precision;
|
return precision;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEndDatePrecision() {
|
public String getEndDatePrecision() {
|
||||||
String precision = VitroVocabulary.Precision.DAY.uri();
|
String precision = VitroVocabulary.Precision.DAY.uri();
|
||||||
return precision;
|
return precision;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,9 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a slightly unusual generator that is used by Manage Authors on
|
* This is a slightly unusual generator that is used by Manage Authors on
|
||||||
* information resources.
|
* information resources.
|
||||||
*
|
*
|
||||||
* It is intended to always be an add, and never an update.
|
* It is intended to always be an add, and never an update.
|
||||||
*/
|
*/
|
||||||
public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator implements EditConfigurationGenerator {
|
public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator implements EditConfigurationGenerator {
|
||||||
public static Log log = LogFactory.getLog(AddAuthorsToInformationResourceGenerator.class);
|
public static Log log = LogFactory.getLog(AddAuthorsToInformationResourceGenerator.class);
|
||||||
|
@ -45,7 +45,7 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
HttpSession session) {
|
HttpSession session) {
|
||||||
EditConfigurationVTwo editConfiguration = new EditConfigurationVTwo();
|
EditConfigurationVTwo editConfiguration = new EditConfigurationVTwo();
|
||||||
initBasics(editConfiguration, vreq);
|
initBasics(editConfiguration, vreq);
|
||||||
initPropertyParameters(vreq, session, editConfiguration);
|
initPropertyParameters(vreq, session, editConfiguration);
|
||||||
|
|
||||||
|
@ -53,22 +53,22 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
setUrlToReturnTo(editConfiguration, vreq);
|
setUrlToReturnTo(editConfiguration, vreq);
|
||||||
|
|
||||||
//set variable names
|
//set variable names
|
||||||
editConfiguration.setVarNameForSubject("infoResource");
|
editConfiguration.setVarNameForSubject("infoResource");
|
||||||
editConfiguration.setVarNameForPredicate("predicate");
|
editConfiguration.setVarNameForPredicate("predicate");
|
||||||
editConfiguration.setVarNameForObject("authorshipUri");
|
editConfiguration.setVarNameForObject("authorshipUri");
|
||||||
|
|
||||||
// Required N3
|
// Required N3
|
||||||
editConfiguration.setN3Required( list( getN3NewAuthorship() ) );
|
editConfiguration.setN3Required( list( getN3NewAuthorship() ) );
|
||||||
|
|
||||||
// Optional N3
|
// Optional N3
|
||||||
editConfiguration.setN3Optional( generateN3Optional());
|
editConfiguration.setN3Optional( generateN3Optional());
|
||||||
|
|
||||||
editConfiguration.addNewResource("authorshipUri", DEFAULT_NS_TOKEN);
|
editConfiguration.addNewResource("authorshipUri", DEFAULT_NS_TOKEN);
|
||||||
editConfiguration.addNewResource("newPerson", DEFAULT_NS_TOKEN);
|
editConfiguration.addNewResource("newPerson", DEFAULT_NS_TOKEN);
|
||||||
editConfiguration.addNewResource("newOrg", DEFAULT_NS_TOKEN);
|
editConfiguration.addNewResource("newOrg", DEFAULT_NS_TOKEN);
|
||||||
editConfiguration.addNewResource("vcardPerson", DEFAULT_NS_TOKEN);
|
editConfiguration.addNewResource("vcardPerson", DEFAULT_NS_TOKEN);
|
||||||
editConfiguration.addNewResource("vcardName", DEFAULT_NS_TOKEN);
|
editConfiguration.addNewResource("vcardName", DEFAULT_NS_TOKEN);
|
||||||
|
|
||||||
//In scope
|
//In scope
|
||||||
setUrisAndLiteralsInScope(editConfiguration, vreq);
|
setUrisAndLiteralsInScope(editConfiguration, vreq);
|
||||||
|
|
||||||
|
@ -88,121 +88,121 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
|
|
||||||
//Adding additional data, specifically edit mode
|
//Adding additional data, specifically edit mode
|
||||||
addFormSpecificData(editConfiguration, vreq);
|
addFormSpecificData(editConfiguration, vreq);
|
||||||
|
|
||||||
editConfiguration.addValidator(new AntiXssValidation());
|
editConfiguration.addValidator(new AntiXssValidation());
|
||||||
|
|
||||||
//NOITCE this generator does not run prepare() since it
|
//NOITCE this generator does not run prepare() since it
|
||||||
//is never an update and has no SPARQL for existing
|
//is never an update and has no SPARQL for existing
|
||||||
|
|
||||||
return editConfiguration;
|
return editConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUrlToReturnTo(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setUrlToReturnTo(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
editConfiguration.setUrlPatternToReturnTo(EditConfigurationUtils.getFormUrlWithoutContext(vreq));
|
editConfiguration.setUrlPatternToReturnTo(EditConfigurationUtils.getFormUrlWithoutContext(vreq));
|
||||||
}
|
}
|
||||||
|
|
||||||
/***N3 strings both required and optional***/
|
/***N3 strings both required and optional***/
|
||||||
|
|
||||||
public String getN3PrefixString() {
|
public String getN3PrefixString() {
|
||||||
return "@prefix core: <" + vivoCore + "> .\n" +
|
return "@prefix core: <" + vivoCore + "> .\n" +
|
||||||
"@prefix foaf: <" + foaf + "> . \n" ;
|
"@prefix foaf: <" + foaf + "> . \n" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3NewAuthorship() {
|
private String getN3NewAuthorship() {
|
||||||
return getN3PrefixString() +
|
return getN3PrefixString() +
|
||||||
"?authorshipUri a core:Authorship ;\n" +
|
"?authorshipUri a core:Authorship ;\n" +
|
||||||
" core:relates ?infoResource .\n" +
|
" core:relates ?infoResource .\n" +
|
||||||
"?infoResource core:relatedBy ?authorshipUri .";
|
"?infoResource core:relatedBy ?authorshipUri .";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3AuthorshipRank() {
|
private String getN3AuthorshipRank() {
|
||||||
return getN3PrefixString() +
|
return getN3PrefixString() +
|
||||||
"?authorshipUri core:rank ?rank .";
|
"?authorshipUri core:rank ?rank .";
|
||||||
}
|
}
|
||||||
|
|
||||||
//first name, middle name, last name, and new perseon for new author being created, and n3 for existing person
|
//first name, middle name, last name, and new perseon for new author being created, and n3 for existing person
|
||||||
//if existing person selected as author
|
//if existing person selected as author
|
||||||
public List<String> generateN3Optional() {
|
public List<String> generateN3Optional() {
|
||||||
return list(
|
return list(
|
||||||
getN3NewPersonFirstName() ,
|
getN3NewPersonFirstName() ,
|
||||||
getN3NewPersonMiddleName(),
|
getN3NewPersonMiddleName(),
|
||||||
getN3NewPersonLastName(),
|
getN3NewPersonLastName(),
|
||||||
getN3NewPerson(),
|
getN3NewPerson(),
|
||||||
getN3AuthorshipRank(),
|
getN3AuthorshipRank(),
|
||||||
getN3ForExistingPerson(),
|
getN3ForExistingPerson(),
|
||||||
getN3NewOrg(),
|
getN3NewOrg(),
|
||||||
getN3ForExistingOrg());
|
getN3ForExistingOrg());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getN3NewPersonFirstName() {
|
private String getN3NewPersonFirstName() {
|
||||||
return getN3PrefixString() +
|
return getN3PrefixString() +
|
||||||
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
||||||
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
||||||
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
||||||
"?vcardName vcard:givenName ?firstName .";
|
"?vcardName vcard:givenName ?firstName .";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3NewPersonMiddleName() {
|
private String getN3NewPersonMiddleName() {
|
||||||
return getN3PrefixString() +
|
return getN3PrefixString() +
|
||||||
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
||||||
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
||||||
"?vcardPerson a vcard:Individual . \n" +
|
"?vcardPerson a vcard:Individual . \n" +
|
||||||
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a vcard:Name . \n" +
|
"?vcardName a vcard:Name . \n" +
|
||||||
"?vcardName <http://vivoweb.org/ontology/core#middleName> ?middleName .";
|
"?vcardName <http://vivoweb.org/ontology/core#middleName> ?middleName .";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3NewPersonLastName() {
|
private String getN3NewPersonLastName() {
|
||||||
return getN3PrefixString() +
|
return getN3PrefixString() +
|
||||||
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
||||||
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
||||||
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
||||||
"?vcardName vcard:familyName ?lastName .";
|
"?vcardName vcard:familyName ?lastName .";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3NewPerson() {
|
private String getN3NewPerson() {
|
||||||
return getN3PrefixString() +
|
return getN3PrefixString() +
|
||||||
"?newPerson a foaf:Person ;\n" +
|
"?newPerson a foaf:Person ;\n" +
|
||||||
"<" + RDFS.label.getURI() + "> ?label .\n" +
|
"<" + RDFS.label.getURI() + "> ?label .\n" +
|
||||||
"?authorshipUri core:relates ?newPerson .\n" +
|
"?authorshipUri core:relates ?newPerson .\n" +
|
||||||
"?newPerson core:relatedBy ?authorshipUri . ";
|
"?newPerson core:relatedBy ?authorshipUri . ";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3ForExistingPerson() {
|
private String getN3ForExistingPerson() {
|
||||||
return getN3PrefixString() +
|
return getN3PrefixString() +
|
||||||
"?authorshipUri core:relates ?personUri .\n" +
|
"?authorshipUri core:relates ?personUri .\n" +
|
||||||
"?personUri core:relatedBy ?authorshipUri .";
|
"?personUri core:relatedBy ?authorshipUri .";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3NewOrg() {
|
private String getN3NewOrg() {
|
||||||
return getN3PrefixString() +
|
return getN3PrefixString() +
|
||||||
"?newOrg a foaf:Organization ;\n" +
|
"?newOrg a foaf:Organization ;\n" +
|
||||||
"<" + RDFS.label.getURI() + "> ?orgName .\n" +
|
"<" + RDFS.label.getURI() + "> ?orgName .\n" +
|
||||||
"?authorshipUri core:relates ?newOrg .\n" +
|
"?authorshipUri core:relates ?newOrg .\n" +
|
||||||
"?newOrg core:relatedBy ?authorshipUri . ";
|
"?newOrg core:relatedBy ?authorshipUri . ";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3ForExistingOrg() {
|
private String getN3ForExistingOrg() {
|
||||||
return getN3PrefixString() +
|
return getN3PrefixString() +
|
||||||
"?authorshipUri core:relates ?orgUri .\n" +
|
"?authorshipUri core:relates ?orgUri .\n" +
|
||||||
"?orgUri core:relatedBy ?authorshipUri .";
|
"?orgUri core:relatedBy ?authorshipUri .";
|
||||||
}
|
}
|
||||||
/** Get new resources */
|
/** Get new resources */
|
||||||
//A new authorship uri will always be created when an author is added
|
//A new authorship uri will always be created when an author is added
|
||||||
//A new person may be added if a person not in the system will be added as author
|
//A new person may be added if a person not in the system will be added as author
|
||||||
private Map<String, String> generateNewResources(VitroRequest vreq) {
|
private Map<String, String> generateNewResources(VitroRequest vreq) {
|
||||||
|
|
||||||
|
|
||||||
HashMap<String, String> newResources = new HashMap<String, String>();
|
HashMap<String, String> newResources = new HashMap<String, String>();
|
||||||
newResources.put("authorshipUri", DEFAULT_NS_TOKEN);
|
newResources.put("authorshipUri", DEFAULT_NS_TOKEN);
|
||||||
newResources.put("newPerson", DEFAULT_NS_TOKEN);
|
newResources.put("newPerson", DEFAULT_NS_TOKEN);
|
||||||
newResources.put("vcardPerson", DEFAULT_NS_TOKEN);
|
newResources.put("vcardPerson", DEFAULT_NS_TOKEN);
|
||||||
|
@ -210,26 +210,26 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
newResources.put("newOrg", DEFAULT_NS_TOKEN);
|
newResources.put("newOrg", DEFAULT_NS_TOKEN);
|
||||||
return newResources;
|
return newResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set URIS and Literals In Scope and on form and supporting methods */
|
/** Set URIS and Literals In Scope and on form and supporting methods */
|
||||||
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
//Uris in scope always contain subject and predicate
|
//Uris in scope always contain subject and predicate
|
||||||
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
||||||
urisInScope.put(editConfiguration.getVarNameForSubject(),
|
urisInScope.put(editConfiguration.getVarNameForSubject(),
|
||||||
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
|
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
|
||||||
urisInScope.put(editConfiguration.getVarNameForPredicate(),
|
urisInScope.put(editConfiguration.getVarNameForPredicate(),
|
||||||
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
|
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
|
||||||
editConfiguration.setUrisInScope(urisInScope);
|
editConfiguration.setUrisInScope(urisInScope);
|
||||||
//no literals in scope
|
//no literals in scope
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
public void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
List<String> urisOnForm = new ArrayList<String>();
|
List<String> urisOnForm = new ArrayList<String>();
|
||||||
//If an existing person is being used as an author, need to get the person uri
|
//If an existing person is being used as an author, need to get the person uri
|
||||||
urisOnForm.add("personUri");
|
urisOnForm.add("personUri");
|
||||||
urisOnForm.add("orgUri");
|
urisOnForm.add("orgUri");
|
||||||
editConfiguration.setUrisOnform(urisOnForm);
|
editConfiguration.setUrisOnform(urisOnForm);
|
||||||
|
|
||||||
//for person who is not in system, need to add first name, last name and middle name
|
//for person who is not in system, need to add first name, last name and middle name
|
||||||
//Also need to store authorship rank and label of author
|
//Also need to store authorship rank and label of author
|
||||||
List<String> literalsOnForm = list("firstName",
|
List<String> literalsOnForm = list("firstName",
|
||||||
|
@ -239,10 +239,10 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
"orgName",
|
"orgName",
|
||||||
"label");
|
"label");
|
||||||
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set SPARQL Queries and supporting methods. */
|
/** Set SPARQL Queries and supporting methods. */
|
||||||
private void setSparqlQueries(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setSparqlQueries(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
//Sparql queries are all empty for existing values
|
//Sparql queries are all empty for existing values
|
||||||
//This form is different from the others that it gets multiple authors on the same page
|
//This form is different from the others that it gets multiple authors on the same page
|
||||||
//and that information will be queried and stored in the additional form specific data
|
//and that information will be queried and stored in the additional form specific data
|
||||||
|
@ -252,12 +252,12 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
editConfiguration.setSparqlForAdditionalUrisInScope(new HashMap<String, String>());
|
editConfiguration.setSparqlForAdditionalUrisInScope(new HashMap<String, String>());
|
||||||
editConfiguration.setSparqlForAdditionalLiteralsInScope(new HashMap<String, String>());
|
editConfiguration.setSparqlForAdditionalLiteralsInScope(new HashMap<String, String>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Set Fields and supporting methods
|
* Set Fields and supporting methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
|
public void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
|
||||||
setLabelField(editConfiguration);
|
setLabelField(editConfiguration);
|
||||||
setFirstNameField(editConfiguration);
|
setFirstNameField(editConfiguration);
|
||||||
|
@ -268,7 +268,7 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
setOrgUriField(editConfiguration);
|
setOrgUriField(editConfiguration);
|
||||||
setOrgNameField(editConfiguration);
|
setOrgNameField(editConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLabelField(EditConfigurationVTwo editConfiguration) {
|
private void setLabelField(EditConfigurationVTwo editConfiguration) {
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
setName("label").
|
setName("label").
|
||||||
|
@ -333,7 +333,7 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
setRangeDatatypeUri(XSD.xstring.toString())
|
setRangeDatatypeUri(XSD.xstring.toString())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Form specific data
|
//Form specific data
|
||||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||||
|
@ -418,27 +418,27 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
+ "WHERE { { \n"
|
+ "WHERE { { \n"
|
||||||
+ " ?subject core:relatedBy ?authorshipURI . \n"
|
+ " ?subject core:relatedBy ?authorshipURI . \n"
|
||||||
+ " ?authorshipURI a core:Authorship . \n"
|
+ " ?authorshipURI a core:Authorship . \n"
|
||||||
+ " ?authorshipURI core:relates ?authorURI . \n"
|
+ " ?authorshipURI core:relates ?authorURI . \n"
|
||||||
+ " ?authorURI a foaf:Agent . \n"
|
+ " ?authorURI a foaf:Agent . \n"
|
||||||
+ " OPTIONAL { ?authorURI rdfs:label ?authorName } \n"
|
+ " OPTIONAL { ?authorURI rdfs:label ?authorName } \n"
|
||||||
+ " OPTIONAL { ?authorshipURI core:rank ?rank } \n"
|
+ " OPTIONAL { ?authorshipURI core:rank ?rank } \n"
|
||||||
+ "} UNION { \n"
|
+ "} UNION { \n"
|
||||||
+ " ?subject core:relatedBy ?authorshipURI . \n"
|
+ " ?subject core:relatedBy ?authorshipURI . \n"
|
||||||
+ " ?authorshipURI a core:Authorship . \n"
|
+ " ?authorshipURI a core:Authorship . \n"
|
||||||
+ " ?authorshipURI core:relates ?authorURI . \n"
|
+ " ?authorshipURI core:relates ?authorURI . \n"
|
||||||
+ " ?authorURI a vcard:Individual . \n"
|
+ " ?authorURI a vcard:Individual . \n"
|
||||||
+ " ?authorURI vcard:hasName ?vName . \n"
|
+ " ?authorURI vcard:hasName ?vName . \n"
|
||||||
+ " ?vName vcard:givenName ?firstName . \n"
|
+ " ?vName vcard:givenName ?firstName . \n"
|
||||||
+ " ?vName vcard:familyName ?lastName . \n"
|
+ " ?vName vcard:familyName ?lastName . \n"
|
||||||
+ " OPTIONAL { ?vName core:middleName ?middleName . } \n"
|
+ " OPTIONAL { ?vName core:middleName ?middleName . } \n"
|
||||||
+ " OPTIONAL { ?authorshipURI core:rank ?rank } \n"
|
+ " OPTIONAL { ?authorshipURI core:rank ?rank } \n"
|
||||||
+ " bind ( COALESCE(?firstName, \"\") As ?firstName1) . \n"
|
+ " bind ( COALESCE(?firstName, \"\") As ?firstName1) . \n"
|
||||||
+ " bind ( COALESCE(?middleName, \"\") As ?middleName1) . \n"
|
+ " bind ( COALESCE(?middleName, \"\") As ?middleName1) . \n"
|
||||||
+ " bind ( COALESCE(?lastName, \"\") As ?lastName1) . \n"
|
+ " bind ( COALESCE(?lastName, \"\") As ?lastName1) . \n"
|
||||||
+ " bind (concat(str(?lastName1 + \", \"),str(?middleName1 + \" \"),str(?firstName1)) as ?authorName) . \n"
|
+ " bind (concat(str(?lastName1 + \", \"),str(?middleName1 + \" \"),str(?firstName1)) as ?authorName) . \n"
|
||||||
+ "} } ORDER BY ?rank";
|
+ "} } ORDER BY ?rank";
|
||||||
|
|
||||||
|
|
||||||
private List<AuthorshipInfo> getExistingAuthorships(String subjectUri, VitroRequest vreq) {
|
private List<AuthorshipInfo> getExistingAuthorships(String subjectUri, VitroRequest vreq) {
|
||||||
RDFService rdfService = vreq.getRDFService();
|
RDFService rdfService = vreq.getRDFService();
|
||||||
|
|
||||||
|
@ -448,7 +448,7 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
|
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
Model constructedModel = ModelFactory.createDefaultModel();
|
||||||
rdfService.sparqlConstructQuery(constructStr, constructedModel);
|
rdfService.sparqlConstructQuery(constructStr, constructedModel);
|
||||||
|
|
||||||
String queryStr = QueryUtils.subUriForQueryVar(this.getAuthorshipsQuery(), "subject", subjectUri);
|
String queryStr = QueryUtils.subUriForQueryVar(this.getAuthorshipsQuery(), "subject", subjectUri);
|
||||||
log.debug("Query string is: " + queryStr);
|
log.debug("Query string is: " + queryStr);
|
||||||
|
|
||||||
|
@ -467,7 +467,7 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
}
|
}
|
||||||
authorships = QueryUtils.removeDuplicatesMapsFromList(authorships, "authorShipURI", "authorURI");
|
authorships = QueryUtils.removeDuplicatesMapsFromList(authorships, "authorShipURI", "authorURI");
|
||||||
log.debug("authorships = " + authorships);
|
log.debug("authorships = " + authorships);
|
||||||
return getAuthorshipInfo(authorships);
|
return getAuthorshipInfo(authorships);
|
||||||
|
@ -480,22 +480,22 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
+ " ?authorship a core:Authorship . \n"
|
+ " ?authorship a core:Authorship . \n"
|
||||||
+ " ?authorship core:rank ?rank .\n"
|
+ " ?authorship core:rank ?rank .\n"
|
||||||
+ "} ORDER BY DESC(?rank) LIMIT 1";
|
+ "} ORDER BY DESC(?rank) LIMIT 1";
|
||||||
|
|
||||||
private int getMaxRank(String subjectUri, VitroRequest vreq) {
|
private int getMaxRank(String subjectUri, VitroRequest vreq) {
|
||||||
|
|
||||||
int maxRank = 0; // default value
|
int maxRank = 0; // default value
|
||||||
String queryStr = QueryUtils.subUriForQueryVar(this.getMaxRankQueryStr(), "subject", subjectUri);
|
String queryStr = QueryUtils.subUriForQueryVar(this.getMaxRankQueryStr(), "subject", subjectUri);
|
||||||
log.debug("maxRank query string is: " + queryStr);
|
log.debug("maxRank query string is: " + queryStr);
|
||||||
try {
|
try {
|
||||||
ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
|
ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
|
||||||
if (results != null && results.hasNext()) { // there is at most one result
|
if (results != null && results.hasNext()) { // there is at most one result
|
||||||
QuerySolution soln = results.next();
|
QuerySolution soln = results.next();
|
||||||
RDFNode node = soln.get("rank");
|
RDFNode node = soln.get("rank");
|
||||||
if (node != null && node.isLiteral()) {
|
if (node != null && node.isLiteral()) {
|
||||||
// node.asLiteral().getInt() won't return an xsd:string that
|
// node.asLiteral().getInt() won't return an xsd:string that
|
||||||
// can be parsed as an int.
|
// can be parsed as an int.
|
||||||
int rank = Integer.parseInt(node.asLiteral().getLexicalForm());
|
int rank = Integer.parseInt(node.asLiteral().getLexicalForm());
|
||||||
if (rank > maxRank) {
|
if (rank > maxRank) {
|
||||||
log.debug("setting maxRank to " + rank);
|
log.debug("setting maxRank to " + rank);
|
||||||
maxRank = rank;
|
maxRank = rank;
|
||||||
}
|
}
|
||||||
|
@ -549,8 +549,8 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
//Author information for authorship node
|
//Author information for authorship node
|
||||||
private String authorUri;
|
private String authorUri;
|
||||||
private String authorName;
|
private String authorName;
|
||||||
|
|
||||||
public AuthorshipInfo(String inputAuthorshipUri,
|
public AuthorshipInfo(String inputAuthorshipUri,
|
||||||
String inputAuthorshipName,
|
String inputAuthorshipName,
|
||||||
String inputAuthorUri,
|
String inputAuthorUri,
|
||||||
String inputAuthorName) {
|
String inputAuthorName) {
|
||||||
|
@ -560,25 +560,25 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
authorName = inputAuthorName;
|
authorName = inputAuthorName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Getters - specifically required for Freemarker template's access to POJO
|
//Getters - specifically required for Freemarker template's access to POJO
|
||||||
public String getAuthorshipUri() {
|
public String getAuthorshipUri() {
|
||||||
return authorshipUri;
|
return authorshipUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthorshipName() {
|
public String getAuthorshipName() {
|
||||||
return authorshipName;
|
return authorshipName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthorUri() {
|
public String getAuthorUri() {
|
||||||
return authorUri;
|
return authorUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthorName() {
|
public String getAuthorName() {
|
||||||
return authorName;
|
return authorName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static final String DEFAULT_NS_TOKEN=null; //null forces the default NS
|
static final String DEFAULT_NS_TOKEN=null; //null forces the default NS
|
||||||
|
|
||||||
protected String getMaxRankQueryStr() {
|
protected String getMaxRankQueryStr() {
|
||||||
|
|
|
@ -7,28 +7,28 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantField
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
||||||
|
|
||||||
public class AddClinicalRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
public class AddClinicalRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
||||||
|
|
||||||
private static String template = "addClinicalRoleToPerson.ftl";
|
private static String template = "addClinicalRoleToPerson.ftl";
|
||||||
|
|
||||||
//Should this be overridden
|
//Should this be overridden
|
||||||
@Override
|
@Override
|
||||||
String getTemplate() {
|
String getTemplate() {
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getRoleType() {
|
String getRoleType() {
|
||||||
return "http://vivoweb.org/ontology/core#ClinicalRole";
|
return "http://vivoweb.org/ontology/core#ClinicalRole";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Clinical role involves hard-coded options for the "right side" of the role or activity. */
|
/** Clinical role involves hard-coded options for the "right side" of the role or activity. */
|
||||||
@Override
|
@Override
|
||||||
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
||||||
return new ConstantFieldOptions(
|
return new ConstantFieldOptions(
|
||||||
"", "Select one",
|
"", "Select one",
|
||||||
"http://vivoweb.org/ontology/core#Project", "Project",
|
"http://vivoweb.org/ontology/core#Project", "Project",
|
||||||
"http://purl.obolibrary.org/obo/ERO_0000005", "Service"
|
"http://purl.obolibrary.org/obo/ERO_0000005", "Service"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//isShowRoleLabelField remains true for this so doesn't need to be overwritten
|
//isShowRoleLabelField remains true for this so doesn't need to be overwritten
|
||||||
|
@ -38,7 +38,7 @@ public class AddClinicalRoleToPersonGenerator extends AddRoleToPersonTwoStageGen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use the methods below to change the date/time precision in the
|
* Use the methods below to change the date/time precision in the
|
||||||
* custom form associated with this generator. When not used, the
|
* custom form associated with this generator. When not used, the
|
||||||
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
||||||
|
@ -54,6 +54,6 @@ public class AddClinicalRoleToPersonGenerator extends AddRoleToPersonTwoStageGen
|
||||||
String precision = VitroVocabulary.Precision.DAY.uri();
|
String precision = VitroVocabulary.Precision.DAY.uri();
|
||||||
return precision;
|
return precision;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,14 +22,14 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaSearchQueryOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaSearchQueryOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This generator is for the case where a new concept is being added for an object property other than research/subject areas where the
|
* This generator is for the case where a new concept is being added for an object property other than research/subject areas where the
|
||||||
* default object property form generator would work instead of the generator for managing concepts.
|
* default object property form generator would work instead of the generator for managing concepts.
|
||||||
* In this case, we don't want the dropdown list for types for "add a new item of this type" to show concept subclasses, so we are overriding
|
* In this case, we don't want the dropdown list for types for "add a new item of this type" to show concept subclasses, so we are overriding
|
||||||
* the fields to just include the Concept class.
|
* the fields to just include the Concept class.
|
||||||
*/
|
*/
|
||||||
public class AddConceptThroughObjectPropertyGenerator extends DefaultObjectPropertyFormGenerator implements EditConfigurationGenerator {
|
public class AddConceptThroughObjectPropertyGenerator extends DefaultObjectPropertyFormGenerator implements EditConfigurationGenerator {
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(AddConceptThroughObjectPropertyGenerator.class);
|
private Log log = LogFactory.getLog(AddConceptThroughObjectPropertyGenerator.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
|
@ -44,7 +44,7 @@ public class AddConceptThroughObjectPropertyGenerator extends DefaultObjectPrope
|
||||||
}
|
}
|
||||||
return editConfig;
|
return editConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashMap<String, String> getCreateNewTypesOptions(VitroRequest vreq) {
|
private HashMap<String, String> getCreateNewTypesOptions(VitroRequest vreq) {
|
||||||
HashMap<String, String> options = new HashMap<String, String>();
|
HashMap<String, String> options = new HashMap<String, String>();
|
||||||
List<VClass> rangeTypes = getRangeTypes(vreq);
|
List<VClass> rangeTypes = getRangeTypes(vreq);
|
||||||
|
@ -53,7 +53,7 @@ public class AddConceptThroughObjectPropertyGenerator extends DefaultObjectPrope
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
//We will override range types as well so that autocomplete and other fields dependent on range
|
//We will override range types as well so that autocomplete and other fields dependent on range
|
||||||
//will only consider the main concept type to be the range type
|
//will only consider the main concept type to be the range type
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,44 +73,44 @@ public class AddConceptThroughObjectPropertyGenerator extends DefaultObjectPrope
|
||||||
if (rangeUri != null) {
|
if (rangeUri != null) {
|
||||||
VClass rangeVClass = ctxDaoFact.getVClassDao().getVClassByURI(rangeUri);
|
VClass rangeVClass = ctxDaoFact.getVClassDao().getVClassByURI(rangeUri);
|
||||||
if (!rangeVClass.isUnion()) {
|
if (!rangeVClass.isUnion()) {
|
||||||
types.add(rangeVClass);
|
types.add(rangeVClass);
|
||||||
} else {
|
} else {
|
||||||
types.addAll(rangeVClass.getUnionComponents());
|
types.addAll(rangeVClass.getUnionComponents());
|
||||||
}
|
}
|
||||||
return types;
|
return types;
|
||||||
} else {
|
} else {
|
||||||
//This should never happen
|
//This should never happen
|
||||||
log.warn("Range not found for this property so employing SKOS concept class");
|
log.warn("Range not found for this property so employing SKOS concept class");
|
||||||
String vclassURI = "http://www.w3.org/2004/02/skos/core#Concept";
|
String vclassURI = "http://www.w3.org/2004/02/skos/core#Concept";
|
||||||
VClass rangeVClass = ctxDaoFact.getVClassDao().getVClassByURI(vclassURI);
|
VClass rangeVClass = ctxDaoFact.getVClassDao().getVClassByURI(vclassURI);
|
||||||
types.add(rangeVClass);
|
types.add(rangeVClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
return types;
|
return types;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Should override the method in default object property
|
//Should override the method in default object property
|
||||||
private String getTemplate(
|
private String getTemplate(
|
||||||
VitroRequest vreq) {
|
VitroRequest vreq) {
|
||||||
|
|
||||||
String acObjectPropertyTemplate = "addConceptThroughObjectPropertyAutoComplete.ftl";
|
String acObjectPropertyTemplate = "addConceptThroughObjectPropertyAutoComplete.ftl";
|
||||||
String objectPropertyTemplate = "addConceptThroughObjectPropertyForm.ftl";
|
String objectPropertyTemplate = "addConceptThroughObjectPropertyForm.ftl";
|
||||||
String template = objectPropertyTemplate;
|
String template = objectPropertyTemplate;
|
||||||
if( doAutoComplete )
|
if( doAutoComplete )
|
||||||
template = acObjectPropertyTemplate;
|
template = acObjectPropertyTemplate;
|
||||||
return template;
|
return template;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri, List<VClass> rangeTypes) throws Exception {
|
protected void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri, List<VClass> rangeTypes) throws Exception {
|
||||||
FieldVTwo field = new FieldVTwo();
|
FieldVTwo field = new FieldVTwo();
|
||||||
field.setName("objectVar");
|
field.setName("objectVar");
|
||||||
|
|
||||||
List<String> validators = new ArrayList<String>();
|
List<String> validators = new ArrayList<String>();
|
||||||
validators.add("nonempty");
|
validators.add("nonempty");
|
||||||
field.setValidators(validators);
|
field.setValidators(validators);
|
||||||
|
|
||||||
if( ! doAutoComplete ){
|
if( ! doAutoComplete ){
|
||||||
List<String> types = new ArrayList<String>();
|
List<String> types = new ArrayList<String>();
|
||||||
for(VClass v: rangeTypes) {
|
for(VClass v: rangeTypes) {
|
||||||
|
@ -125,11 +125,11 @@ public class AddConceptThroughObjectPropertyGenerator extends DefaultObjectPrope
|
||||||
}else{
|
}else{
|
||||||
field.setOptions(null);
|
field.setOptions(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, FieldVTwo> fields = new HashMap<String, FieldVTwo>();
|
Map<String, FieldVTwo> fields = new HashMap<String, FieldVTwo>();
|
||||||
fields.put(field.getName(), field);
|
fields.put(field.getName(), field);
|
||||||
|
|
||||||
editConfiguration.setFields(fields);
|
editConfiguration.setFields(fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Custom form for adding or editing a webpage associated with an individual. The primary page,
|
Custom form for adding or editing a webpage associated with an individual. The primary page,
|
||||||
ManageWebpagesForIndividual, should forward to this page if: (a) we are adding a new page, or
|
ManageWebpagesForIndividual, should forward to this page if: (a) we are adding a new page, or
|
||||||
(b) an edit link in the Manage Webpages view has been clicked. But right now (a) is not implemented.
|
(b) an edit link in the Manage Webpages view has been clicked. But right now (a) is not implemented.
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@ -40,41 +40,41 @@ public class AddEditWebpageFormGenerator extends BaseEditConfigurationGenerator
|
||||||
prepare(vreq, config);
|
prepare(vreq, config);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Have broken this method down into two portions to allow for overriding of edit configuration
|
//Have broken this method down into two portions to allow for overriding of edit configuration
|
||||||
//without having to copy the entire method and before prepare is called
|
//without having to copy the entire method and before prepare is called
|
||||||
|
|
||||||
protected EditConfigurationVTwo setupConfig(VitroRequest vreq, HttpSession session) throws Exception{
|
protected EditConfigurationVTwo setupConfig(VitroRequest vreq, HttpSession session) throws Exception{
|
||||||
|
|
||||||
EditConfigurationVTwo config = new EditConfigurationVTwo();
|
EditConfigurationVTwo config = new EditConfigurationVTwo();
|
||||||
|
|
||||||
config.setTemplate(this.getTemplate());
|
config.setTemplate(this.getTemplate());
|
||||||
|
|
||||||
initBasics(config, vreq);
|
initBasics(config, vreq);
|
||||||
initPropertyParameters(vreq, session, config);
|
initPropertyParameters(vreq, session, config);
|
||||||
initObjectPropForm(config, vreq);
|
initObjectPropForm(config, vreq);
|
||||||
String linkUri = getLinkUri(vreq);
|
String linkUri = getLinkUri(vreq);
|
||||||
String domainUri = vreq.getParameter("domainUri");
|
String domainUri = vreq.getParameter("domainUri");
|
||||||
String vcardIndividualType = "http://www.w3.org/2006/vcard/ns#Kind";
|
String vcardIndividualType = "http://www.w3.org/2006/vcard/ns#Kind";
|
||||||
|
|
||||||
|
|
||||||
config.setVarNameForSubject("subject");
|
config.setVarNameForSubject("subject");
|
||||||
config.setVarNameForObject("vcard");
|
config.setVarNameForObject("vcard");
|
||||||
|
|
||||||
config.addNewResource("vcard", DEFAULT_NS_FOR_NEW_RESOURCE);
|
config.addNewResource("vcard", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
config.addNewResource("link", DEFAULT_NS_FOR_NEW_RESOURCE);
|
config.addNewResource("link", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
config.setN3Required(list( this.getN3ForWebpage(), N3_FOR_URLTYPE ));
|
config.setN3Required(list( this.getN3ForWebpage(), N3_FOR_URLTYPE ));
|
||||||
config.setN3Optional(list( N3_FOR_ANCHOR, N3_FOR_RANK));
|
config.setN3Optional(list( N3_FOR_ANCHOR, N3_FOR_RANK));
|
||||||
|
|
||||||
config.addUrisInScope("webpageProperty", list( "http://purl.obolibrary.org/obo/ARG_2000028" ));
|
config.addUrisInScope("webpageProperty", list( "http://purl.obolibrary.org/obo/ARG_2000028" ));
|
||||||
config.addUrisInScope("inverseProperty", list( "http://purl.obolibrary.org/obo/ARG_2000029" ));
|
config.addUrisInScope("inverseProperty", list( "http://purl.obolibrary.org/obo/ARG_2000029" ));
|
||||||
config.addUrisInScope("linkUrlPredicate", list( "http://www.w3.org/2006/vcard/ns#url" ));
|
config.addUrisInScope("linkUrlPredicate", list( "http://www.w3.org/2006/vcard/ns#url" ));
|
||||||
config.addUrisInScope("linkLabelPredicate", list( "http://www.w3.org/2000/01/rdf-schema#label" ));
|
config.addUrisInScope("linkLabelPredicate", list( "http://www.w3.org/2000/01/rdf-schema#label" ));
|
||||||
config.addUrisInScope("rankPredicate", list( core + "rank"));
|
config.addUrisInScope("rankPredicate", list( core + "rank"));
|
||||||
config.addUrisInScope("vcardType", list( vcardIndividualType ));
|
config.addUrisInScope("vcardType", list( vcardIndividualType ));
|
||||||
|
|
||||||
|
|
||||||
if ( config.isUpdate() ) {
|
if ( config.isUpdate() ) {
|
||||||
config.addUrisInScope("link", list( linkUri ));
|
config.addUrisInScope("link", list( linkUri ));
|
||||||
}
|
}
|
||||||
|
@ -87,45 +87,45 @@ public class AddEditWebpageFormGenerator extends BaseEditConfigurationGenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
config.addSparqlForAdditionalUrisInScope("vcard", individualVcardQuery);
|
config.addSparqlForAdditionalUrisInScope("vcard", individualVcardQuery);
|
||||||
|
|
||||||
config.setUrisOnForm("urlType");
|
config.setUrisOnForm("urlType");
|
||||||
config.setLiteralsOnForm(list("url","label","rank"));
|
config.setLiteralsOnForm(list("url","label","rank"));
|
||||||
|
|
||||||
config.addSparqlForExistingLiteral("url", URL_QUERY);
|
config.addSparqlForExistingLiteral("url", URL_QUERY);
|
||||||
config.addSparqlForExistingLiteral("label", ANCHOR_QUERY);
|
config.addSparqlForExistingLiteral("label", ANCHOR_QUERY);
|
||||||
config.addSparqlForExistingLiteral("rank", MAX_RANK_QUERY);
|
config.addSparqlForExistingLiteral("rank", MAX_RANK_QUERY);
|
||||||
config.addSparqlForExistingUris("urlType", URLTYPE_QUERY);
|
config.addSparqlForExistingUris("urlType", URLTYPE_QUERY);
|
||||||
|
|
||||||
config.addField(new FieldVTwo().
|
config.addField(new FieldVTwo().
|
||||||
setName("url").
|
setName("url").
|
||||||
setValidators(list("nonempty", "datatype:"+XSD.anyURI.toString(), "httpUrl")).
|
setValidators(list("nonempty", "datatype:"+XSD.anyURI.toString(), "httpUrl")).
|
||||||
setRangeDatatypeUri(XSD.anyURI.toString()));
|
setRangeDatatypeUri(XSD.anyURI.toString()));
|
||||||
|
|
||||||
config.addField( new FieldVTwo().
|
config.addField( new FieldVTwo().
|
||||||
setName("urlType").
|
setName("urlType").
|
||||||
setValidators( list("nonempty") ).
|
setValidators( list("nonempty") ).
|
||||||
setOptions(
|
setOptions(
|
||||||
new ChildVClassesWithParent("http://www.w3.org/2006/vcard/ns#URL")));
|
new ChildVClassesWithParent("http://www.w3.org/2006/vcard/ns#URL")));
|
||||||
|
|
||||||
config.addField(new FieldVTwo().
|
config.addField(new FieldVTwo().
|
||||||
setName("label"));
|
setName("label"));
|
||||||
|
|
||||||
config.addField(new FieldVTwo().
|
config.addField(new FieldVTwo().
|
||||||
setName("rank").
|
setName("rank").
|
||||||
setRangeDatatypeUri(XSD.xint.toString()));
|
setRangeDatatypeUri(XSD.xint.toString()));
|
||||||
|
|
||||||
config.addFormSpecificData("newRank",
|
config.addFormSpecificData("newRank",
|
||||||
getMaxRank( EditConfigurationUtils.getObjectUri(vreq),
|
getMaxRank( EditConfigurationUtils.getObjectUri(vreq),
|
||||||
EditConfigurationUtils.getSubjectUri(vreq), vreq )
|
EditConfigurationUtils.getSubjectUri(vreq), vreq )
|
||||||
+ 1 );
|
+ 1 );
|
||||||
|
|
||||||
config.addValidator(new AntiXssValidation());
|
config.addValidator(new AntiXssValidation());
|
||||||
|
|
||||||
//might be null
|
//might be null
|
||||||
config.addFormSpecificData("subjectName", getName( config, vreq));
|
config.addFormSpecificData("subjectName", getName( config, vreq));
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** may be null */
|
/** may be null */
|
||||||
private Object getName(EditConfigurationVTwo config, VitroRequest vreq) {
|
private Object getName(EditConfigurationVTwo config, VitroRequest vreq) {
|
||||||
Individual ind = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(config.getSubjectUri());
|
Individual ind = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(config.getSubjectUri());
|
||||||
|
@ -136,40 +136,40 @@ public class AddEditWebpageFormGenerator extends BaseEditConfigurationGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ********* N3 Assertions *********** */
|
/* ********* N3 Assertions *********** */
|
||||||
static String N3_FOR_WEBPAGE =
|
static String N3_FOR_WEBPAGE =
|
||||||
"?subject ?webpageProperty ?vcard . \n"+
|
"?subject ?webpageProperty ?vcard . \n"+
|
||||||
"?vcard ?inverseProperty ?subject . \n"+
|
"?vcard ?inverseProperty ?subject . \n"+
|
||||||
"?vcard a ?vcardType . \n" +
|
"?vcard a ?vcardType . \n" +
|
||||||
"?vcard <http://www.w3.org/2006/vcard/ns#hasURL> ?link ."+
|
"?vcard <http://www.w3.org/2006/vcard/ns#hasURL> ?link ."+
|
||||||
"?link a <http://www.w3.org/2006/vcard/ns#URL> . \n" +
|
"?link a <http://www.w3.org/2006/vcard/ns#URL> . \n" +
|
||||||
"?link ?linkUrlPredicate ?url .";
|
"?link ?linkUrlPredicate ?url .";
|
||||||
|
|
||||||
static String N3_FOR_URLTYPE =
|
static String N3_FOR_URLTYPE =
|
||||||
"?link a ?urlType .";
|
"?link a ?urlType .";
|
||||||
|
|
||||||
static String N3_FOR_ANCHOR =
|
static String N3_FOR_ANCHOR =
|
||||||
"?link ?linkLabelPredicate ?label .";
|
"?link ?linkLabelPredicate ?label .";
|
||||||
|
|
||||||
static String N3_FOR_RANK =
|
static String N3_FOR_RANK =
|
||||||
"?link ?rankPredicate ?rank .";
|
"?link ?rankPredicate ?rank .";
|
||||||
|
|
||||||
/* *********** SPARQL queries for existing values ************** */
|
/* *********** SPARQL queries for existing values ************** */
|
||||||
|
|
||||||
static String URL_QUERY =
|
static String URL_QUERY =
|
||||||
"SELECT ?urlExisting WHERE { ?link ?linkUrlPredicate ?urlExisting }";
|
"SELECT ?urlExisting WHERE { ?link ?linkUrlPredicate ?urlExisting }";
|
||||||
|
|
||||||
static String URLTYPE_QUERY =
|
static String URLTYPE_QUERY =
|
||||||
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
||||||
"SELECT ?linkClassExisting WHERE { ?link vitro:mostSpecificType ?linkClassExisting }";
|
"SELECT ?linkClassExisting WHERE { ?link vitro:mostSpecificType ?linkClassExisting }";
|
||||||
|
|
||||||
static String ANCHOR_QUERY =
|
static String ANCHOR_QUERY =
|
||||||
"SELECT ?labelExisting WHERE { ?link ?linkLabelPredicate ?labelExisting }";
|
"SELECT ?labelExisting WHERE { ?link ?linkLabelPredicate ?labelExisting }";
|
||||||
|
|
||||||
static String RANK_QUERY =
|
static String RANK_QUERY =
|
||||||
"SELECT ?rankExisting WHERE { ?link ?rankPredicate ?rankExisting }";
|
"SELECT ?rankExisting WHERE { ?link ?rankPredicate ?rankExisting }";
|
||||||
|
|
||||||
static String core = "http://vivoweb.org/ontology/core#";
|
static String core = "http://vivoweb.org/ontology/core#";
|
||||||
|
|
||||||
static String individualVcardQuery =
|
static String individualVcardQuery =
|
||||||
"SELECT ?existingVcard WHERE { \n" +
|
"SELECT ?existingVcard WHERE { \n" +
|
||||||
"?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?existingVcard . \n" +
|
"?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?existingVcard . \n" +
|
||||||
|
@ -177,7 +177,7 @@ public class AddEditWebpageFormGenerator extends BaseEditConfigurationGenerator
|
||||||
|
|
||||||
/* Note on ordering by rank in sparql: if there is a non-integer value on a link, that will be returned,
|
/* Note on ordering by rank in sparql: if there is a non-integer value on a link, that will be returned,
|
||||||
* since it's ranked highest. Preventing that would require getting all the ranks and sorting in Java,
|
* since it's ranked highest. Preventing that would require getting all the ranks and sorting in Java,
|
||||||
* throwing out non-int values.
|
* throwing out non-int values.
|
||||||
*/
|
*/
|
||||||
private static String MAX_RANK_QUERY = ""
|
private static String MAX_RANK_QUERY = ""
|
||||||
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
|
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
|
||||||
|
@ -187,23 +187,23 @@ public class AddEditWebpageFormGenerator extends BaseEditConfigurationGenerator
|
||||||
+ " ?vcard vcard:hasURL ?link . \n"
|
+ " ?vcard vcard:hasURL ?link . \n"
|
||||||
+ " ?link core:rank ?rank .\n"
|
+ " ?link core:rank ?rank .\n"
|
||||||
+ "} ORDER BY DESC(?rank) LIMIT 1";
|
+ "} ORDER BY DESC(?rank) LIMIT 1";
|
||||||
|
|
||||||
private int getMaxRank(String objectUri, String subjectUri, VitroRequest vreq) {
|
private int getMaxRank(String objectUri, String subjectUri, VitroRequest vreq) {
|
||||||
|
|
||||||
int maxRank = 0; // default value
|
int maxRank = 0; // default value
|
||||||
if (objectUri == null) { // adding new webpage
|
if (objectUri == null) { // adding new webpage
|
||||||
String queryStr = QueryUtils.subUriForQueryVar(this.getMaxRankQueryStr(), "subject", subjectUri);
|
String queryStr = QueryUtils.subUriForQueryVar(this.getMaxRankQueryStr(), "subject", subjectUri);
|
||||||
log.debug("Query string is: " + queryStr);
|
log.debug("Query string is: " + queryStr);
|
||||||
try {
|
try {
|
||||||
ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
|
ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
|
||||||
if (results != null && results.hasNext()) { // there is at most one result
|
if (results != null && results.hasNext()) { // there is at most one result
|
||||||
QuerySolution soln = results.next();
|
QuerySolution soln = results.next();
|
||||||
RDFNode node = soln.get("rank");
|
RDFNode node = soln.get("rank");
|
||||||
if (node != null && node.isLiteral()) {
|
if (node != null && node.isLiteral()) {
|
||||||
// node.asLiteral().getInt() won't return an xsd:string that
|
// node.asLiteral().getInt() won't return an xsd:string that
|
||||||
// can be parsed as an int.
|
// can be parsed as an int.
|
||||||
int rank = Integer.parseInt(node.asLiteral().getLexicalForm());
|
int rank = Integer.parseInt(node.asLiteral().getLexicalForm());
|
||||||
if (rank > maxRank) {
|
if (rank > maxRank) {
|
||||||
log.debug("setting maxRank to " + rank);
|
log.debug("setting maxRank to " + rank);
|
||||||
maxRank = rank;
|
maxRank = rank;
|
||||||
}
|
}
|
||||||
|
@ -217,11 +217,11 @@ public class AddEditWebpageFormGenerator extends BaseEditConfigurationGenerator
|
||||||
}
|
}
|
||||||
return maxRank;
|
return maxRank;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getTemplate() {
|
protected String getTemplate() {
|
||||||
return formTemplate;
|
return formTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getMaxRankQueryStr() {
|
protected String getMaxRankQueryStr() {
|
||||||
return MAX_RANK_QUERY;
|
return MAX_RANK_QUERY;
|
||||||
}
|
}
|
||||||
|
@ -238,8 +238,8 @@ public class AddEditWebpageFormGenerator extends BaseEditConfigurationGenerator
|
||||||
String rangeUri = (String) vreq.getParameter("rangeUri");
|
String rangeUri = (String) vreq.getParameter("rangeUri");
|
||||||
String generatorName = "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManageWebpagesForIndividualGenerator";
|
String generatorName = "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManageWebpagesForIndividualGenerator";
|
||||||
String editUrl = EditConfigurationUtils.getEditUrlWithoutContext(vreq);
|
String editUrl = EditConfigurationUtils.getEditUrlWithoutContext(vreq);
|
||||||
String returnPath = editUrl + "?subjectUri=" + UrlBuilder.urlEncode(subjectUri) +
|
String returnPath = editUrl + "?subjectUri=" + UrlBuilder.urlEncode(subjectUri) +
|
||||||
"&predicateUri=" + UrlBuilder.urlEncode(predicateUri) +
|
"&predicateUri=" + UrlBuilder.urlEncode(predicateUri) +
|
||||||
"&editForm=" + UrlBuilder.urlEncode(generatorName);
|
"&editForm=" + UrlBuilder.urlEncode(generatorName);
|
||||||
if(domainUri != null && !domainUri.isEmpty()) {
|
if(domainUri != null && !domainUri.isEmpty()) {
|
||||||
returnPath += "&domainUri=" + UrlBuilder.urlEncode(domainUri);
|
returnPath += "&domainUri=" + UrlBuilder.urlEncode(domainUri);
|
||||||
|
@ -248,12 +248,12 @@ public class AddEditWebpageFormGenerator extends BaseEditConfigurationGenerator
|
||||||
returnPath += "&rangeUri=" + UrlBuilder.urlEncode(rangeUri);
|
returnPath += "&rangeUri=" + UrlBuilder.urlEncode(rangeUri);
|
||||||
}
|
}
|
||||||
return returnPath;
|
return returnPath;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getLinkUri(VitroRequest vreq) {
|
private String getLinkUri(VitroRequest vreq) {
|
||||||
String linkUri = vreq.getParameter("linkUri");
|
String linkUri = vreq.getParameter("linkUri");
|
||||||
|
|
||||||
return linkUri;
|
return linkUri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,36 +6,36 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesOptions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
||||||
/**
|
/**
|
||||||
* Generates the edit configuration for adding a Role to a Person.
|
* Generates the edit configuration for adding a Role to a Person.
|
||||||
|
|
||||||
Stage one is selecting the type of the non-person thing
|
Stage one is selecting the type of the non-person thing
|
||||||
associated with the Role with the intention of reducing the
|
associated with the Role with the intention of reducing the
|
||||||
number of Individuals that the user has to select from.
|
number of Individuals that the user has to select from.
|
||||||
Stage two is selecting the non-person Individual to associate
|
Stage two is selecting the non-person Individual to associate
|
||||||
with the Role.
|
with the Role.
|
||||||
|
|
||||||
This is intended to create a set of statements like:
|
This is intended to create a set of statements like:
|
||||||
|
|
||||||
?person core:hasResearchActivityRole ?newRole.
|
?person core:hasResearchActivityRole ?newRole.
|
||||||
?newRole rdf:type core:ResearchActivityRole ;
|
?newRole rdf:type core:ResearchActivityRole ;
|
||||||
roleToActivityPredicate ?someActivity .
|
roleToActivityPredicate ?someActivity .
|
||||||
?someActivity rdf:type core:ResearchActivity .
|
?someActivity rdf:type core:ResearchActivity .
|
||||||
?someActivity rdfs:label "activity title" .
|
?someActivity rdfs:label "activity title" .
|
||||||
|
|
||||||
|
|
||||||
Each subclass of the abstract two stage Generator class will have the option of overriding certain
|
Each subclass of the abstract two stage Generator class will have the option of overriding certain
|
||||||
methods, and must always implement the following methods:
|
methods, and must always implement the following methods:
|
||||||
getRoleType
|
getRoleType
|
||||||
getRoleActivityTypeOptionsType
|
getRoleActivityTypeOptionsType
|
||||||
getRoleActivityTypeObjectClassUri
|
getRoleActivityTypeObjectClassUri
|
||||||
getRoleActivityTypeLiteralOptions
|
getRoleActivityTypeLiteralOptions
|
||||||
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class AddEditorRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
public class AddEditorRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
||||||
private static String TEMPLATE = "addEditorRoleToPerson.ftl";
|
private static String TEMPLATE = "addEditorRoleToPerson.ftl";
|
||||||
private static String OPTION_CLASS_URI = "http://purl.org/ontology/bibo/Collection";
|
private static String OPTION_CLASS_URI = "http://purl.org/ontology/bibo/Collection";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getTemplate(){ return TEMPLATE; }
|
String getTemplate(){ return TEMPLATE; }
|
||||||
|
|
||||||
|
@ -49,12 +49,12 @@ public class AddEditorRoleToPersonGenerator extends AddRoleToPersonTwoStageGener
|
||||||
return new ChildVClassesOptions(OPTION_CLASS_URI)
|
return new ChildVClassesOptions(OPTION_CLASS_URI)
|
||||||
.setDefaultOptionLabel("Select type");
|
.setDefaultOptionLabel("Select type");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Do not show the role label field for the AddEditorRoleToPerson form */
|
/** Do not show the role label field for the AddEditorRoleToPerson form */
|
||||||
@Override
|
@Override
|
||||||
boolean isShowRoleLabelField() { return true; }
|
boolean isShowRoleLabelField() { return true; }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use the methods below to change the date/time precision in the
|
* Use the methods below to change the date/time precision in the
|
||||||
* custom form associated with this generator. When not used, the
|
* custom form associated with this generator. When not used, the
|
||||||
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
||||||
|
@ -70,5 +70,5 @@ public class AddEditorRoleToPersonGenerator extends AddRoleToPersonTwoStageGener
|
||||||
String precision = VitroVocabulary.Precision.DAY.uri();
|
String precision = VitroVocabulary.Precision.DAY.uri();
|
||||||
return precision;
|
return precision;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,9 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a slightly unusual generator that is used by Manage Editors on
|
* This is a slightly unusual generator that is used by Manage Editors on
|
||||||
* information resources.
|
* information resources.
|
||||||
*
|
*
|
||||||
* It is intended to always be an add, and never an update.
|
* It is intended to always be an add, and never an update.
|
||||||
*/
|
*/
|
||||||
public class AddEditorsToInformationResourceGenerator extends VivoBaseGenerator implements EditConfigurationGenerator {
|
public class AddEditorsToInformationResourceGenerator extends VivoBaseGenerator implements EditConfigurationGenerator {
|
||||||
public static Log log = LogFactory.getLog(AddEditorsToInformationResourceGenerator.class);
|
public static Log log = LogFactory.getLog(AddEditorsToInformationResourceGenerator.class);
|
||||||
|
@ -45,7 +45,7 @@ public class AddEditorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
HttpSession session) {
|
HttpSession session) {
|
||||||
EditConfigurationVTwo editConfiguration = new EditConfigurationVTwo();
|
EditConfigurationVTwo editConfiguration = new EditConfigurationVTwo();
|
||||||
initBasics(editConfiguration, vreq);
|
initBasics(editConfiguration, vreq);
|
||||||
initPropertyParameters(vreq, session, editConfiguration);
|
initPropertyParameters(vreq, session, editConfiguration);
|
||||||
|
|
||||||
|
@ -53,21 +53,21 @@ public class AddEditorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
setUrlToReturnTo(editConfiguration, vreq);
|
setUrlToReturnTo(editConfiguration, vreq);
|
||||||
|
|
||||||
//set variable names
|
//set variable names
|
||||||
editConfiguration.setVarNameForSubject("infoResource");
|
editConfiguration.setVarNameForSubject("infoResource");
|
||||||
editConfiguration.setVarNameForPredicate("predicate");
|
editConfiguration.setVarNameForPredicate("predicate");
|
||||||
editConfiguration.setVarNameForObject("editorshipUri");
|
editConfiguration.setVarNameForObject("editorshipUri");
|
||||||
|
|
||||||
// Required N3
|
// Required N3
|
||||||
editConfiguration.setN3Required( list( getN3NewEditorship() ) );
|
editConfiguration.setN3Required( list( getN3NewEditorship() ) );
|
||||||
|
|
||||||
// Optional N3
|
// Optional N3
|
||||||
editConfiguration.setN3Optional( generateN3Optional());
|
editConfiguration.setN3Optional( generateN3Optional());
|
||||||
|
|
||||||
editConfiguration.addNewResource("editorshipUri", DEFAULT_NS_TOKEN);
|
editConfiguration.addNewResource("editorshipUri", DEFAULT_NS_TOKEN);
|
||||||
editConfiguration.addNewResource("newPerson", DEFAULT_NS_TOKEN);
|
editConfiguration.addNewResource("newPerson", DEFAULT_NS_TOKEN);
|
||||||
editConfiguration.addNewResource("vcardPerson", DEFAULT_NS_TOKEN);
|
editConfiguration.addNewResource("vcardPerson", DEFAULT_NS_TOKEN);
|
||||||
editConfiguration.addNewResource("vcardName", DEFAULT_NS_TOKEN);
|
editConfiguration.addNewResource("vcardName", DEFAULT_NS_TOKEN);
|
||||||
|
|
||||||
//In scope
|
//In scope
|
||||||
setUrisAndLiteralsInScope(editConfiguration, vreq);
|
setUrisAndLiteralsInScope(editConfiguration, vreq);
|
||||||
|
|
||||||
|
@ -87,130 +87,130 @@ public class AddEditorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
|
|
||||||
//Adding additional data, specifically edit mode
|
//Adding additional data, specifically edit mode
|
||||||
addFormSpecificData(editConfiguration, vreq);
|
addFormSpecificData(editConfiguration, vreq);
|
||||||
|
|
||||||
editConfiguration.addValidator(new AntiXssValidation());
|
editConfiguration.addValidator(new AntiXssValidation());
|
||||||
|
|
||||||
//NOITCE this generator does not run prepare() since it
|
//NOITCE this generator does not run prepare() since it
|
||||||
//is never an update and has no SPARQL for existing
|
//is never an update and has no SPARQL for existing
|
||||||
|
|
||||||
return editConfiguration;
|
return editConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUrlToReturnTo(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setUrlToReturnTo(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
editConfiguration.setUrlPatternToReturnTo(EditConfigurationUtils.getFormUrlWithoutContext(vreq));
|
editConfiguration.setUrlPatternToReturnTo(EditConfigurationUtils.getFormUrlWithoutContext(vreq));
|
||||||
}
|
}
|
||||||
|
|
||||||
/***N3 strings both required and optional***/
|
/***N3 strings both required and optional***/
|
||||||
|
|
||||||
public String getN3PrefixString() {
|
public String getN3PrefixString() {
|
||||||
return "@prefix core: <" + vivoCore + "> .\n" +
|
return "@prefix core: <" + vivoCore + "> .\n" +
|
||||||
"@prefix foaf: <" + foaf + "> . \n" ;
|
"@prefix foaf: <" + foaf + "> . \n" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3NewEditorship() {
|
private String getN3NewEditorship() {
|
||||||
return getN3PrefixString() +
|
return getN3PrefixString() +
|
||||||
"?editorshipUri a core:Editorship ;\n" +
|
"?editorshipUri a core:Editorship ;\n" +
|
||||||
" core:relates ?infoResource .\n" +
|
" core:relates ?infoResource .\n" +
|
||||||
"?infoResource core:relatedBy ?editorshipUri .";
|
"?infoResource core:relatedBy ?editorshipUri .";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3EditorshipRank() {
|
private String getN3EditorshipRank() {
|
||||||
return getN3PrefixString() +
|
return getN3PrefixString() +
|
||||||
"?editorshipUri core:editorRank ?rank .";
|
"?editorshipUri core:editorRank ?rank .";
|
||||||
}
|
}
|
||||||
|
|
||||||
//first name, middle name, last name, and new perseon for new editor being created, and n3 for existing person
|
//first name, middle name, last name, and new perseon for new editor being created, and n3 for existing person
|
||||||
//if existing person selected as editor
|
//if existing person selected as editor
|
||||||
public List<String> generateN3Optional() {
|
public List<String> generateN3Optional() {
|
||||||
return list(
|
return list(
|
||||||
getN3NewPersonFirstName() ,
|
getN3NewPersonFirstName() ,
|
||||||
getN3NewPersonMiddleName(),
|
getN3NewPersonMiddleName(),
|
||||||
getN3NewPersonLastName(),
|
getN3NewPersonLastName(),
|
||||||
getN3NewPerson(),
|
getN3NewPerson(),
|
||||||
getN3EditorshipRank(),
|
getN3EditorshipRank(),
|
||||||
getN3ForExistingPerson());
|
getN3ForExistingPerson());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getN3NewPersonFirstName() {
|
private String getN3NewPersonFirstName() {
|
||||||
return getN3PrefixString() +
|
return getN3PrefixString() +
|
||||||
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
||||||
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
||||||
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
||||||
"?vcardName vcard:givenName ?firstName .";
|
"?vcardName vcard:givenName ?firstName .";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3NewPersonMiddleName() {
|
private String getN3NewPersonMiddleName() {
|
||||||
return getN3PrefixString() +
|
return getN3PrefixString() +
|
||||||
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
||||||
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
||||||
"?vcardPerson a vcard:Individual . \n" +
|
"?vcardPerson a vcard:Individual . \n" +
|
||||||
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a vcard:Name . \n" +
|
"?vcardName a vcard:Name . \n" +
|
||||||
"?vcardName <http://vivoweb.org/ontology/core#middleName> ?middleName .";
|
"?vcardName <http://vivoweb.org/ontology/core#middleName> ?middleName .";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3NewPersonLastName() {
|
private String getN3NewPersonLastName() {
|
||||||
return getN3PrefixString() +
|
return getN3PrefixString() +
|
||||||
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
||||||
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
||||||
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
||||||
"?vcardName vcard:familyName ?lastName .";
|
"?vcardName vcard:familyName ?lastName .";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3NewPerson() {
|
private String getN3NewPerson() {
|
||||||
return getN3PrefixString() +
|
return getN3PrefixString() +
|
||||||
"?newPerson a foaf:Person ;\n" +
|
"?newPerson a foaf:Person ;\n" +
|
||||||
"<" + RDFS.label.getURI() + "> ?label .\n" +
|
"<" + RDFS.label.getURI() + "> ?label .\n" +
|
||||||
"?editorshipUri core:relates ?newPerson .\n" +
|
"?editorshipUri core:relates ?newPerson .\n" +
|
||||||
"?newPerson core:relatedBy ?editorshipUri . ";
|
"?newPerson core:relatedBy ?editorshipUri . ";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3ForExistingPerson() {
|
private String getN3ForExistingPerson() {
|
||||||
return getN3PrefixString() +
|
return getN3PrefixString() +
|
||||||
"?editorshipUri core:relates ?personUri .\n" +
|
"?editorshipUri core:relates ?personUri .\n" +
|
||||||
"?personUri core:relatedBy ?editorshipUri .";
|
"?personUri core:relatedBy ?editorshipUri .";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get new resources */
|
/** Get new resources */
|
||||||
//A new editorship uri will always be created when an editor is added
|
//A new editorship uri will always be created when an editor is added
|
||||||
//A new person may be added if a person not in the system will be added as editor
|
//A new person may be added if a person not in the system will be added as editor
|
||||||
private Map<String, String> generateNewResources(VitroRequest vreq) {
|
private Map<String, String> generateNewResources(VitroRequest vreq) {
|
||||||
|
|
||||||
|
|
||||||
HashMap<String, String> newResources = new HashMap<String, String>();
|
HashMap<String, String> newResources = new HashMap<String, String>();
|
||||||
newResources.put("editorshipUri", DEFAULT_NS_TOKEN);
|
newResources.put("editorshipUri", DEFAULT_NS_TOKEN);
|
||||||
newResources.put("newPerson", DEFAULT_NS_TOKEN);
|
newResources.put("newPerson", DEFAULT_NS_TOKEN);
|
||||||
newResources.put("vcardPerson", DEFAULT_NS_TOKEN);
|
newResources.put("vcardPerson", DEFAULT_NS_TOKEN);
|
||||||
newResources.put("vcardName", DEFAULT_NS_TOKEN);
|
newResources.put("vcardName", DEFAULT_NS_TOKEN);
|
||||||
return newResources;
|
return newResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set URIS and Literals In Scope and on form and supporting methods */
|
/** Set URIS and Literals In Scope and on form and supporting methods */
|
||||||
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
//Uris in scope always contain subject and predicate
|
//Uris in scope always contain subject and predicate
|
||||||
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
||||||
urisInScope.put(editConfiguration.getVarNameForSubject(),
|
urisInScope.put(editConfiguration.getVarNameForSubject(),
|
||||||
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
|
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
|
||||||
urisInScope.put(editConfiguration.getVarNameForPredicate(),
|
urisInScope.put(editConfiguration.getVarNameForPredicate(),
|
||||||
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
|
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
|
||||||
editConfiguration.setUrisInScope(urisInScope);
|
editConfiguration.setUrisInScope(urisInScope);
|
||||||
//no literals in scope
|
//no literals in scope
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
public void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
List<String> urisOnForm = new ArrayList<String>();
|
List<String> urisOnForm = new ArrayList<String>();
|
||||||
//If an existing person is being used as an editor, need to get the person uri
|
//If an existing person is being used as an editor, need to get the person uri
|
||||||
urisOnForm.add("personUri");
|
urisOnForm.add("personUri");
|
||||||
editConfiguration.setUrisOnform(urisOnForm);
|
editConfiguration.setUrisOnform(urisOnForm);
|
||||||
|
|
||||||
//for person who is not in system, need to add first name, last name and middle name
|
//for person who is not in system, need to add first name, last name and middle name
|
||||||
//Also need to store editorship rank and label of editor
|
//Also need to store editorship rank and label of editor
|
||||||
List<String> literalsOnForm = list("firstName",
|
List<String> literalsOnForm = list("firstName",
|
||||||
|
@ -219,10 +219,10 @@ public class AddEditorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
"rank",
|
"rank",
|
||||||
"label");
|
"label");
|
||||||
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set SPARQL Queries and supporting methods. */
|
/** Set SPARQL Queries and supporting methods. */
|
||||||
private void setSparqlQueries(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setSparqlQueries(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
//Sparql queries are all empty for existing values
|
//Sparql queries are all empty for existing values
|
||||||
//This form is different from the others that it gets multiple editors on the same page
|
//This form is different from the others that it gets multiple editors on the same page
|
||||||
//and that information will be queried and stored in the additional form specific data
|
//and that information will be queried and stored in the additional form specific data
|
||||||
|
@ -232,12 +232,12 @@ public class AddEditorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
editConfiguration.setSparqlForAdditionalUrisInScope(new HashMap<String, String>());
|
editConfiguration.setSparqlForAdditionalUrisInScope(new HashMap<String, String>());
|
||||||
editConfiguration.setSparqlForAdditionalLiteralsInScope(new HashMap<String, String>());
|
editConfiguration.setSparqlForAdditionalLiteralsInScope(new HashMap<String, String>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Set Fields and supporting methods
|
* Set Fields and supporting methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
|
public void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
|
||||||
setLabelField(editConfiguration);
|
setLabelField(editConfiguration);
|
||||||
setFirstNameField(editConfiguration);
|
setFirstNameField(editConfiguration);
|
||||||
|
@ -246,7 +246,7 @@ public class AddEditorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
setRankField(editConfiguration);
|
setRankField(editConfiguration);
|
||||||
setPersonUriField(editConfiguration);
|
setPersonUriField(editConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLabelField(EditConfigurationVTwo editConfiguration) {
|
private void setLabelField(EditConfigurationVTwo editConfiguration) {
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
setName("label").
|
setName("label").
|
||||||
|
@ -352,13 +352,13 @@ public class AddEditorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
+ "WHERE { \n"
|
+ "WHERE { \n"
|
||||||
+ "?subject core:relatedBy ?editorshipURI . \n"
|
+ "?subject core:relatedBy ?editorshipURI . \n"
|
||||||
+ "?editorshipURI a core:Editorship . \n"
|
+ "?editorshipURI a core:Editorship . \n"
|
||||||
+ "?editorshipURI core:relates ?editorURI . \n"
|
+ "?editorshipURI core:relates ?editorURI . \n"
|
||||||
+ "?editorURI a foaf:Person . \n"
|
+ "?editorURI a foaf:Person . \n"
|
||||||
+ "OPTIONAL { ?editorURI rdfs:label ?editorName } \n"
|
+ "OPTIONAL { ?editorURI rdfs:label ?editorName } \n"
|
||||||
+ "OPTIONAL { ?editorshipURI core:rank ?rank } \n"
|
+ "OPTIONAL { ?editorshipURI core:rank ?rank } \n"
|
||||||
+ "} ORDER BY ?rank";
|
+ "} ORDER BY ?rank";
|
||||||
|
|
||||||
|
|
||||||
private List<EditorshipInfo> getExistingEditorships(String subjectUri, VitroRequest vreq) {
|
private List<EditorshipInfo> getExistingEditorships(String subjectUri, VitroRequest vreq) {
|
||||||
RDFService rdfService = vreq.getRDFService();
|
RDFService rdfService = vreq.getRDFService();
|
||||||
|
|
||||||
|
@ -387,7 +387,7 @@ public class AddEditorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
}
|
}
|
||||||
log.debug("editorships = " + editorships);
|
log.debug("editorships = " + editorships);
|
||||||
return getEditorshipInfo(editorships);
|
return getEditorshipInfo(editorships);
|
||||||
}
|
}
|
||||||
|
@ -399,22 +399,22 @@ public class AddEditorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
+ " ?editorship a core:Editorship . \n"
|
+ " ?editorship a core:Editorship . \n"
|
||||||
+ " ?editorship core:rank ?rank .\n"
|
+ " ?editorship core:rank ?rank .\n"
|
||||||
+ "} ORDER BY DESC(?rank) LIMIT 1";
|
+ "} ORDER BY DESC(?rank) LIMIT 1";
|
||||||
|
|
||||||
private int getMaxRank(String subjectUri, VitroRequest vreq) {
|
private int getMaxRank(String subjectUri, VitroRequest vreq) {
|
||||||
|
|
||||||
int maxRank = 0; // default value
|
int maxRank = 0; // default value
|
||||||
String queryStr = QueryUtils.subUriForQueryVar(this.getMaxRankQueryStr(), "subject", subjectUri);
|
String queryStr = QueryUtils.subUriForQueryVar(this.getMaxRankQueryStr(), "subject", subjectUri);
|
||||||
log.debug("maxRank query string is: " + queryStr);
|
log.debug("maxRank query string is: " + queryStr);
|
||||||
try {
|
try {
|
||||||
ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
|
ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
|
||||||
if (results != null && results.hasNext()) { // there is at most one result
|
if (results != null && results.hasNext()) { // there is at most one result
|
||||||
QuerySolution soln = results.next();
|
QuerySolution soln = results.next();
|
||||||
RDFNode node = soln.get("rank");
|
RDFNode node = soln.get("rank");
|
||||||
if (node != null && node.isLiteral()) {
|
if (node != null && node.isLiteral()) {
|
||||||
// node.asLiteral().getInt() won't return an xsd:string that
|
// node.asLiteral().getInt() won't return an xsd:string that
|
||||||
// can be parsed as an int.
|
// can be parsed as an int.
|
||||||
int rank = Integer.parseInt(node.asLiteral().getLexicalForm());
|
int rank = Integer.parseInt(node.asLiteral().getLexicalForm());
|
||||||
if (rank > maxRank) {
|
if (rank > maxRank) {
|
||||||
log.debug("setting maxRank to " + rank);
|
log.debug("setting maxRank to " + rank);
|
||||||
maxRank = rank;
|
maxRank = rank;
|
||||||
}
|
}
|
||||||
|
@ -468,8 +468,8 @@ public class AddEditorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
//Editor information for editorship node
|
//Editor information for editorship node
|
||||||
private String editorUri;
|
private String editorUri;
|
||||||
private String editorName;
|
private String editorName;
|
||||||
|
|
||||||
public EditorshipInfo(String inputEditorshipUri,
|
public EditorshipInfo(String inputEditorshipUri,
|
||||||
String inputEditorshipName,
|
String inputEditorshipName,
|
||||||
String inputEditorUri,
|
String inputEditorUri,
|
||||||
String inputEditorName) {
|
String inputEditorName) {
|
||||||
|
@ -479,25 +479,25 @@ public class AddEditorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
editorName = inputEditorName;
|
editorName = inputEditorName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Getters - specifically required for Freemarker template's access to POJO
|
//Getters - specifically required for Freemarker template's access to POJO
|
||||||
public String getEditorshipUri() {
|
public String getEditorshipUri() {
|
||||||
return editorshipUri;
|
return editorshipUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEditorshipName() {
|
public String getEditorshipName() {
|
||||||
return editorshipName;
|
return editorshipName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEditorUri() {
|
public String getEditorUri() {
|
||||||
return editorUri;
|
return editorUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEditorName() {
|
public String getEditorName() {
|
||||||
return editorName;
|
return editorName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static final String DEFAULT_NS_TOKEN=null; //null forces the default NS
|
static final String DEFAULT_NS_TOKEN=null; //null forces the default NS
|
||||||
|
|
||||||
protected String getMaxRankQueryStr() {
|
protected String getMaxRankQueryStr() {
|
||||||
|
|
|
@ -32,12 +32,12 @@ import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
|
||||||
|
|
||||||
public class AddEditorshipToPersonGenerator extends VivoBaseGenerator implements
|
public class AddEditorshipToPersonGenerator extends VivoBaseGenerator implements
|
||||||
EditConfigurationGenerator {
|
EditConfigurationGenerator {
|
||||||
|
|
||||||
public AddEditorshipToPersonGenerator() {}
|
public AddEditorshipToPersonGenerator() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) throws Exception {
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) throws Exception {
|
||||||
|
|
||||||
if( EditConfigurationUtils.getObjectUri(vreq) == null ){
|
if( EditConfigurationUtils.getObjectUri(vreq) == null ){
|
||||||
return doAddNew(vreq,session);
|
return doAddNew(vreq,session);
|
||||||
}else{
|
}else{
|
||||||
|
@ -47,7 +47,7 @@ public class AddEditorshipToPersonGenerator extends VivoBaseGenerator implements
|
||||||
|
|
||||||
private EditConfigurationVTwo doSkipToDocument(VitroRequest vreq) {
|
private EditConfigurationVTwo doSkipToDocument(VitroRequest vreq) {
|
||||||
Individual editorshipNode = EditConfigurationUtils.getObjectIndividual(vreq);
|
Individual editorshipNode = EditConfigurationUtils.getObjectIndividual(vreq);
|
||||||
|
|
||||||
//try to get the document
|
//try to get the document
|
||||||
String documentQueryStr = "SELECT ?obj \n" +
|
String documentQueryStr = "SELECT ?obj \n" +
|
||||||
"WHERE { <" + editorshipNode.getURI() + "> <http://vivoweb.org/ontology/core#relates> ?obj . \n" +
|
"WHERE { <" + editorshipNode.getURI() + "> <http://vivoweb.org/ontology/core#relates> ?obj . \n" +
|
||||||
|
@ -60,8 +60,8 @@ public class AddEditorshipToPersonGenerator extends VivoBaseGenerator implements
|
||||||
return doBadEditorshipNoPub( vreq );
|
return doBadEditorshipNoPub( vreq );
|
||||||
}else if( rs.size() > 1 ){
|
}else if( rs.size() > 1 ){
|
||||||
return doBadEditorshipMultiplePubs(vreq);
|
return doBadEditorshipMultiplePubs(vreq);
|
||||||
}else{
|
}else{
|
||||||
//skip to document
|
//skip to document
|
||||||
RDFNode objNode = rs.next().get("obj");
|
RDFNode objNode = rs.next().get("obj");
|
||||||
if (!objNode.isResource() || objNode.isAnon()) {
|
if (!objNode.isResource() || objNode.isAnon()) {
|
||||||
return doBadEditorshipNoPub( vreq );
|
return doBadEditorshipNoPub( vreq );
|
||||||
|
@ -77,38 +77,38 @@ public class AddEditorshipToPersonGenerator extends VivoBaseGenerator implements
|
||||||
|
|
||||||
protected EditConfigurationVTwo doAddNew(VitroRequest vreq,
|
protected EditConfigurationVTwo doAddNew(VitroRequest vreq,
|
||||||
HttpSession session) throws Exception {
|
HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
|
|
||||||
conf.setTemplate("addEditorshipToPerson.ftl");
|
conf.setTemplate("addEditorshipToPerson.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("person");
|
conf.setVarNameForSubject("person");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("editorship");
|
conf.setVarNameForObject("editorship");
|
||||||
|
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewEditorship ) );
|
conf.setN3Required( Arrays.asList( n3ForNewEditorship ) );
|
||||||
conf.setN3Optional( Arrays.asList( n3ForNewDocumentAssertion,
|
conf.setN3Optional( Arrays.asList( n3ForNewDocumentAssertion,
|
||||||
n3ForExistingDocumentAssertion ) );
|
n3ForExistingDocumentAssertion ) );
|
||||||
|
|
||||||
conf.addNewResource("editorship", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("editorship", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("newDocument", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("newDocument", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
conf.setUrisOnform(Arrays.asList("existingDocument", "documentType"));
|
conf.setUrisOnform(Arrays.asList("existingDocument", "documentType"));
|
||||||
conf.setLiteralsOnForm(Arrays.asList("documentLabel", "documentLabelDisplay" ));
|
conf.setLiteralsOnForm(Arrays.asList("documentLabel", "documentLabelDisplay" ));
|
||||||
|
|
||||||
conf.addSparqlForExistingLiteral("documentLabel", documentLabelQuery);
|
conf.addSparqlForExistingLiteral("documentLabel", documentLabelQuery);
|
||||||
|
|
||||||
conf.addSparqlForExistingUris("documentType", documentTypeQuery);
|
conf.addSparqlForExistingUris("documentType", documentTypeQuery);
|
||||||
conf.addSparqlForExistingUris("existingDocument", existingDocumentQuery);
|
conf.addSparqlForExistingUris("existingDocument", existingDocumentQuery);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("documentType").
|
setName("documentType").
|
||||||
setValidators( list("nonempty") ).
|
setValidators( list("nonempty") ).
|
||||||
setOptions( new ConstantFieldOptions("documentType", getDocumentTypeLiteralOptions() ))
|
setOptions( new ConstantFieldOptions("documentType", getDocumentTypeLiteralOptions() ))
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
|
@ -123,61 +123,61 @@ public class AddEditorshipToPersonGenerator extends VivoBaseGenerator implements
|
||||||
|
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
addFormSpecificData(conf, vreq);
|
addFormSpecificData(conf, vreq);
|
||||||
|
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* N3 assertions */
|
/* N3 assertions */
|
||||||
|
|
||||||
final static String n3ForNewEditorship =
|
final static String n3ForNewEditorship =
|
||||||
"@prefix vivo: <" + vivoCore + "> . \n" +
|
"@prefix vivo: <" + vivoCore + "> . \n" +
|
||||||
"?person ?predicate ?editorship . \n" +
|
"?person ?predicate ?editorship . \n" +
|
||||||
"?editorship a vivo:Editorship . \n" +
|
"?editorship a vivo:Editorship . \n" +
|
||||||
"?editorship vivo:relates ?person . " ;
|
"?editorship vivo:relates ?person . " ;
|
||||||
|
|
||||||
final static String n3ForNewDocumentAssertion =
|
final static String n3ForNewDocumentAssertion =
|
||||||
"@prefix vivo: <" + vivoCore + "> . \n" +
|
"@prefix vivo: <" + vivoCore + "> . \n" +
|
||||||
"?editorship vivo:relates ?newDocument . \n" +
|
"?editorship vivo:relates ?newDocument . \n" +
|
||||||
"?newDocument vivo:editedBy ?editorship . \n" +
|
"?newDocument vivo:editedBy ?editorship . \n" +
|
||||||
"?newDocument a ?documentType . \n" +
|
"?newDocument a ?documentType . \n" +
|
||||||
"?newDocument <" + label + "> ?documentLabel. " ;
|
"?newDocument <" + label + "> ?documentLabel. " ;
|
||||||
|
|
||||||
final static String n3ForExistingDocumentAssertion =
|
final static String n3ForExistingDocumentAssertion =
|
||||||
"@prefix vivo: <" + vivoCore + "> . \n" +
|
"@prefix vivo: <" + vivoCore + "> . \n" +
|
||||||
"?editorship vivo:relates ?existingDocument . \n" +
|
"?editorship vivo:relates ?existingDocument . \n" +
|
||||||
"?existingDocument vivo:editedBy ?editorship . \n" +
|
"?existingDocument vivo:editedBy ?editorship . \n" +
|
||||||
"?existingDocument a ?documentType . " ;
|
"?existingDocument a ?documentType . " ;
|
||||||
|
|
||||||
/* Queries for editing an existing entry */
|
/* Queries for editing an existing entry */
|
||||||
|
|
||||||
final static String documentTypeQuery =
|
final static String documentTypeQuery =
|
||||||
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
||||||
"PREFIX vivo: <" + vivoCore + "> . \n" +
|
"PREFIX vivo: <" + vivoCore + "> . \n" +
|
||||||
"PREFIX bibo: <http://purl.org/ontology/bibo/> . \n" +
|
"PREFIX bibo: <http://purl.org/ontology/bibo/> . \n" +
|
||||||
"SELECT ?documentType WHERE { \n" +
|
"SELECT ?documentType WHERE { \n" +
|
||||||
" ?editorship vivo:relates ?existingDocument . \n" +
|
" ?editorship vivo:relates ?existingDocument . \n" +
|
||||||
" ?existingDocument a <http://purl.obolibrary.org/obo/IAO_0000030> . \n" +
|
" ?existingDocument a <http://purl.obolibrary.org/obo/IAO_0000030> . \n" +
|
||||||
" ?existingDocument vitro:mostSpecificType ?documentType . \n" +
|
" ?existingDocument vitro:mostSpecificType ?documentType . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String documentLabelQuery =
|
final static String documentLabelQuery =
|
||||||
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
||||||
"PREFIX vivo: <" + vivoCore + "> . \n" +
|
"PREFIX vivo: <" + vivoCore + "> . \n" +
|
||||||
"PREFIX bibo: <http://purl.org/ontology/bibo/> . \n" +
|
"PREFIX bibo: <http://purl.org/ontology/bibo/> . \n" +
|
||||||
"SELECT ?documentLabel WHERE { \n" +
|
"SELECT ?documentLabel WHERE { \n" +
|
||||||
" ?editorship vivo:relates ?existingDocument . \n" +
|
" ?editorship vivo:relates ?existingDocument . \n" +
|
||||||
" ?existingDocument a <http://purl.obolibrary.org/obo/IAO_0000030> . \n" +
|
" ?existingDocument a <http://purl.obolibrary.org/obo/IAO_0000030> . \n" +
|
||||||
" ?existingDocument <" + label + "> ?documentLabel . \n" +
|
" ?existingDocument <" + label + "> ?documentLabel . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String existingDocumentQuery =
|
final static String existingDocumentQuery =
|
||||||
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
||||||
"PREFIX vivo: <" + vivoCore + "> . \n" +
|
"PREFIX vivo: <" + vivoCore + "> . \n" +
|
||||||
"PREFIX bibo: <http://purl.org/ontology/bibo/> . \n" +
|
"PREFIX bibo: <http://purl.org/ontology/bibo/> . \n" +
|
||||||
"SELECT existingDocument WHERE { \n" +
|
"SELECT existingDocument WHERE { \n" +
|
||||||
" ?editorship vivo:relates ?existingDocument . \n" +
|
" ?editorship vivo:relates ?existingDocument . \n" +
|
||||||
" ?existingDocument a <http://purl.obolibrary.org/obo/IAO_0000030> . \n" +
|
" ?existingDocument a <http://purl.obolibrary.org/obo/IAO_0000030> . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
//Adding form specific data such as edit mode
|
//Adding form specific data such as edit mode
|
||||||
|
@ -202,7 +202,7 @@ public class AddEditorshipToPersonGenerator extends VivoBaseGenerator implements
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<List<String>> getDocumentTypeLiteralOptions() {
|
private List<List<String>> getDocumentTypeLiteralOptions() {
|
||||||
List<List<String>> literalOptions = new ArrayList<List<String>>();
|
List<List<String>> literalOptions = new ArrayList<List<String>>();
|
||||||
literalOptions.add(list("http://purl.org/ontology/bibo/Book", "Book"));
|
literalOptions.add(list("http://purl.org/ontology/bibo/Book", "Book"));
|
||||||
|
|
|
@ -21,95 +21,95 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
|
||||||
public class AddFullNameToPersonGenerator extends VivoBaseGenerator implements
|
public class AddFullNameToPersonGenerator extends VivoBaseGenerator implements
|
||||||
EditConfigurationGenerator {
|
EditConfigurationGenerator {
|
||||||
private Log log = LogFactory.getLog(AddFullNameToPersonGenerator.class);
|
private Log log = LogFactory.getLog(AddFullNameToPersonGenerator.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
HttpSession session) throws Exception {
|
HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
String fullNameUri = getFullNameUri(vreq);
|
String fullNameUri = getFullNameUri(vreq);
|
||||||
|
|
||||||
conf.setTemplate("addFullNameToPerson.ftl");
|
conf.setTemplate("addFullNameToPerson.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("person");
|
conf.setVarNameForSubject("person");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("individualVcard");
|
conf.setVarNameForObject("individualVcard");
|
||||||
|
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewName ) );
|
conf.setN3Required( Arrays.asList( n3ForNewName ) );
|
||||||
conf.setN3Optional( Arrays.asList( firstNameAssertion, middleNameAssertion, lastNameAssertion, suffixAssertion, prefixAssertion ) );
|
conf.setN3Optional( Arrays.asList( firstNameAssertion, middleNameAssertion, lastNameAssertion, suffixAssertion, prefixAssertion ) );
|
||||||
|
|
||||||
conf.addNewResource("fullName", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("fullName", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("individualVcard", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("individualVcard", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
conf.setLiteralsOnForm(Arrays.asList("firstName", "middleName", "lastName", "suffix", "prefix" ));
|
conf.setLiteralsOnForm(Arrays.asList("firstName", "middleName", "lastName", "suffix", "prefix" ));
|
||||||
|
|
||||||
conf.addSparqlForExistingLiteral("firstName", firstNameQuery);
|
conf.addSparqlForExistingLiteral("firstName", firstNameQuery);
|
||||||
conf.addSparqlForExistingLiteral("middleName", middleNameQuery);
|
conf.addSparqlForExistingLiteral("middleName", middleNameQuery);
|
||||||
conf.addSparqlForExistingLiteral("lastName", lastNameQuery);
|
conf.addSparqlForExistingLiteral("lastName", lastNameQuery);
|
||||||
conf.addSparqlForExistingLiteral("suffix", suffixQuery);
|
conf.addSparqlForExistingLiteral("suffix", suffixQuery);
|
||||||
conf.addSparqlForExistingLiteral("prefix", prefixQuery);
|
conf.addSparqlForExistingLiteral("prefix", prefixQuery);
|
||||||
conf.addSparqlForAdditionalUrisInScope("individualVcard", individualVcardQuery);
|
conf.addSparqlForAdditionalUrisInScope("individualVcard", individualVcardQuery);
|
||||||
|
|
||||||
if ( conf.isUpdate() ) {
|
if ( conf.isUpdate() ) {
|
||||||
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
||||||
urisInScope.put("fullName", Arrays.asList(new String[]{fullNameUri}));
|
urisInScope.put("fullName", Arrays.asList(new String[]{fullNameUri}));
|
||||||
conf.addUrisInScope(urisInScope);
|
conf.addUrisInScope(urisInScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("firstName")
|
setName("firstName")
|
||||||
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators( list("nonempty") ));
|
setValidators( list("nonempty") ));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("middleName")
|
setName("middleName")
|
||||||
.setRangeDatatypeUri( XSD.xstring.toString()) );
|
.setRangeDatatypeUri( XSD.xstring.toString()) );
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("lastName")
|
setName("lastName")
|
||||||
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators( list("nonempty") ));
|
setValidators( list("nonempty") ));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("suffix")
|
setName("suffix")
|
||||||
.setRangeDatatypeUri( XSD.xstring.toString()) );
|
.setRangeDatatypeUri( XSD.xstring.toString()) );
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("prefix")
|
setName("prefix")
|
||||||
.setRangeDatatypeUri( XSD.xstring.toString()) );
|
.setRangeDatatypeUri( XSD.xstring.toString()) );
|
||||||
|
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
|
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* N3 assertions */
|
/* N3 assertions */
|
||||||
|
|
||||||
final static String n3ForNewName =
|
final static String n3ForNewName =
|
||||||
"?person <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
"?person <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
||||||
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?person . \n" +
|
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?person . \n" +
|
||||||
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasName> ?fullName . \n" +
|
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasName> ?fullName . \n" +
|
||||||
"?fullName a <http://www.w3.org/2006/vcard/ns#Name> . " ;
|
"?fullName a <http://www.w3.org/2006/vcard/ns#Name> . " ;
|
||||||
|
|
||||||
final static String firstNameAssertion =
|
final static String firstNameAssertion =
|
||||||
"?fullName <http://www.w3.org/2006/vcard/ns#givenName> ?firstName .";
|
"?fullName <http://www.w3.org/2006/vcard/ns#givenName> ?firstName .";
|
||||||
|
|
||||||
final static String middleNameAssertion =
|
final static String middleNameAssertion =
|
||||||
"?fullName <http://vivoweb.org/ontology/core#middleName> ?middleName .";
|
"?fullName <http://vivoweb.org/ontology/core#middleName> ?middleName .";
|
||||||
|
|
||||||
final static String lastNameAssertion =
|
final static String lastNameAssertion =
|
||||||
"?fullName <http://www.w3.org/2006/vcard/ns#familyName> ?lastName .";
|
"?fullName <http://www.w3.org/2006/vcard/ns#familyName> ?lastName .";
|
||||||
|
|
||||||
final static String suffixAssertion =
|
final static String suffixAssertion =
|
||||||
"?fullName <http://www.w3.org/2006/vcard/ns#honorificSuffix> ?suffix .";
|
"?fullName <http://www.w3.org/2006/vcard/ns#honorificSuffix> ?suffix .";
|
||||||
|
|
||||||
final static String prefixAssertion =
|
final static String prefixAssertion =
|
||||||
"?fullName <http://www.w3.org/2006/vcard/ns#honorificPrefix> ?prefix .";
|
"?fullName <http://www.w3.org/2006/vcard/ns#honorificPrefix> ?prefix .";
|
||||||
|
|
||||||
/* Queries for editing an existing entry */
|
/* Queries for editing an existing entry */
|
||||||
|
@ -119,29 +119,29 @@ public class AddFullNameToPersonGenerator extends VivoBaseGenerator implements
|
||||||
"?person <http://purl.obolibrary.org/obo/ARG_2000028> ?existingIndividualVcard . \n" +
|
"?person <http://purl.obolibrary.org/obo/ARG_2000028> ?existingIndividualVcard . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String firstNameQuery =
|
final static String firstNameQuery =
|
||||||
"SELECT ?existingFirstName WHERE {\n"+
|
"SELECT ?existingFirstName WHERE {\n"+
|
||||||
"?fullName <http://www.w3.org/2006/vcard/ns#givenName> ?existingFirstName . }";
|
"?fullName <http://www.w3.org/2006/vcard/ns#givenName> ?existingFirstName . }";
|
||||||
|
|
||||||
final static String middleNameQuery =
|
final static String middleNameQuery =
|
||||||
"SELECT ?existingMiddleName WHERE {\n"+
|
"SELECT ?existingMiddleName WHERE {\n"+
|
||||||
"?fullName <http://vivoweb.org/ontology/core#middleName> ?existingMiddleName . }";
|
"?fullName <http://vivoweb.org/ontology/core#middleName> ?existingMiddleName . }";
|
||||||
|
|
||||||
final static String lastNameQuery =
|
final static String lastNameQuery =
|
||||||
"SELECT ?existingLastName WHERE {\n"+
|
"SELECT ?existingLastName WHERE {\n"+
|
||||||
"?fullName <http://www.w3.org/2006/vcard/ns#familyName> ?existingLastName . }";
|
"?fullName <http://www.w3.org/2006/vcard/ns#familyName> ?existingLastName . }";
|
||||||
|
|
||||||
final static String suffixQuery =
|
final static String suffixQuery =
|
||||||
"SELECT ?existingSuffix WHERE {\n"+
|
"SELECT ?existingSuffix WHERE {\n"+
|
||||||
"?fullName <http://www.w3.org/2006/vcard/ns#honorificSuffix> ?existingSuffix . }";
|
"?fullName <http://www.w3.org/2006/vcard/ns#honorificSuffix> ?existingSuffix . }";
|
||||||
|
|
||||||
final static String prefixQuery =
|
final static String prefixQuery =
|
||||||
"SELECT ?existingPrefix WHERE {\n"+
|
"SELECT ?existingPrefix WHERE {\n"+
|
||||||
"?fullName <http://www.w3.org/2006/vcard/ns#honorificPrefix> ?existingPrefix . }";
|
"?fullName <http://www.w3.org/2006/vcard/ns#honorificPrefix> ?existingPrefix . }";
|
||||||
|
|
||||||
private String getFullNameUri(VitroRequest vreq) {
|
private String getFullNameUri(VitroRequest vreq) {
|
||||||
String fullNameUri = vreq.getParameter("fullNameUri");
|
String fullNameUri = vreq.getParameter("fullNameUri");
|
||||||
|
|
||||||
return fullNameUri;
|
return fullNameUri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,60 +37,60 @@ import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
|
||||||
/**
|
/**
|
||||||
* Custom form for adding a grant to an person for the predicates hasCo-PrincipalInvestigatorRole
|
* Custom form for adding a grant to an person for the predicates hasCo-PrincipalInvestigatorRole
|
||||||
and hasPrincipalInvestigatorRole.
|
and hasPrincipalInvestigatorRole.
|
||||||
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator {
|
public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator {
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(AddGrantRoleToPersonGenerator.class);
|
private Log log = LogFactory.getLog(AddGrantRoleToPersonGenerator.class);
|
||||||
private String subjectUri = null;
|
private String subjectUri = null;
|
||||||
private String predicateUri = null;
|
private String predicateUri = null;
|
||||||
private String objectUri = null;
|
private String objectUri = null;
|
||||||
private String template = "addGrantRoleToPerson.ftl";
|
private String template = "addGrantRoleToPerson.ftl";
|
||||||
|
|
||||||
//Types of options to populate drop-down for types for the "right side" of the role
|
//Types of options to populate drop-down for types for the "right side" of the role
|
||||||
public static enum RoleActivityOptionTypes {
|
public static enum RoleActivityOptionTypes {
|
||||||
VCLASSGROUP,
|
VCLASSGROUP,
|
||||||
CHILD_VCLASSES,
|
CHILD_VCLASSES,
|
||||||
HARDCODED_LITERALS
|
HARDCODED_LITERALS
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
|
||||||
EditConfigurationVTwo editConfiguration = new EditConfigurationVTwo();
|
EditConfigurationVTwo editConfiguration = new EditConfigurationVTwo();
|
||||||
|
|
||||||
//process subject, predicate, object parameters
|
//process subject, predicate, object parameters
|
||||||
this.initProcessParameters(vreq, session, editConfiguration);
|
this.initProcessParameters(vreq, session, editConfiguration);
|
||||||
|
|
||||||
//Assumes this is a simple case of subject predicate var
|
//Assumes this is a simple case of subject predicate var
|
||||||
editConfiguration.setN3Required(this.generateN3Required(vreq));
|
editConfiguration.setN3Required(this.generateN3Required(vreq));
|
||||||
|
|
||||||
//n3 optional
|
//n3 optional
|
||||||
editConfiguration.setN3Optional(this.generateN3Optional(vreq));
|
editConfiguration.setN3Optional(this.generateN3Optional(vreq));
|
||||||
|
|
||||||
//Todo: what do new resources depend on here?
|
//Todo: what do new resources depend on here?
|
||||||
//In original form, these variables start off empty
|
//In original form, these variables start off empty
|
||||||
editConfiguration.setNewResources(generateNewResources(vreq));
|
editConfiguration.setNewResources(generateNewResources(vreq));
|
||||||
//In scope
|
//In scope
|
||||||
this.setUrisAndLiteralsInScope(editConfiguration, vreq);
|
this.setUrisAndLiteralsInScope(editConfiguration, vreq);
|
||||||
|
|
||||||
//on Form
|
//on Form
|
||||||
this.setUrisAndLiteralsOnForm(editConfiguration, vreq);
|
this.setUrisAndLiteralsOnForm(editConfiguration, vreq);
|
||||||
|
|
||||||
editConfiguration.setFilesOnForm(new ArrayList<String>());
|
editConfiguration.setFilesOnForm(new ArrayList<String>());
|
||||||
|
|
||||||
//Sparql queries
|
//Sparql queries
|
||||||
this.setSparqlQueries(editConfiguration, vreq);
|
this.setSparqlQueries(editConfiguration, vreq);
|
||||||
|
|
||||||
//set fields
|
//set fields
|
||||||
setFields(editConfiguration, vreq, EditConfigurationUtils.getPredicateUri(vreq));
|
setFields(editConfiguration, vreq, EditConfigurationUtils.getPredicateUri(vreq));
|
||||||
|
|
||||||
// No need to put in session here b/c put in session within edit request dispatch controller instead
|
// No need to put in session here b/c put in session within edit request dispatch controller instead
|
||||||
//placing in session depends on having edit key which is handled in edit request dispatch controller
|
//placing in session depends on having edit key which is handled in edit request dispatch controller
|
||||||
// editConfiguration.putConfigInSession(editConfiguration, session);
|
// editConfiguration.putConfigInSession(editConfiguration, session);
|
||||||
|
|
||||||
prepareForUpdate(vreq, session, editConfiguration);
|
prepareForUpdate(vreq, session, editConfiguration);
|
||||||
|
|
||||||
//Form title and submit label now moved to edit configuration template
|
//Form title and submit label now moved to edit configuration template
|
||||||
//TODO: check if edit configuration template correct place to set those or whether
|
//TODO: check if edit configuration template correct place to set those or whether
|
||||||
//additional methods here should be used and reference instead, e.g. edit configuration template could call
|
//additional methods here should be used and reference instead, e.g. edit configuration template could call
|
||||||
|
@ -99,7 +99,7 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
setTemplate(editConfiguration, vreq);
|
setTemplate(editConfiguration, vreq);
|
||||||
//Set edit key
|
//Set edit key
|
||||||
setEditKey(editConfiguration, vreq);
|
setEditKey(editConfiguration, vreq);
|
||||||
|
|
||||||
//Add validators
|
//Add validators
|
||||||
editConfiguration.addValidator(new DateTimeIntervalValidationVTwo("startField","endField") );
|
editConfiguration.addValidator(new DateTimeIntervalValidationVTwo("startField","endField") );
|
||||||
editConfiguration.addValidator(new AntiXssValidation());
|
editConfiguration.addValidator(new AntiXssValidation());
|
||||||
|
@ -109,18 +109,18 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
addFormSpecificData(editConfiguration, vreq);
|
addFormSpecificData(editConfiguration, vreq);
|
||||||
return editConfiguration;
|
return editConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void setEditKey(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setEditKey(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
String editKey = EditConfigurationUtils.getEditKey(vreq);
|
String editKey = EditConfigurationUtils.getEditKey(vreq);
|
||||||
editConfiguration.setEditKey(editKey);
|
editConfiguration.setEditKey(editKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setTemplate(EditConfigurationVTwo editConfiguration,
|
protected void setTemplate(EditConfigurationVTwo editConfiguration,
|
||||||
VitroRequest vreq) {
|
VitroRequest vreq) {
|
||||||
editConfiguration.setTemplate(template);
|
editConfiguration.setTemplate(template);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Initialize setup: process parameters
|
//Initialize setup: process parameters
|
||||||
|
@ -131,11 +131,11 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
|
|
||||||
subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
|
subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
|
||||||
predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||||
|
|
||||||
editConfiguration.setFormUrl(formUrl);
|
editConfiguration.setFormUrl(formUrl);
|
||||||
|
|
||||||
editConfiguration.setUrlPatternToReturnTo("/individual");
|
editConfiguration.setUrlPatternToReturnTo("/individual");
|
||||||
|
|
||||||
editConfiguration.setVarNameForSubject("person");
|
editConfiguration.setVarNameForSubject("person");
|
||||||
editConfiguration.setSubjectUri(subjectUri);
|
editConfiguration.setSubjectUri(subjectUri);
|
||||||
editConfiguration.setEntityToReturnTo(subjectUri);
|
editConfiguration.setEntityToReturnTo(subjectUri);
|
||||||
|
@ -143,28 +143,28 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
editConfiguration.setPredicateUri(predicateUri);
|
editConfiguration.setPredicateUri(predicateUri);
|
||||||
//by definition, this is an object property
|
//by definition, this is an object property
|
||||||
objectUri = EditConfigurationUtils.getObjectUri(vreq);
|
objectUri = EditConfigurationUtils.getObjectUri(vreq);
|
||||||
|
|
||||||
this.processObjectPropForm(vreq, editConfiguration);
|
this.processObjectPropForm(vreq, editConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processObjectPropForm(VitroRequest vreq, EditConfigurationVTwo editConfiguration) {
|
private void processObjectPropForm(VitroRequest vreq, EditConfigurationVTwo editConfiguration) {
|
||||||
editConfiguration.setVarNameForObject("role");
|
editConfiguration.setVarNameForObject("role");
|
||||||
editConfiguration.setObject(objectUri);
|
editConfiguration.setObject(objectUri);
|
||||||
//this needs to be set for the editing to be triggered properly, otherwise the 'prepare' method
|
//this needs to be set for the editing to be triggered properly, otherwise the 'prepare' method
|
||||||
//pretends this is a data property editing statement and throws an error
|
//pretends this is a data property editing statement and throws an error
|
||||||
//TODO: Check if null in case no object uri exists but this is still an object property
|
//TODO: Check if null in case no object uri exists but this is still an object property
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* N3 Required and Optional Generators as well as supporting methods
|
* N3 Required and Optional Generators as well as supporting methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private String getPrefixesString() {
|
private String getPrefixesString() {
|
||||||
//TODO: Include dynamic way of including this
|
//TODO: Include dynamic way of including this
|
||||||
return "@prefix core: <http://vivoweb.org/ontology/core#> .";
|
return "@prefix core: <http://vivoweb.org/ontology/core#> .";
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Check if single string or multiple strings - check rdfslabel form etc. for prefix
|
//TODO: Check if single string or multiple strings - check rdfslabel form etc. for prefix
|
||||||
//processing
|
//processing
|
||||||
private List<String> generateN3Required(VitroRequest vreq) {
|
private List<String> generateN3Required(VitroRequest vreq) {
|
||||||
|
@ -173,8 +173,8 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
n3ForEdit.add(editString);
|
n3ForEdit.add(editString);
|
||||||
return n3ForEdit;
|
return n3ForEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<String> generateN3Optional(VitroRequest vreq) {
|
private List<String> generateN3Optional(VitroRequest vreq) {
|
||||||
List<String> n3Optional = new ArrayList<String>();
|
List<String> n3Optional = new ArrayList<String>();
|
||||||
//n3 for new grant
|
//n3 for new grant
|
||||||
|
@ -187,61 +187,61 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
n3Optional.addAll(getN3ForStart());
|
n3Optional.addAll(getN3ForStart());
|
||||||
//N3 For End
|
//N3 For End
|
||||||
n3Optional.addAll(getN3ForEnd());
|
n3Optional.addAll(getN3ForEnd());
|
||||||
return n3Optional;
|
return n3Optional;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getN3ForGrantRole(VitroRequest vreq) {
|
public String getN3ForGrantRole(VitroRequest vreq) {
|
||||||
String editString = getPrefixesString();
|
String editString = getPrefixesString();
|
||||||
editString += "?person ?rolePredicate ?role .";
|
editString += "?person ?rolePredicate ?role .";
|
||||||
editString += "?role a <" + getRoleType(vreq) + "> .";
|
editString += "?role a <" + getRoleType(vreq) + "> .";
|
||||||
return editString;
|
return editString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getN3ForNewGrant(VitroRequest vreq) {
|
public String getN3ForNewGrant(VitroRequest vreq) {
|
||||||
String editString = getPrefixesString();
|
String editString = getPrefixesString();
|
||||||
editString += "?role <" + getRoleToGrantPredicate(vreq) + "> ?grant .";
|
editString += "?role <" + getRoleToGrantPredicate(vreq) + "> ?grant .";
|
||||||
editString += "?grant a core:Grant . ";
|
editString += "?grant a core:Grant . ";
|
||||||
editString += "?person core:relatedBy ?grant . ";
|
editString += "?person core:relatedBy ?grant . ";
|
||||||
editString += "?grant core:relates ?person . ";
|
editString += "?grant core:relates ?person . ";
|
||||||
editString += "?grant <" + getGrantToRolePredicate(vreq) + "> ?role .";
|
editString += "?grant <" + getGrantToRolePredicate(vreq) + "> ?role .";
|
||||||
editString += "?grant <" + RDFS.label.getURI() + "> ?grantLabel .";
|
editString += "?grant <" + RDFS.label.getURI() + "> ?grantLabel .";
|
||||||
return editString;
|
return editString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getN3ForExistingGrant(VitroRequest vreq) {
|
public String getN3ForExistingGrant(VitroRequest vreq) {
|
||||||
String editString = getPrefixesString();
|
String editString = getPrefixesString();
|
||||||
editString += "?person core:relatedBy ?existingGrant . ";
|
editString += "?person core:relatedBy ?existingGrant . ";
|
||||||
editString += "?existingGrant core:relates ?person . ";
|
editString += "?existingGrant core:relates ?person . ";
|
||||||
editString += "?role <" + getRoleToGrantPredicate(vreq) + "> ?existingGrant . ";
|
editString += "?role <" + getRoleToGrantPredicate(vreq) + "> ?existingGrant . ";
|
||||||
editString += "?existingGrant <" + getGrantToRolePredicate(vreq) + "> ?role .";
|
editString += "?existingGrant <" + getGrantToRolePredicate(vreq) + "> ?role .";
|
||||||
return editString;
|
return editString;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Method b/c used in two locations, n3 optional and n3 assertions
|
//Method b/c used in two locations, n3 optional and n3 assertions
|
||||||
private List<String> getN3ForStart() {
|
private List<String> getN3ForStart() {
|
||||||
List<String> n3ForStart = new ArrayList<String>();
|
List<String> n3ForStart = new ArrayList<String>();
|
||||||
n3ForStart.add("?role <" + getRoleToIntervalURI() + "> ?intervalNode ." +
|
n3ForStart.add("?role <" + getRoleToIntervalURI() + "> ?intervalNode ." +
|
||||||
"?intervalNode <" + RDF.type.getURI() + "> <" + getIntervalTypeURI() + "> ." +
|
"?intervalNode <" + RDF.type.getURI() + "> <" + getIntervalTypeURI() + "> ." +
|
||||||
"?intervalNode <" + getIntervalToStartURI() + "> ?startNode ." +
|
"?intervalNode <" + getIntervalToStartURI() + "> ?startNode ." +
|
||||||
"?startNode <" + RDF.type.getURI() + "> <" + getDateTimeValueTypeURI() + "> ." +
|
"?startNode <" + RDF.type.getURI() + "> <" + getDateTimeValueTypeURI() + "> ." +
|
||||||
"?startNode <" + getDateTimeValueURI() + "> ?startField-value ." +
|
"?startNode <" + getDateTimeValueURI() + "> ?startField-value ." +
|
||||||
"?startNode <" + getDateTimePrecisionURI() + "> ?startField-precision .");
|
"?startNode <" + getDateTimePrecisionURI() + "> ?startField-precision .");
|
||||||
return n3ForStart;
|
return n3ForStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getN3ForEnd() {
|
private List<String> getN3ForEnd() {
|
||||||
List<String> n3ForEnd = new ArrayList<String>();
|
List<String> n3ForEnd = new ArrayList<String>();
|
||||||
n3ForEnd.add("?role <" + getRoleToIntervalURI() + "> ?intervalNode . " +
|
n3ForEnd.add("?role <" + getRoleToIntervalURI() + "> ?intervalNode . " +
|
||||||
"?intervalNode <" + RDF.type.getURI() + "> <" + getIntervalTypeURI() + "> ." +
|
"?intervalNode <" + RDF.type.getURI() + "> <" + getIntervalTypeURI() + "> ." +
|
||||||
"?intervalNode <" + getIntervalToEndURI() + "> ?endNode ." +
|
"?intervalNode <" + getIntervalToEndURI() + "> ?endNode ." +
|
||||||
"?endNode <" + RDF.type.getURI() + "> <" + getDateTimeValueTypeURI() + "> ." +
|
"?endNode <" + RDF.type.getURI() + "> <" + getDateTimeValueTypeURI() + "> ." +
|
||||||
"?endNode <" + getDateTimeValueURI() + "> ?endField-value ." +
|
"?endNode <" + getDateTimeValueURI() + "> ?endField-value ." +
|
||||||
"?endNode <" + getDateTimePrecisionURI() + "> ?endField-precision .");
|
"?endNode <" + getDateTimePrecisionURI() + "> ?endField-precision .");
|
||||||
return n3ForEnd;
|
return n3ForEnd;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get new resources
|
* Get new resources
|
||||||
*/
|
*/
|
||||||
|
@ -256,22 +256,22 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
newResources.put("endNode", defaultNamespace + "individual");
|
newResources.put("endNode", defaultNamespace + "individual");
|
||||||
return newResources;
|
return newResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set URIS and Literals In Scope and on form and supporting methods
|
* Set URIS and Literals In Scope and on form and supporting methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
||||||
//note that at this point the subject, predicate, and object var parameters have already been processed
|
//note that at this point the subject, predicate, and object var parameters have already been processed
|
||||||
//these two were always set when instantiating an edit configuration object from json,
|
//these two were always set when instantiating an edit configuration object from json,
|
||||||
//although the json itself did not specify subject/predicate as part of uris in scope
|
//although the json itself did not specify subject/predicate as part of uris in scope
|
||||||
urisInScope.put(editConfiguration.getVarNameForSubject(),
|
urisInScope.put(editConfiguration.getVarNameForSubject(),
|
||||||
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
|
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
|
||||||
urisInScope.put(editConfiguration.getVarNameForPredicate(),
|
urisInScope.put(editConfiguration.getVarNameForPredicate(),
|
||||||
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
|
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
|
||||||
//Setting role type
|
//Setting role type
|
||||||
urisInScope.put("roleType",
|
urisInScope.put("roleType",
|
||||||
Arrays.asList(new String[]{getRoleType(vreq)}));
|
Arrays.asList(new String[]{getRoleType(vreq)}));
|
||||||
//Setting inverse role predicate
|
//Setting inverse role predicate
|
||||||
urisInScope.put("inverseRolePredicate", getInversePredicate(vreq));
|
urisInScope.put("inverseRolePredicate", getInversePredicate(vreq));
|
||||||
|
@ -281,7 +281,7 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
//with existing values for variables
|
//with existing values for variables
|
||||||
editConfiguration.setLiteralsInScope(new HashMap<String, List<Literal>>());
|
editConfiguration.setLiteralsInScope(new HashMap<String, List<Literal>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getInversePredicate(VitroRequest vreq) {
|
private List<String> getInversePredicate(VitroRequest vreq) {
|
||||||
List<String> inversePredicateArray = new ArrayList<String>();
|
List<String> inversePredicateArray = new ArrayList<String>();
|
||||||
ObjectProperty op = EditConfigurationUtils.getObjectProperty(vreq);
|
ObjectProperty op = EditConfigurationUtils.getObjectProperty(vreq);
|
||||||
|
@ -292,8 +292,8 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
//n3 should look as follows
|
//n3 should look as follows
|
||||||
//?subject ?predicate ?objectVar
|
//?subject ?predicate ?objectVar
|
||||||
|
|
||||||
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
List<String> urisOnForm = new ArrayList<String>();
|
List<String> urisOnForm = new ArrayList<String>();
|
||||||
List<String> literalsOnForm = new ArrayList<String>();
|
List<String> literalsOnForm = new ArrayList<String>();
|
||||||
|
@ -306,25 +306,25 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
literalsOnForm.add("grantLabelDisplay");
|
literalsOnForm.add("grantLabelDisplay");
|
||||||
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set SPARQL Queries and supporting methods
|
* Set SPARQL Queries and supporting methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
private void setSparqlQueries(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setSparqlQueries(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
//Sparql queries defining retrieval of literals etc.
|
//Sparql queries defining retrieval of literals etc.
|
||||||
editConfiguration.setSparqlForAdditionalLiteralsInScope(new HashMap<String, String>());
|
editConfiguration.setSparqlForAdditionalLiteralsInScope(new HashMap<String, String>());
|
||||||
|
|
||||||
Map<String, String> urisInScope = new HashMap<String, String>();
|
Map<String, String> urisInScope = new HashMap<String, String>();
|
||||||
editConfiguration.setSparqlForAdditionalUrisInScope(urisInScope);
|
editConfiguration.setSparqlForAdditionalUrisInScope(urisInScope);
|
||||||
|
|
||||||
editConfiguration.setSparqlForExistingLiterals(generateSparqlForExistingLiterals(vreq));
|
editConfiguration.setSparqlForExistingLiterals(generateSparqlForExistingLiterals(vreq));
|
||||||
editConfiguration.setSparqlForExistingUris(generateSparqlForExistingUris(vreq));
|
editConfiguration.setSparqlForExistingUris(generateSparqlForExistingUris(vreq));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Get page uri for object
|
//Get page uri for object
|
||||||
private HashMap<String, String> generateSparqlForExistingUris(VitroRequest vreq) {
|
private HashMap<String, String> generateSparqlForExistingUris(VitroRequest vreq) {
|
||||||
HashMap<String, String> map = new HashMap<String, String>();
|
HashMap<String, String> map = new HashMap<String, String>();
|
||||||
|
@ -337,7 +337,7 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
map.put("endField-precision", getEndPrecisionQuery(vreq));
|
map.put("endField-precision", getEndPrecisionQuery(vreq));
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String getEndPrecisionQuery(VitroRequest vreq) {
|
private String getEndPrecisionQuery(VitroRequest vreq) {
|
||||||
|
@ -345,7 +345,7 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
"?role <" + getRoleToIntervalURI() + "> ?intervalNode ." +
|
"?role <" + getRoleToIntervalURI() + "> ?intervalNode ." +
|
||||||
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> ." +
|
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> ." +
|
||||||
"?intervalNode <" + getIntervalToEndURI() + "> ?endNode ." +
|
"?intervalNode <" + getIntervalToEndURI() + "> ?endNode ." +
|
||||||
"?endNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> . " +
|
"?endNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> . " +
|
||||||
"?endNode <" + getDateTimePrecisionURI() + "> ?existingEndPrecision . }";
|
"?endNode <" + getDateTimePrecisionURI() + "> ?existingEndPrecision . }";
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
"?role <" + getRoleToIntervalURI() + "> ?intervalNode ." +
|
"?role <" + getRoleToIntervalURI() + "> ?intervalNode ." +
|
||||||
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> ." +
|
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> ." +
|
||||||
"?intervalNode <" + getIntervalToStartURI() + "> ?startNode ." +
|
"?intervalNode <" + getIntervalToStartURI() + "> ?startNode ." +
|
||||||
"?startNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> . " +
|
"?startNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> . " +
|
||||||
"?startNode <" + getDateTimePrecisionURI() + "> ?existingStartPrecision . }";
|
"?startNode <" + getDateTimePrecisionURI() + "> ?existingStartPrecision . }";
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
@ -365,27 +365,27 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
"?role <" + getRoleToIntervalURI() + "> ?intervalNode ."+
|
"?role <" + getRoleToIntervalURI() + "> ?intervalNode ."+
|
||||||
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> ."+
|
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> ."+
|
||||||
" ?intervalNode <" + getIntervalToEndURI() + "> ?existingEndNode . "+
|
" ?intervalNode <" + getIntervalToEndURI() + "> ?existingEndNode . "+
|
||||||
"?existingEndNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> .}";
|
"?existingEndNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> .}";
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getStartNodeQuery(VitroRequest vreq) {
|
private String getStartNodeQuery(VitroRequest vreq) {
|
||||||
String query = "SELECT ?existingStartNode WHERE {"+
|
String query = "SELECT ?existingStartNode WHERE {"+
|
||||||
"?role <" + getRoleToIntervalURI() + "> ?intervalNode ."+
|
"?role <" + getRoleToIntervalURI() + "> ?intervalNode ."+
|
||||||
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> ."+
|
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> ."+
|
||||||
"?intervalNode <" + getIntervalToStartURI() + "> ?existingStartNode . "+
|
"?intervalNode <" + getIntervalToStartURI() + "> ?existingStartNode . "+
|
||||||
"?existingStartNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> .}";
|
"?existingStartNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> .}";
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getIntervalNodeQuery(VitroRequest vreq) {
|
private String getIntervalNodeQuery(VitroRequest vreq) {
|
||||||
String query = "SELECT ?existingIntervalNode WHERE { " +
|
String query = "SELECT ?existingIntervalNode WHERE { " +
|
||||||
"?role <" + getRoleToIntervalURI() + "> ?existingIntervalNode . " +
|
"?role <" + getRoleToIntervalURI() + "> ?existingIntervalNode . " +
|
||||||
" ?existingIntervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> . }";
|
" ?existingIntervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> . }";
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private HashMap<String, String> generateSparqlForExistingLiterals(VitroRequest vreq) {
|
private HashMap<String, String> generateSparqlForExistingLiterals(VitroRequest vreq) {
|
||||||
HashMap<String, String> map = new HashMap<String, String>();
|
HashMap<String, String> map = new HashMap<String, String>();
|
||||||
|
@ -395,55 +395,55 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
map.put("endField-value", getExistingEndDateQuery(vreq));
|
map.put("endField-value", getExistingEndDateQuery(vreq));
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getGrantLabelQuery(VitroRequest vreq) {
|
private String getGrantLabelQuery(VitroRequest vreq) {
|
||||||
String query = "PREFIX core: <" + getVivoCoreNamespace() + ">" +
|
String query = "PREFIX core: <" + getVivoCoreNamespace() + ">" +
|
||||||
"PREFIX rdfs: <" + RDFS.getURI() + "> \n";
|
"PREFIX rdfs: <" + RDFS.getURI() + "> \n";
|
||||||
|
|
||||||
String roleToGrantPredicate = getRoleToGrantPredicate(vreq);
|
String roleToGrantPredicate = getRoleToGrantPredicate(vreq);
|
||||||
query += "SELECT ?existingGrantLabel WHERE { \n" +
|
query += "SELECT ?existingGrantLabel WHERE { \n" +
|
||||||
"?role <" + roleToGrantPredicate + "> ?existingGrant . \n" +
|
"?role <" + roleToGrantPredicate + "> ?existingGrant . \n" +
|
||||||
"?existingGrant rdfs:label ?existingGrantLabel . }";
|
"?existingGrant rdfs:label ?existingGrantLabel . }";
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getExistingGrantQuery(VitroRequest vreq) {
|
private String getExistingGrantQuery(VitroRequest vreq) {
|
||||||
String query = "PREFIX core: <" + getVivoCoreNamespace() + ">" +
|
String query = "PREFIX core: <" + getVivoCoreNamespace() + ">" +
|
||||||
"PREFIX rdfs: <" + RDFS.getURI() + "> \n";
|
"PREFIX rdfs: <" + RDFS.getURI() + "> \n";
|
||||||
|
|
||||||
String roleToGrantPredicate = getRoleToGrantPredicate(vreq);
|
String roleToGrantPredicate = getRoleToGrantPredicate(vreq);
|
||||||
query += "SELECT ?existingGrant WHERE { \n" +
|
query += "SELECT ?existingGrant WHERE { \n" +
|
||||||
"?role <" + roleToGrantPredicate + "> ?existingGrant . }";
|
"?role <" + roleToGrantPredicate + "> ?existingGrant . }";
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getExistingEndDateQuery(VitroRequest vreq) {
|
private String getExistingEndDateQuery(VitroRequest vreq) {
|
||||||
String query = " SELECT ?existingEndDate WHERE {\n" +
|
String query = " SELECT ?existingEndDate WHERE {\n" +
|
||||||
"?role <" + getRoleToIntervalURI() + "> ?intervalNode .\n" +
|
"?role <" + getRoleToIntervalURI() + "> ?intervalNode .\n" +
|
||||||
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> .\n" +
|
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> .\n" +
|
||||||
"?intervalNode <" + getIntervalToEndURI() + "> ?endNode .\n" +
|
"?intervalNode <" + getIntervalToEndURI() + "> ?endNode .\n" +
|
||||||
"?endNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> .\n" +
|
"?endNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> .\n" +
|
||||||
"?endNode <" + getDateTimeValueURI() + "> ?existingEndDate . }";
|
"?endNode <" + getDateTimeValueURI() + "> ?existingEndDate . }";
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getExistingStartDateQuery(VitroRequest vreq) {
|
private String getExistingStartDateQuery(VitroRequest vreq) {
|
||||||
String query = "SELECT ?existingDateStart WHERE {\n" +
|
String query = "SELECT ?existingDateStart WHERE {\n" +
|
||||||
"?role <" + getRoleToIntervalURI() + "> ?intervalNode .\n" +
|
"?role <" + getRoleToIntervalURI() + "> ?intervalNode .\n" +
|
||||||
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> .\n" +
|
"?intervalNode <" + VitroVocabulary.RDF_TYPE + "> <" + getIntervalTypeURI() + "> .\n" +
|
||||||
"?intervalNode <" + getIntervalToStartURI() + "> ?startNode .\n" +
|
"?intervalNode <" + getIntervalToStartURI() + "> ?startNode .\n" +
|
||||||
"?startNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> .\n" +
|
"?startNode <" + VitroVocabulary.RDF_TYPE + "> <" + getDateTimeValueTypeURI() + "> .\n" +
|
||||||
"?startNode <" + getDateTimeValueURI() + "> ?existingDateStart . }";
|
"?startNode <" + getDateTimeValueURI() + "> ?existingDateStart . }";
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Set Fields and supporting methods
|
* Set Fields and supporting methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
|
private void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
|
||||||
Map<String, FieldVTwo> fields = new HashMap<String, FieldVTwo>();
|
Map<String, FieldVTwo> fields = new HashMap<String, FieldVTwo>();
|
||||||
//Multiple fields
|
//Multiple fields
|
||||||
|
@ -455,20 +455,20 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
getEndField(editConfiguration, vreq, fields);
|
getEndField(editConfiguration, vreq, fields);
|
||||||
editConfiguration.setFields(fields);
|
editConfiguration.setFields(fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getGrantField(EditConfigurationVTwo editConfiguration,
|
private void getGrantField(EditConfigurationVTwo editConfiguration,
|
||||||
VitroRequest vreq, Map<String, FieldVTwo> fields) {
|
VitroRequest vreq, Map<String, FieldVTwo> fields) {
|
||||||
String fieldName = "grant";
|
String fieldName = "grant";
|
||||||
|
|
||||||
FieldVTwo field = new FieldVTwo();
|
FieldVTwo field = new FieldVTwo();
|
||||||
field.setName(fieldName);
|
field.setName(fieldName);
|
||||||
//queryForExisting is not being used anywhere in Field
|
//queryForExisting is not being used anywhere in Field
|
||||||
|
|
||||||
List<String> validators = new ArrayList<String>();
|
List<String> validators = new ArrayList<String>();
|
||||||
field.setValidators(validators);
|
field.setValidators(validators);
|
||||||
|
|
||||||
fields.put(field.getName(), field);
|
fields.put(field.getName(), field);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getGrantLabelField(EditConfigurationVTwo editConfiguration,
|
private void getGrantLabelField(EditConfigurationVTwo editConfiguration,
|
||||||
|
@ -476,45 +476,45 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
String fieldName = "grantLabel";
|
String fieldName = "grantLabel";
|
||||||
//get range data type uri and range language
|
//get range data type uri and range language
|
||||||
String stringDatatypeUri = XSD.xstring.toString();
|
String stringDatatypeUri = XSD.xstring.toString();
|
||||||
|
|
||||||
FieldVTwo field = new FieldVTwo();
|
FieldVTwo field = new FieldVTwo();
|
||||||
field.setName(fieldName);
|
field.setName(fieldName);
|
||||||
//queryForExisting is not being used anywhere in Field
|
//queryForExisting is not being used anywhere in Field
|
||||||
|
|
||||||
//Not really interested in validators here
|
//Not really interested in validators here
|
||||||
List<String> validators = new ArrayList<String>();
|
List<String> validators = new ArrayList<String>();
|
||||||
validators.add("datatype:" + stringDatatypeUri);
|
validators.add("datatype:" + stringDatatypeUri);
|
||||||
field.setValidators(validators);
|
field.setValidators(validators);
|
||||||
|
|
||||||
|
fields.put(field.getName(), field);
|
||||||
|
|
||||||
fields.put(field.getName(), field);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getGrantLabelDisplayField(EditConfigurationVTwo editConfiguration,
|
private void getGrantLabelDisplayField(EditConfigurationVTwo editConfiguration,
|
||||||
VitroRequest vreq, Map<String, FieldVTwo> fields) {
|
VitroRequest vreq, Map<String, FieldVTwo> fields) {
|
||||||
|
|
||||||
FieldVTwo field = new FieldVTwo();
|
|
||||||
|
|
||||||
String fieldName = "grantLabelDisplay";
|
|
||||||
field.setName(fieldName);
|
|
||||||
|
|
||||||
String stringDatatypeUri = XSD.xstring.toString();
|
|
||||||
field.setRangeDatatypeUri(null);
|
|
||||||
|
|
||||||
fields.put(field.getName(), field);
|
FieldVTwo field = new FieldVTwo();
|
||||||
|
|
||||||
|
String fieldName = "grantLabelDisplay";
|
||||||
|
field.setName(fieldName);
|
||||||
|
|
||||||
|
String stringDatatypeUri = XSD.xstring.toString();
|
||||||
|
field.setRangeDatatypeUri(null);
|
||||||
|
|
||||||
|
fields.put(field.getName(), field);
|
||||||
|
|
||||||
}
|
}
|
||||||
//Need if returning from an invalid submission
|
//Need if returning from an invalid submission
|
||||||
private void getExistingGrantField(
|
private void getExistingGrantField(
|
||||||
EditConfigurationVTwo editConfiguration, VitroRequest vreq,
|
EditConfigurationVTwo editConfiguration, VitroRequest vreq,
|
||||||
Map<String, FieldVTwo> fields) {
|
Map<String, FieldVTwo> fields) {
|
||||||
String fieldName = "existingGrant";
|
String fieldName = "existingGrant";
|
||||||
|
|
||||||
FieldVTwo field = new FieldVTwo();
|
FieldVTwo field = new FieldVTwo();
|
||||||
field.setName(fieldName);
|
field.setName(fieldName);
|
||||||
//queryForExisting is not being used anywhere in Field
|
//queryForExisting is not being used anywhere in Field
|
||||||
|
|
||||||
fields.put(field.getName(), field);
|
fields.put(field.getName(), field);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getStartField(EditConfigurationVTwo editConfiguration,
|
private void getStartField(EditConfigurationVTwo editConfiguration,
|
||||||
|
@ -522,16 +522,16 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
String fieldName = "startField";
|
String fieldName = "startField";
|
||||||
|
|
||||||
FieldVTwo field = new FieldVTwo();
|
FieldVTwo field = new FieldVTwo();
|
||||||
field.setName(fieldName);
|
field.setName(fieldName);
|
||||||
|
|
||||||
//This logic was originally after edit configuration object created from json in original jsp
|
//This logic was originally after edit configuration object created from json in original jsp
|
||||||
field.setEditElement(
|
field.setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(field,
|
new DateTimeWithPrecisionVTwo(field,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri()));
|
VitroVocabulary.Precision.NONE.uri()));
|
||||||
|
|
||||||
fields.put(field.getName(), field);
|
fields.put(field.getName(), field);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getEndField(EditConfigurationVTwo editConfiguration,
|
private void getEndField(EditConfigurationVTwo editConfiguration,
|
||||||
|
@ -539,19 +539,19 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
String fieldName = "endField";
|
String fieldName = "endField";
|
||||||
|
|
||||||
FieldVTwo field = new FieldVTwo();
|
FieldVTwo field = new FieldVTwo();
|
||||||
field.setName(fieldName);
|
field.setName(fieldName);
|
||||||
|
|
||||||
List<String> validators = new ArrayList<String>();
|
List<String> validators = new ArrayList<String>();
|
||||||
field.setValidators(validators);
|
field.setValidators(validators);
|
||||||
|
|
||||||
//Set edit element
|
//Set edit element
|
||||||
field.setEditElement(
|
field.setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(field,
|
new DateTimeWithPrecisionVTwo(field,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri()));
|
VitroVocabulary.Precision.NONE.uri()));
|
||||||
|
|
||||||
fields.put(field.getName(), field);
|
fields.put(field.getName(), field);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -560,9 +560,9 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
* @param session - the HTTP session
|
* @param session - the HTTP session
|
||||||
* @param editConfiguration - Edit configuration
|
* @param editConfiguration - Edit configuration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void prepareForUpdate(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
private void prepareForUpdate(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
||||||
//Here, retrieve model from
|
//Here, retrieve model from
|
||||||
OntModel model = ModelAccess.on(session.getServletContext()).getOntModel();
|
OntModel model = ModelAccess.on(session.getServletContext()).getOntModel();
|
||||||
//Object property by definition
|
//Object property by definition
|
||||||
String objectUri = EditConfigurationUtils.getObjectUri(vreq);
|
String objectUri = EditConfigurationUtils.getObjectUri(vreq);
|
||||||
|
@ -574,9 +574,9 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
editConfiguration.prepareForNonUpdate( model );
|
editConfiguration.prepareForNonUpdate( model );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Methods for checking edit mode **
|
/**Methods for checking edit mode **
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public EditMode getEditMode(VitroRequest vreq) {
|
public EditMode getEditMode(VitroRequest vreq) {
|
||||||
List<String> roleToGrantPredicates = getPossibleRoleToGrantPredicates();
|
List<String> roleToGrantPredicates = getPossibleRoleToGrantPredicates();
|
||||||
|
@ -586,15 +586,15 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
private boolean isAddMode(VitroRequest vreq) {
|
private boolean isAddMode(VitroRequest vreq) {
|
||||||
return EditModeUtils.isAddMode(getEditMode(vreq));
|
return EditModeUtils.isAddMode(getEditMode(vreq));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isEditMode(VitroRequest vreq) {
|
private boolean isEditMode(VitroRequest vreq) {
|
||||||
return EditModeUtils.isEditMode(getEditMode(vreq));
|
return EditModeUtils.isEditMode(getEditMode(vreq));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isRepairMode(VitroRequest vreq) {
|
private boolean isRepairMode(VitroRequest vreq) {
|
||||||
return EditModeUtils.isRepairMode(getEditMode(vreq));
|
return EditModeUtils.isRepairMode(getEditMode(vreq));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Methods that are REQUIRED to be implemented in subclasses
|
* Methods that are REQUIRED to be implemented in subclasses
|
||||||
**/
|
**/
|
||||||
|
@ -606,12 +606,12 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
}
|
}
|
||||||
else if(rangeUri.equals(getCoPrincipalInvestigatorURI())) {
|
else if(rangeUri.equals(getCoPrincipalInvestigatorURI())) {
|
||||||
return getVivoOntologyCoreNamespace() + "CoPrincipalInvestigatorRole";
|
return getVivoOntologyCoreNamespace() + "CoPrincipalInvestigatorRole";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return getVivoOntologyCoreNamespace() + "InvestigatorRole";
|
return getVivoOntologyCoreNamespace() + "InvestigatorRole";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getCoPrincipalInvestigatorURI() {
|
private Object getCoPrincipalInvestigatorURI() {
|
||||||
return getVivoOntologyCoreNamespace() + "CoPrincipalInvestigatorRole";
|
return getVivoOntologyCoreNamespace() + "CoPrincipalInvestigatorRole";
|
||||||
}
|
}
|
||||||
|
@ -631,27 +631,27 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
* Methods with default values that may be overwritten when required by a subclass
|
* Methods with default values that may be overwritten when required by a subclass
|
||||||
* Both Default value and method that can be overwritten are included below
|
* Both Default value and method that can be overwritten are included below
|
||||||
**/
|
**/
|
||||||
|
|
||||||
public boolean isShowRoleLabelField(VitroRequest vreq) {
|
public boolean isShowRoleLabelField(VitroRequest vreq) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//This has a default value, but note that even that will not be used
|
//This has a default value, but note that even that will not be used
|
||||||
//in the update with realized in or contributes to
|
//in the update with realized in or contributes to
|
||||||
//Overridden when need be in subclassed generator
|
//Overridden when need be in subclassed generator
|
||||||
//Also note that for now we're going to actually going to return a
|
//Also note that for now we're going to actually going to return a
|
||||||
//placeholder value by default
|
//placeholder value by default
|
||||||
public String getRoleToGrantPredicate(VitroRequest vreq) {
|
public String getRoleToGrantPredicate(VitroRequest vreq) {
|
||||||
ObjectProperty predicate = ModelUtils.getPropertyForRoleInClass(getGrantType(), vreq.getWebappDaoFactory());
|
ObjectProperty predicate = ModelUtils.getPropertyForRoleInClass(getGrantType(), vreq.getWebappDaoFactory());
|
||||||
return predicate.getURI();
|
return predicate.getURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGrantToRolePredicate(VitroRequest vreq) {
|
public String getGrantToRolePredicate(VitroRequest vreq) {
|
||||||
ObjectProperty predicate = ModelUtils.getPropertyForRoleInClass(getGrantType(), vreq.getWebappDaoFactory());
|
ObjectProperty predicate = ModelUtils.getPropertyForRoleInClass(getGrantType(), vreq.getWebappDaoFactory());
|
||||||
return predicate.getURIInverse();
|
return predicate.getURIInverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGrantType() {
|
public String getGrantType() {
|
||||||
return "http://vivoweb.org/ontology/core#Grant";
|
return "http://vivoweb.org/ontology/core#Grant";
|
||||||
}
|
}
|
||||||
|
@ -662,65 +662,65 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
public String getDefaultgrantToRolePredicate() {
|
public String getDefaultgrantToRolePredicate() {
|
||||||
return "http://vivoweb.org/ontology/core#relates";
|
return "http://vivoweb.org/ontology/core#relates";
|
||||||
}
|
}
|
||||||
|
|
||||||
//roleToGrantPredicate
|
//roleToGrantPredicate
|
||||||
public String getDefaultroleToGrantPredicate() {
|
public String getDefaultroleToGrantPredicate() {
|
||||||
return "http://purl.obolibrary.org/obo/BFO_0000054";
|
return "http://purl.obolibrary.org/obo/BFO_0000054";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getPossibleRoleToGrantPredicates() {
|
public List<String> getPossibleRoleToGrantPredicates() {
|
||||||
return ModelUtils.getPossiblePropertiesForRole();
|
return ModelUtils.getPossiblePropertiesForRole();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getPossibleGrantToRolePredicates() {
|
public List<String> getPossibleGrantToRolePredicates() {
|
||||||
return ModelUtils.getPossibleInversePropertiesForRole();
|
return ModelUtils.getPossibleInversePropertiesForRole();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Methods to return URIS for various predicates
|
* Methods to return URIS for various predicates
|
||||||
**/
|
**/
|
||||||
public String getVivoCoreNamespace() {
|
public String getVivoCoreNamespace() {
|
||||||
return "http://vivoweb.org/ontology/core#";
|
return "http://vivoweb.org/ontology/core#";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRoleToIntervalURI() {
|
public String getRoleToIntervalURI() {
|
||||||
return getVivoCoreNamespace() + "dateTimeInterval";
|
return getVivoCoreNamespace() + "dateTimeInterval";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIntervalTypeURI() {
|
public String getIntervalTypeURI() {
|
||||||
return getVivoCoreNamespace() + "DateTimeInterval";
|
return getVivoCoreNamespace() + "DateTimeInterval";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIntervalToStartURI() {
|
public String getIntervalToStartURI() {
|
||||||
return getVivoCoreNamespace() + "start";
|
return getVivoCoreNamespace() + "start";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIntervalToEndURI() {
|
public String getIntervalToEndURI() {
|
||||||
return getVivoCoreNamespace() + "end";
|
return getVivoCoreNamespace() + "end";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStartYearPredURI() {
|
public String getStartYearPredURI() {
|
||||||
return getVivoCoreNamespace() + "startYear";
|
return getVivoCoreNamespace() + "startYear";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEndYearPredURI() {
|
public String getEndYearPredURI() {
|
||||||
return getVivoCoreNamespace() + "endYear";
|
return getVivoCoreNamespace() + "endYear";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDateTimeValueTypeURI() {
|
public String getDateTimeValueTypeURI() {
|
||||||
return getVivoCoreNamespace() + "DateTimeValue";
|
return getVivoCoreNamespace() + "DateTimeValue";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDateTimePrecisionURI() {
|
public String getDateTimePrecisionURI() {
|
||||||
return getVivoCoreNamespace() + "dateTimePrecision";
|
return getVivoCoreNamespace() + "dateTimePrecision";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDateTimeValueURI() {
|
public String getDateTimeValueURI() {
|
||||||
return getVivoCoreNamespace() + "dateTime";
|
return getVivoCoreNamespace() + "dateTime";
|
||||||
}
|
}
|
||||||
|
|
||||||
//Form specific data
|
//Form specific data
|
||||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||||
|
@ -731,23 +731,23 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
||||||
//Put in the fact that we require field
|
//Put in the fact that we require field
|
||||||
editConfiguration.setFormSpecificData(formSpecificData);
|
editConfiguration.setFormSpecificData(formSpecificData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSparqlForAcFilter(VitroRequest vreq) {
|
public String getSparqlForAcFilter(VitroRequest vreq) {
|
||||||
String subject = EditConfigurationUtils.getSubjectUri(vreq);
|
String subject = EditConfigurationUtils.getSubjectUri(vreq);
|
||||||
String predicate = EditConfigurationUtils.getPredicateUri(vreq);
|
String predicate = EditConfigurationUtils.getPredicateUri(vreq);
|
||||||
|
|
||||||
|
|
||||||
String query = "PREFIX core:<" + getVivoCoreNamespace() + "> " +
|
String query = "PREFIX core:<" + getVivoCoreNamespace() + "> " +
|
||||||
"SELECT ?grantUri WHERE { " +
|
"SELECT ?grantUri WHERE { " +
|
||||||
"<" + subject + "> <" + predicate + "> ?grantRole ." +
|
"<" + subject + "> <" + predicate + "> ?grantRole ." +
|
||||||
"?grantRole <" + getRoleToGrantPredicate(vreq) + "> ?grantUri . }";
|
"?grantRole <" + getRoleToGrantPredicate(vreq) + "> ?grantUri . }";
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getRangeUri(VitroRequest vreq) {
|
private String getRangeUri(VitroRequest vreq) {
|
||||||
String rangeUri = vreq.getParameter("rangeUri");
|
String rangeUri = vreq.getParameter("rangeUri");
|
||||||
|
|
||||||
return rangeUri;
|
return rangeUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,54 +1,54 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesOptions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
||||||
|
|
||||||
public class AddHeadOfRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
public class AddHeadOfRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
||||||
|
|
||||||
private static String template = "addHeadOfRoleToPerson.ftl";
|
private static String template = "addHeadOfRoleToPerson.ftl";
|
||||||
private static String OPTION_CLASS_URI = "http://xmlns.com/foaf/0.1/Organization";
|
private static String OPTION_CLASS_URI = "http://xmlns.com/foaf/0.1/Organization";
|
||||||
|
|
||||||
//Should this be overridden
|
//Should this be overridden
|
||||||
@Override
|
@Override
|
||||||
String getTemplate() {
|
String getTemplate() {
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getRoleType() {
|
String getRoleType() {
|
||||||
return "http://vivoweb.org/ontology/core#LeaderRole";
|
return "http://vivoweb.org/ontology/core#LeaderRole";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Head Of role involves hard-coded options for the "right side" of the role or activity */
|
/** Head Of role involves hard-coded options for the "right side" of the role or activity */
|
||||||
@Override
|
@Override
|
||||||
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
||||||
|
|
||||||
return new
|
return new
|
||||||
ChildVClassesOptions(OPTION_CLASS_URI)
|
ChildVClassesOptions(OPTION_CLASS_URI)
|
||||||
.setDefaultOptionLabel("Select type");
|
.setDefaultOptionLabel("Select type");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isShowRoleLabelField(){return true;}
|
boolean isShowRoleLabelField(){return true;}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use the methods below to change the date/time precision in the
|
* Use the methods below to change the date/time precision in the
|
||||||
* custom form associated with this generator. When not used, the
|
* custom form associated with this generator. When not used, the
|
||||||
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
||||||
* MINUTE, TIME and NONE.
|
* MINUTE, TIME and NONE.
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
public String getStartDatePrecision() {
|
public String getStartDatePrecision() {
|
||||||
String precision = VitroVocabulary.Precision.MONTH.uri();
|
String precision = VitroVocabulary.Precision.MONTH.uri();
|
||||||
return precision;
|
return precision;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEndDatePrecision() {
|
public String getEndDatePrecision() {
|
||||||
String precision = VitroVocabulary.Precision.DAY.uri();
|
String precision = VitroVocabulary.Precision.DAY.uri();
|
||||||
return precision;
|
return precision;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,19 +7,19 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantField
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
||||||
|
|
||||||
public class AddMemberRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
public class AddMemberRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
||||||
|
|
||||||
private static String template = "addMemberRoleToPerson.ftl";
|
private static String template = "addMemberRoleToPerson.ftl";
|
||||||
private static String VCLASS_URI = "http://xmlns.com/foaf/0.1/Organization";
|
private static String VCLASS_URI = "http://xmlns.com/foaf/0.1/Organization";
|
||||||
@Override
|
@Override
|
||||||
String getTemplate() {
|
String getTemplate() {
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getRoleType() {
|
String getRoleType() {
|
||||||
return "http://vivoweb.org/ontology/core#MemberRole";
|
return "http://vivoweb.org/ontology/core#MemberRole";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
||||||
return new ConstantFieldOptions(
|
return new ConstantFieldOptions(
|
||||||
|
@ -58,11 +58,11 @@ public class AddMemberRoleToPersonGenerator extends AddRoleToPersonTwoStageGener
|
||||||
"http://purl.obolibrary.org/obo/ERO_0000565","Technology Transfer Office",
|
"http://purl.obolibrary.org/obo/ERO_0000565","Technology Transfer Office",
|
||||||
"http://vivoweb.org/ontology/core#University","University");
|
"http://vivoweb.org/ontology/core#University","University");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
boolean isShowRoleLabelField(){return true;}
|
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
|
boolean isShowRoleLabelField(){return true;}
|
||||||
|
|
||||||
|
/*
|
||||||
* Use the methods below to change the date/time precision in the
|
* Use the methods below to change the date/time precision in the
|
||||||
* custom form associated with this generator. When not used, the
|
* custom form associated with this generator. When not used, the
|
||||||
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
||||||
|
@ -78,5 +78,5 @@ public class AddMemberRoleToPersonGenerator extends AddRoleToPersonTwoStageGener
|
||||||
String precision = VitroVocabulary.Precision.DAY.uri();
|
String precision = VitroVocabulary.Precision.DAY.uri();
|
||||||
return precision;
|
return precision;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,46 +17,46 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
|
||||||
public class AddOrcidIdToPersonGenerator extends VivoBaseGenerator implements
|
public class AddOrcidIdToPersonGenerator extends VivoBaseGenerator implements
|
||||||
EditConfigurationGenerator {
|
EditConfigurationGenerator {
|
||||||
private Log log = LogFactory.getLog(AddOrcidIdToPersonGenerator.class);
|
private Log log = LogFactory.getLog(AddOrcidIdToPersonGenerator.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
HttpSession session) throws Exception {
|
HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
|
|
||||||
conf.setTemplate("addOrcidIdToPerson.ftl");
|
conf.setTemplate("addOrcidIdToPerson.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("person");
|
conf.setVarNameForSubject("person");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("orcidId");
|
conf.setVarNameForObject("orcidId");
|
||||||
|
|
||||||
conf.setN3Required( Arrays.asList( n3ForOrcidId ) );
|
conf.setN3Required( Arrays.asList( n3ForOrcidId ) );
|
||||||
|
|
||||||
conf.setUrisOnform(Arrays.asList("orcidId"));
|
conf.setUrisOnform(Arrays.asList("orcidId"));
|
||||||
|
|
||||||
conf.addSparqlForExistingUris("orcidId", orcidIdQuery);
|
conf.addSparqlForExistingUris("orcidId", orcidIdQuery);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("orcidId").
|
setName("orcidId").
|
||||||
setValidators( list("nonempty") ));
|
setValidators( list("nonempty") ));
|
||||||
|
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
|
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* N3 assertions */
|
/* N3 assertions */
|
||||||
|
|
||||||
final static String n3ForOrcidId =
|
final static String n3ForOrcidId =
|
||||||
"@prefix owl: <http://www.w3.org/2002/07/owl#> .\n"+
|
"@prefix owl: <http://www.w3.org/2002/07/owl#> .\n"+
|
||||||
"?person <http://vivoweb.org/ontology/core#orcidId> ?orcidId . \n" +
|
"?person <http://vivoweb.org/ontology/core#orcidId> ?orcidId . \n" +
|
||||||
"?orcidId a owl:Thing . " ;
|
"?orcidId a owl:Thing . " ;
|
||||||
|
|
||||||
/* Queries for editing an existing entry */
|
/* Queries for editing an existing entry */
|
||||||
|
|
||||||
final static String orcidIdQuery =
|
final static String orcidIdQuery =
|
||||||
|
|
|
@ -7,10 +7,10 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantField
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
||||||
|
|
||||||
public class AddOrganizerRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
public class AddOrganizerRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
||||||
|
|
||||||
private static String template = "addOrganizerRoleToPerson.ftl";
|
private static String template = "addOrganizerRoleToPerson.ftl";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getTemplate() {
|
String getTemplate() {
|
||||||
return template;
|
return template;
|
||||||
|
@ -20,7 +20,7 @@ public class AddOrganizerRoleToPersonGenerator extends AddRoleToPersonTwoStageGe
|
||||||
String getRoleType() {
|
String getRoleType() {
|
||||||
return "http://vivoweb.org/ontology/core#OrganizerRole";
|
return "http://vivoweb.org/ontology/core#OrganizerRole";
|
||||||
}
|
}
|
||||||
|
|
||||||
//Organizer role involves hard-coded options for the "right side" of the role or activity
|
//Organizer role involves hard-coded options for the "right side" of the role or activity
|
||||||
@Override
|
@Override
|
||||||
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
||||||
|
@ -48,7 +48,7 @@ public class AddOrganizerRoleToPersonGenerator extends AddRoleToPersonTwoStageGe
|
||||||
boolean isShowRoleLabelField() {
|
boolean isShowRoleLabelField() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Use the methods below to change the date/time precision in the
|
* Use the methods below to change the date/time precision in the
|
||||||
* custom form associated with this generator. When not used, the
|
* custom form associated with this generator. When not used, the
|
||||||
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
||||||
|
@ -64,5 +64,5 @@ public class AddOrganizerRoleToPersonGenerator extends AddRoleToPersonTwoStageGe
|
||||||
String precision = VitroVocabulary.Precision.DAY.uri();
|
String precision = VitroVocabulary.Precision.DAY.uri();
|
||||||
return precision;
|
return precision;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,17 +7,17 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantField
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
||||||
|
|
||||||
public class AddOutreachProviderRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
public class AddOutreachProviderRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
||||||
|
|
||||||
private static String template = "addOutreachProviderRoleToPerson.ftl";
|
private static String template = "addOutreachProviderRoleToPerson.ftl";
|
||||||
private static String OPTION_CLASS_URI = "http://xmlns.com/foaf/0.1/Organization";
|
private static String OPTION_CLASS_URI = "http://xmlns.com/foaf/0.1/Organization";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getTemplate() {
|
String getTemplate() {
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getRoleType() {
|
String getRoleType() {
|
||||||
return "http://vivoweb.org/ontology/core#OutreachProviderRole";
|
return "http://vivoweb.org/ontology/core#OutreachProviderRole";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,8 +79,8 @@ public class AddOutreachProviderRoleToPersonGenerator extends AddRoleToPersonTwo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isShowRoleLabelField(){return true;}
|
boolean isShowRoleLabelField(){return true;}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use the methods below to change the date/time precision in the
|
* Use the methods below to change the date/time precision in the
|
||||||
* custom form associated with this generator. When not used, the
|
* custom form associated with this generator. When not used, the
|
||||||
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
||||||
|
@ -96,5 +96,5 @@ public class AddOutreachProviderRoleToPersonGenerator extends AddRoleToPersonTwo
|
||||||
String precision = VitroVocabulary.Precision.DAY.uri();
|
String precision = VitroVocabulary.Precision.DAY.uri();
|
||||||
return precision;
|
return precision;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,49 +37,49 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
|
||||||
final static String dateTimeValueType = vivoCore + "DateTimeValue";
|
final static String dateTimeValueType = vivoCore + "DateTimeValue";
|
||||||
final static String dateTimeValue = vivoCore + "dateTime";
|
final static String dateTimeValue = vivoCore + "dateTime";
|
||||||
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
|
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
|
||||||
|
|
||||||
public AddPresenterRoleToPersonGenerator() {}
|
public AddPresenterRoleToPersonGenerator() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
HttpSession session) throws Exception {
|
HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
|
|
||||||
conf.setTemplate("addPresenterRoleToPerson.ftl");
|
conf.setTemplate("addPresenterRoleToPerson.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("person");
|
conf.setVarNameForSubject("person");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("role");
|
conf.setVarNameForObject("role");
|
||||||
|
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewRole ) );
|
conf.setN3Required( Arrays.asList( n3ForNewRole ) );
|
||||||
conf.setN3Optional( Arrays.asList( n3ForRoleLabelAssertion,
|
conf.setN3Optional( Arrays.asList( n3ForRoleLabelAssertion,
|
||||||
n3ForNewPresentation,
|
n3ForNewPresentation,
|
||||||
n3ForExistingPresentation,
|
n3ForExistingPresentation,
|
||||||
n3ForNewConferenceNewPres,
|
n3ForNewConferenceNewPres,
|
||||||
n3ForNewConferenceExistingPres,
|
n3ForNewConferenceExistingPres,
|
||||||
n3ForExistingConferenceNewPres,
|
n3ForExistingConferenceNewPres,
|
||||||
n3ForExistingConferenceExistingPres,
|
n3ForExistingConferenceExistingPres,
|
||||||
n3ForStart,
|
n3ForStart,
|
||||||
n3ForEnd ) );
|
n3ForEnd ) );
|
||||||
|
|
||||||
conf.addNewResource("presentation", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("presentation", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("newConference", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("newConference", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("role", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("role", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
//uris in scope: none
|
//uris in scope: none
|
||||||
//literals in scope: none
|
//literals in scope: none
|
||||||
|
|
||||||
conf.setUrisOnform(Arrays.asList("existingPresentation", "existingConference", "presentationType"));
|
conf.setUrisOnform(Arrays.asList("existingPresentation", "existingConference", "presentationType"));
|
||||||
conf.setLiteralsOnForm(Arrays.asList("presentationLabel", "presentationLabelDisplay", "conferenceLabel", "conferenceLabelDisplay", "roleLabel"));
|
conf.setLiteralsOnForm(Arrays.asList("presentationLabel", "presentationLabelDisplay", "conferenceLabel", "conferenceLabelDisplay", "roleLabel"));
|
||||||
|
|
||||||
conf.addSparqlForExistingLiteral("presentationLabel", presentationLabelQuery);
|
conf.addSparqlForExistingLiteral("presentationLabel", presentationLabelQuery);
|
||||||
conf.addSparqlForExistingLiteral("conferenceLabel", conferenceLabelQuery);
|
conf.addSparqlForExistingLiteral("conferenceLabel", conferenceLabelQuery);
|
||||||
conf.addSparqlForExistingLiteral("roleLabel", roleLabelQuery);
|
conf.addSparqlForExistingLiteral("roleLabel", roleLabelQuery);
|
||||||
|
@ -94,69 +94,69 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
|
||||||
"intervalNode", existingIntervalNodeQuery);
|
"intervalNode", existingIntervalNodeQuery);
|
||||||
conf.addSparqlForExistingUris("startNode", existingStartNodeQuery);
|
conf.addSparqlForExistingUris("startNode", existingStartNodeQuery);
|
||||||
conf.addSparqlForExistingUris("endNode", existingEndNodeQuery);
|
conf.addSparqlForExistingUris("endNode", existingEndNodeQuery);
|
||||||
conf.addSparqlForExistingUris("startField-precision",
|
conf.addSparqlForExistingUris("startField-precision",
|
||||||
existingStartPrecisionQuery);
|
existingStartPrecisionQuery);
|
||||||
conf.addSparqlForExistingUris("endField-precision",
|
conf.addSparqlForExistingUris("endField-precision",
|
||||||
existingEndPrecisionQuery);
|
existingEndPrecisionQuery);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo(). // an autocomplete field
|
conf.addField( new FieldVTwo(). // an autocomplete field
|
||||||
setName("existingPresentation")
|
setName("existingPresentation")
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("presentationLabelDisplay")
|
setName("presentationLabelDisplay")
|
||||||
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators( list("datatype:" + XSD.xstring.toString()) )
|
setValidators( list("datatype:" + XSD.xstring.toString()) )
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("presentationLabel")
|
setName("presentationLabel")
|
||||||
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators( list("datatype:" + XSD.xstring.toString()) )
|
setValidators( list("datatype:" + XSD.xstring.toString()) )
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("presentationType").
|
setName("presentationType").
|
||||||
setValidators( list("nonempty") ).
|
setValidators( list("nonempty") ).
|
||||||
setOptions( new ChildVClassesWithParent(
|
setOptions( new ChildVClassesWithParent(
|
||||||
presentationClass))
|
presentationClass))
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("roleLabel").
|
setName("roleLabel").
|
||||||
setRangeDatatypeUri( XSD.xstring.toString() ).
|
setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators(list("datatype:" + XSD.xstring.toString())));
|
setValidators(list("datatype:" + XSD.xstring.toString())));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo(). // an autocomplete field
|
conf.addField( new FieldVTwo(). // an autocomplete field
|
||||||
setName("existingConference")
|
setName("existingConference")
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("conferenceLabel").
|
setName("conferenceLabel").
|
||||||
setRangeDatatypeUri(XSD.xstring.toString() )
|
setRangeDatatypeUri(XSD.xstring.toString() )
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("conferenceLabelDisplay").
|
setName("conferenceLabelDisplay").
|
||||||
setRangeDatatypeUri(XSD.xstring.toString() )
|
setRangeDatatypeUri(XSD.xstring.toString() )
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().setName("startField").
|
conf.addField( new FieldVTwo().setName("startField").
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(null,
|
new DateTimeWithPrecisionVTwo(null,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())
|
VitroVocabulary.Precision.NONE.uri())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().setName("endField").
|
conf.addField( new FieldVTwo().setName("endField").
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(null,
|
new DateTimeWithPrecisionVTwo(null,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())
|
VitroVocabulary.Precision.NONE.uri())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
|
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
conf.addValidator(new AutocompleteRequiredInputValidator("existingPresentation", "presentationLabel"));
|
conf.addValidator(new AutocompleteRequiredInputValidator("existingPresentation", "presentationLabel"));
|
||||||
|
@ -165,26 +165,26 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
/* N3 assertions */
|
/* N3 assertions */
|
||||||
final static String n3ForNewRole =
|
final static String n3ForNewRole =
|
||||||
"@prefix core: <" + vivoCore + "> . \n" +
|
"@prefix core: <" + vivoCore + "> . \n" +
|
||||||
"?person <" + hasRolePred + "> ?role . \n" +
|
"?person <" + hasRolePred + "> ?role . \n" +
|
||||||
"?role a <" + roleClass + "> . \n" +
|
"?role a <" + roleClass + "> . \n" +
|
||||||
"?role <" + roleOfPred + "> ?person . ";
|
"?role <" + roleOfPred + "> ?person . ";
|
||||||
|
|
||||||
final static String n3ForRoleLabelAssertion =
|
final static String n3ForRoleLabelAssertion =
|
||||||
"?role <" + label + "> ?roleLabel . ";
|
"?role <" + label + "> ?roleLabel . ";
|
||||||
|
|
||||||
final static String n3ForNewPresentation =
|
final static String n3ForNewPresentation =
|
||||||
"?role <" + roleRealizedInPred + "> ?presentation . \n" +
|
"?role <" + roleRealizedInPred + "> ?presentation . \n" +
|
||||||
"?presentation <" + realizedRolePred + "> ?role . \n" +
|
"?presentation <" + realizedRolePred + "> ?role . \n" +
|
||||||
"?presentation <" + label + "> ?presentationLabel . \n" +
|
"?presentation <" + label + "> ?presentationLabel . \n" +
|
||||||
"?presentation a ?presentationType .";
|
"?presentation a ?presentationType .";
|
||||||
|
|
||||||
final static String n3ForExistingPresentation =
|
final static String n3ForExistingPresentation =
|
||||||
"?role <" + roleRealizedInPred + "> ?existingPresentation . \n" +
|
"?role <" + roleRealizedInPred + "> ?existingPresentation . \n" +
|
||||||
"?existingPresentation <" + realizedRolePred + "> ?role . \n" +
|
"?existingPresentation <" + realizedRolePred + "> ?role . \n" +
|
||||||
"?existingPresentation a ?presentationType .";
|
"?existingPresentation a ?presentationType .";
|
||||||
|
|
||||||
final static String n3ForNewConferenceNewPres =
|
final static String n3ForNewConferenceNewPres =
|
||||||
"?presentation <" + eventWithinPred + "> ?newConference . \n" +
|
"?presentation <" + eventWithinPred + "> ?newConference . \n" +
|
||||||
"?newConference <" + includesEventPred + "> ?presentation . \n" +
|
"?newConference <" + includesEventPred + "> ?presentation . \n" +
|
||||||
|
@ -196,63 +196,63 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
|
||||||
"?newConference <" + includesEventPred + "> ?existingPresentation . \n" +
|
"?newConference <" + includesEventPred + "> ?existingPresentation . \n" +
|
||||||
"?newConference a <" + conferenceClass + "> . \n" +
|
"?newConference a <" + conferenceClass + "> . \n" +
|
||||||
"?newConference <" + label + "> ?conferenceLabel .";
|
"?newConference <" + label + "> ?conferenceLabel .";
|
||||||
|
|
||||||
final static String n3ForExistingConferenceNewPres =
|
final static String n3ForExistingConferenceNewPres =
|
||||||
"?existingConference <" + includesEventPred + "> ?presentation . \n" +
|
"?existingConference <" + includesEventPred + "> ?presentation . \n" +
|
||||||
"?presentation <" + eventWithinPred + "> ?existingConference . \n" +
|
"?presentation <" + eventWithinPred + "> ?existingConference . \n" +
|
||||||
"?presentation <" + label + "> ?presentationLabel . ";
|
"?presentation <" + label + "> ?presentationLabel . ";
|
||||||
|
|
||||||
final static String n3ForExistingConferenceExistingPres =
|
final static String n3ForExistingConferenceExistingPres =
|
||||||
"?existingConference <" + includesEventPred + "> ?existingPresentation . \n" +
|
"?existingConference <" + includesEventPred + "> ?existingPresentation . \n" +
|
||||||
"?existingPresentation <" + eventWithinPred + "> ?existingConference . ";
|
"?existingPresentation <" + eventWithinPred + "> ?existingConference . ";
|
||||||
|
|
||||||
final static String n3ForStart =
|
final static String n3ForStart =
|
||||||
"?role <" + roleToInterval + "> ?intervalNode . \n" +
|
"?role <" + roleToInterval + "> ?intervalNode . \n" +
|
||||||
"?intervalNode a <" + intervalType + "> . \n" +
|
"?intervalNode a <" + intervalType + "> . \n" +
|
||||||
"?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
"?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
"?startNode a <" + dateTimeValueType + "> . \n" +
|
"?startNode a <" + dateTimeValueType + "> . \n" +
|
||||||
"?startNode <" + dateTimeValue + "> ?startField-value . \n" +
|
"?startNode <" + dateTimeValue + "> ?startField-value . \n" +
|
||||||
"?startNode <" + dateTimePrecision + "> ?startField-precision . \n";
|
"?startNode <" + dateTimePrecision + "> ?startField-precision . \n";
|
||||||
|
|
||||||
final static String n3ForEnd =
|
final static String n3ForEnd =
|
||||||
"?role <" + roleToInterval + "> ?intervalNode . \n" +
|
"?role <" + roleToInterval + "> ?intervalNode . \n" +
|
||||||
"?intervalNode a <" + intervalType + "> . \n" +
|
"?intervalNode a <" + intervalType + "> . \n" +
|
||||||
"?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
"?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
||||||
"?endNode a <" + dateTimeValueType + "> . \n" +
|
"?endNode a <" + dateTimeValueType + "> . \n" +
|
||||||
"?endNode <" + dateTimeValue + "> ?endField-value . \n" +
|
"?endNode <" + dateTimeValue + "> ?endField-value . \n" +
|
||||||
"?endNode <" + dateTimePrecision + "> ?endField-precision . \n";
|
"?endNode <" + dateTimePrecision + "> ?endField-precision . \n";
|
||||||
|
|
||||||
/* Queries for editing an existing entry */
|
/* Queries for editing an existing entry */
|
||||||
final static String roleLabelQuery =
|
final static String roleLabelQuery =
|
||||||
"SELECT ?existingRoleLabel WHERE { \n" +
|
"SELECT ?existingRoleLabel WHERE { \n" +
|
||||||
"?role <" + label + "> ?existingRoleLabel . }";
|
"?role <" + label + "> ?existingRoleLabel . }";
|
||||||
|
|
||||||
final static String presentationQuery =
|
final static String presentationQuery =
|
||||||
"SELECT ?existingPresentation WHERE { \n" +
|
"SELECT ?existingPresentation WHERE { \n" +
|
||||||
"?role <" + roleRealizedInPred + "> ?existingPresentation . }";
|
"?role <" + roleRealizedInPred + "> ?existingPresentation . }";
|
||||||
|
|
||||||
final static String presentationLabelQuery =
|
final static String presentationLabelQuery =
|
||||||
"SELECT ?existingPresentationLabel WHERE { \n" +
|
"SELECT ?existingPresentationLabel WHERE { \n" +
|
||||||
"?role <" + roleRealizedInPred + "> ?existingPresentation . " +
|
"?role <" + roleRealizedInPred + "> ?existingPresentation . " +
|
||||||
"?existingPresentation <" + label + "> ?existingPresentationLabel . }";
|
"?existingPresentation <" + label + "> ?existingPresentationLabel . }";
|
||||||
|
|
||||||
final static String presentationTypeQuery =
|
final static String presentationTypeQuery =
|
||||||
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
||||||
"SELECT ?existingPresentationType WHERE { \n" +
|
"SELECT ?existingPresentationType WHERE { \n" +
|
||||||
"?role <" + roleRealizedInPred + "> ?existingPresentation . " +
|
"?role <" + roleRealizedInPred + "> ?existingPresentation . " +
|
||||||
"?existingPresentation vitro:mostSpecificType ?existingPresentationType . }";
|
"?existingPresentation vitro:mostSpecificType ?existingPresentationType . }";
|
||||||
|
|
||||||
final static String existingConferenceQuery =
|
final static String existingConferenceQuery =
|
||||||
"SELECT ?existingConference WHERE { \n" +
|
"SELECT ?existingConference WHERE { \n" +
|
||||||
"?role <" + roleRealizedInPred + "> ?existingPresentation . " +
|
"?role <" + roleRealizedInPred + "> ?existingPresentation . " +
|
||||||
"?existingPresentation <" + eventWithinPred + "> ?existingConference . }";
|
"?existingPresentation <" + eventWithinPred + "> ?existingConference . }";
|
||||||
|
|
||||||
final static String conferenceLabelQuery =
|
final static String conferenceLabelQuery =
|
||||||
"SELECT ?existingConferenceLabel WHERE { \n" +
|
"SELECT ?existingConferenceLabel WHERE { \n" +
|
||||||
"?role <" + roleRealizedInPred + "> ?existingPresentation . " +
|
"?role <" + roleRealizedInPred + "> ?existingPresentation . " +
|
||||||
"?existingPresentation <" + eventWithinPred + "> ?existingConference . \n" +
|
"?existingPresentation <" + eventWithinPred + "> ?existingConference . \n" +
|
||||||
"?existingConference <" + label + "> ?existingConferenceLabel . }";
|
"?existingConference <" + label + "> ?existingConferenceLabel . }";
|
||||||
|
|
||||||
final static String existingStartDateQuery =
|
final static String existingStartDateQuery =
|
||||||
"SELECT ?existingDateStart WHERE { \n" +
|
"SELECT ?existingDateStart WHERE { \n" +
|
||||||
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
|
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
|
||||||
|
@ -260,7 +260,7 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
|
||||||
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
" ?startNode a <" + dateTimeValueType +"> . \n" +
|
" ?startNode a <" + dateTimeValueType +"> . \n" +
|
||||||
" ?startNode <" + dateTimeValue + "> ?existingDateStart . }";
|
" ?startNode <" + dateTimeValue + "> ?existingDateStart . }";
|
||||||
|
|
||||||
final static String existingEndDateQuery =
|
final static String existingEndDateQuery =
|
||||||
"SELECT ?existingEndDate WHERE { \n" +
|
"SELECT ?existingEndDate WHERE { \n" +
|
||||||
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
|
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
|
||||||
|
@ -270,39 +270,39 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
|
||||||
" ?endNode <" + dateTimeValue + "> ?existingEndDate . }";
|
" ?endNode <" + dateTimeValue + "> ?existingEndDate . }";
|
||||||
|
|
||||||
final static String existingIntervalNodeQuery =
|
final static String existingIntervalNodeQuery =
|
||||||
"SELECT ?existingIntervalNode WHERE { \n" +
|
"SELECT ?existingIntervalNode WHERE { \n" +
|
||||||
" ?role <" + roleToInterval + "> ?existingIntervalNode . \n" +
|
" ?role <" + roleToInterval + "> ?existingIntervalNode . \n" +
|
||||||
" ?existingIntervalNode a <" + intervalType + "> . }";
|
" ?existingIntervalNode a <" + intervalType + "> . }";
|
||||||
|
|
||||||
final static String existingStartNodeQuery =
|
final static String existingStartNodeQuery =
|
||||||
"SELECT ?existingStartNode WHERE { \n" +
|
"SELECT ?existingStartNode WHERE { \n" +
|
||||||
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
|
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToStart + "> ?existingStartNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?existingStartNode . \n" +
|
||||||
" ?existingStartNode a <" + dateTimeValueType + "> . } ";
|
" ?existingStartNode a <" + dateTimeValueType + "> . } ";
|
||||||
|
|
||||||
final static String existingEndNodeQuery =
|
final static String existingEndNodeQuery =
|
||||||
"SELECT ?existingEndNode WHERE { \n" +
|
"SELECT ?existingEndNode WHERE { \n" +
|
||||||
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
|
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToEnd + "> ?existingEndNode . \n" +
|
" ?intervalNode <" + intervalToEnd + "> ?existingEndNode . \n" +
|
||||||
" ?existingEndNode a <" + dateTimeValueType + "> .} ";
|
" ?existingEndNode a <" + dateTimeValueType + "> .} ";
|
||||||
|
|
||||||
final static String existingStartPrecisionQuery =
|
final static String existingStartPrecisionQuery =
|
||||||
"SELECT ?existingStartPrecision WHERE { \n" +
|
"SELECT ?existingStartPrecision WHERE { \n" +
|
||||||
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
|
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
" ?startNode a <" + dateTimeValueType + "> . \n" +
|
" ?startNode a <" + dateTimeValueType + "> . \n" +
|
||||||
" ?startNode <" + dateTimePrecision + "> ?existingStartPrecision . }";
|
" ?startNode <" + dateTimePrecision + "> ?existingStartPrecision . }";
|
||||||
|
|
||||||
final static String existingEndPrecisionQuery =
|
final static String existingEndPrecisionQuery =
|
||||||
"SELECT ?existingEndPrecision WHERE { \n" +
|
"SELECT ?existingEndPrecision WHERE { \n" +
|
||||||
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
|
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
" ?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
||||||
" ?endNode a <" + dateTimeValueType + "> . \n" +
|
" ?endNode a <" + dateTimeValueType + "> . \n" +
|
||||||
" ?endNode <" + dateTimePrecision + "> ?existingEndPrecision . }";
|
" ?endNode <" + dateTimePrecision + "> ?existingEndPrecision . }";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On an add/new, this will show a form, on an edit/update this will skip to the
|
* On an add/new, this will show a form, on an edit/update this will skip to the
|
||||||
* profile page of the publication.
|
* profile page of the publication.
|
||||||
*/
|
*/
|
||||||
public class AddPublicationToPersonGenerator extends VivoBaseGenerator implements EditConfigurationGenerator {
|
public class AddPublicationToPersonGenerator extends VivoBaseGenerator implements EditConfigurationGenerator {
|
||||||
|
|
||||||
|
@ -61,12 +61,12 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
final static String dateTimeValue = vivoCore + "dateTime";
|
final static String dateTimeValue = vivoCore + "dateTime";
|
||||||
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
|
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
|
||||||
final static String relatesPred = vivoCore + "relates";
|
final static String relatesPred = vivoCore + "relates";
|
||||||
|
|
||||||
public AddPublicationToPersonGenerator() {}
|
public AddPublicationToPersonGenerator() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) throws Exception {
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) throws Exception {
|
||||||
|
|
||||||
if( EditConfigurationUtils.getObjectUri(vreq) == null ){
|
if( EditConfigurationUtils.getObjectUri(vreq) == null ){
|
||||||
return doAddNew(vreq,session);
|
return doAddNew(vreq,session);
|
||||||
}else{
|
}else{
|
||||||
|
@ -76,7 +76,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
|
|
||||||
private EditConfigurationVTwo doSkipToPublication(VitroRequest vreq) {
|
private EditConfigurationVTwo doSkipToPublication(VitroRequest vreq) {
|
||||||
Individual authorshipNode = EditConfigurationUtils.getObjectIndividual(vreq);
|
Individual authorshipNode = EditConfigurationUtils.getObjectIndividual(vreq);
|
||||||
|
|
||||||
//try to get the publication
|
//try to get the publication
|
||||||
String pubQueryStr = "SELECT ?obj \n" +
|
String pubQueryStr = "SELECT ?obj \n" +
|
||||||
"WHERE { <" + authorshipNode.getURI() + "> <" + relatesPred + "> ?obj . \n" +
|
"WHERE { <" + authorshipNode.getURI() + "> <" + relatesPred + "> ?obj . \n" +
|
||||||
|
@ -89,8 +89,8 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
return doBadAuthorshipNoPub( vreq );
|
return doBadAuthorshipNoPub( vreq );
|
||||||
}else if( rs.size() > 1 ){
|
}else if( rs.size() > 1 ){
|
||||||
return doBadAuthorshipMultiplePubs(vreq);
|
return doBadAuthorshipMultiplePubs(vreq);
|
||||||
}else{
|
}else{
|
||||||
//skip to publication
|
//skip to publication
|
||||||
RDFNode objNode = rs.next().get("obj");
|
RDFNode objNode = rs.next().get("obj");
|
||||||
if (!objNode.isResource() || objNode.isAnon()) {
|
if (!objNode.isResource() || objNode.isAnon()) {
|
||||||
return doBadAuthorshipNoPub( vreq );
|
return doBadAuthorshipNoPub( vreq );
|
||||||
|
@ -154,10 +154,10 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setVarNames(EditConfigurationVTwo editConfiguration) {
|
private void setVarNames(EditConfigurationVTwo editConfiguration) {
|
||||||
editConfiguration.setVarNameForSubject("person");
|
editConfiguration.setVarNameForSubject("person");
|
||||||
editConfiguration.setVarNameForPredicate("predicate");
|
editConfiguration.setVarNameForPredicate("predicate");
|
||||||
editConfiguration.setVarNameForObject("authorshipUri");
|
editConfiguration.setVarNameForObject("authorshipUri");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -216,18 +216,18 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getAuthorshipN3() {
|
private String getAuthorshipN3() {
|
||||||
return "@prefix core: <" + vivoCore + "> . " +
|
return "@prefix core: <" + vivoCore + "> . " +
|
||||||
"?authorshipUri a core:Authorship ;" +
|
"?authorshipUri a core:Authorship ;" +
|
||||||
"core:relates ?person ." +
|
"core:relates ?person ." +
|
||||||
"?person core:relatedBy ?authorshipUri .";
|
"?person core:relatedBy ?authorshipUri .";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3ForNewPub() {
|
private String getN3ForNewPub() {
|
||||||
return "@prefix core: <" + vivoCore + "> ." +
|
return "@prefix core: <" + vivoCore + "> ." +
|
||||||
"?newPublication a ?pubType ." +
|
"?newPublication a ?pubType ." +
|
||||||
"?newPublication <" + label + "> ?title ." +
|
"?newPublication <" + label + "> ?title ." +
|
||||||
"?authorshipUri core:relates ?newPublication ." +
|
"?authorshipUri core:relates ?newPublication ." +
|
||||||
"?newPublication core:relatedBy ?authorshipUri .";
|
"?newPublication core:relatedBy ?authorshipUri .";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3ForExistingPub() {
|
private String getN3ForExistingPub() {
|
||||||
|
@ -240,7 +240,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||||
"?newPublication vivo:hasPublicationVenue ?newCollection . \n" +
|
"?newPublication vivo:hasPublicationVenue ?newCollection . \n" +
|
||||||
"?newCollection a <" + collectionClass + "> . \n" +
|
"?newCollection a <" + collectionClass + "> . \n" +
|
||||||
"?newCollection vivo:publicationVenueFor ?newPublication . \n" +
|
"?newCollection vivo:publicationVenueFor ?newPublication . \n" +
|
||||||
"?newCollection <" + label + "> ?collection .";
|
"?newCollection <" + label + "> ?collection .";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||||
"?pubUri vivo:hasPublicationVenue ?newCollection . \n" +
|
"?pubUri vivo:hasPublicationVenue ?newCollection . \n" +
|
||||||
"?newCollection a <" + collectionClass + "> . \n" +
|
"?newCollection a <" + collectionClass + "> . \n" +
|
||||||
"?newCollection vivo:publicationVenueFor ?pubUri . \n" +
|
"?newCollection vivo:publicationVenueFor ?pubUri . \n" +
|
||||||
"?newCollection <" + label + "> ?collection .";
|
"?newCollection <" + label + "> ?collection .";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||||
"?pubUri vivo:hasPublicationVenue ?newBook . \n" +
|
"?pubUri vivo:hasPublicationVenue ?newBook . \n" +
|
||||||
"?newBook a <" + bookClass + "> . \n" +
|
"?newBook a <" + bookClass + "> . \n" +
|
||||||
"?newBook vivo:publicationVenueFor ?pubUri . \n " +
|
"?newBook vivo:publicationVenueFor ?pubUri . \n " +
|
||||||
"?newBook <" + label + "> ?book .";
|
"?newBook <" + label + "> ?book .";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,8 +282,8 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||||
"?newPublication vivo:hasPublicationVenue ?newBook . \n" +
|
"?newPublication vivo:hasPublicationVenue ?newBook . \n" +
|
||||||
"?newBook a <" + bookClass + "> . \n" +
|
"?newBook a <" + bookClass + "> . \n" +
|
||||||
"?newBook vivo:publicationVenueFor ?newPublication . \n " +
|
"?newBook vivo:publicationVenueFor ?newPublication . \n " +
|
||||||
"?newBook <" + label + "> ?book . ";
|
"?newBook <" + label + "> ?book . ";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3ForNewBookVolume() {
|
private String getN3ForNewBookVolume() {
|
||||||
|
@ -312,7 +312,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
"?editorship a vivo:Editorship . \n" +
|
"?editorship a vivo:Editorship . \n" +
|
||||||
"?editorship vivo:relates ?newEditor . \n" +
|
"?editorship vivo:relates ?newEditor . \n" +
|
||||||
"?newEditor a <" + editorClass + "> . \n" +
|
"?newEditor a <" + editorClass + "> . \n" +
|
||||||
"?newEditor vivo:relatedBy ?editorship . \n" +
|
"?newEditor vivo:relatedBy ?editorship . \n" +
|
||||||
"?newEditor <" + label + "> ?editor .";
|
"?newEditor <" + label + "> ?editor .";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,13 +323,13 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
"?newBook <" + label + "> ?book . \n " +
|
"?newBook <" + label + "> ?book . \n " +
|
||||||
"?editorship a vivo:Editorship . \n" +
|
"?editorship a vivo:Editorship . \n" +
|
||||||
"?editorship vivo:relates ?editorUri . \n" +
|
"?editorship vivo:relates ?editorUri . \n" +
|
||||||
"?editorUri vivo:relatedBy ?editorship . ";
|
"?editorUri vivo:relatedBy ?editorship . ";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3ForNewBookNewPublisher() {
|
private String getN3ForNewBookNewPublisher() {
|
||||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||||
"?newBook vivo:publisher ?newPublisher . \n " +
|
"?newBook vivo:publisher ?newPublisher . \n " +
|
||||||
"?newPublisher vivo:publisherOf ?newBook . \n" +
|
"?newPublisher vivo:publisherOf ?newBook . \n" +
|
||||||
"?newPublisher <" + label + "> ?publisher .";
|
"?newPublisher <" + label + "> ?publisher .";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||||
"?pubUri <" + presentedAtPred + "> ?newConference . \n" +
|
"?pubUri <" + presentedAtPred + "> ?newConference . \n" +
|
||||||
"?newConference a <" + conferenceClass + "> . \n" +
|
"?newConference a <" + conferenceClass + "> . \n" +
|
||||||
"?newConference <http://purl.obolibrary.org/obo/BFO_0000051> ?pubUri . \n" +
|
"?newConference <http://purl.obolibrary.org/obo/BFO_0000051> ?pubUri . \n" +
|
||||||
"?newConference <" + label + "> ?conference .";
|
"?newConference <" + label + "> ?conference .";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||||
"?newPublication <" + presentedAtPred + "> ?newConference . \n" +
|
"?newPublication <" + presentedAtPred + "> ?newConference . \n" +
|
||||||
"?newConference a <" + conferenceClass + "> . \n" +
|
"?newConference a <" + conferenceClass + "> . \n" +
|
||||||
"?newConference <http://purl.obolibrary.org/obo/BFO_0000051> ?newPublication . \n" +
|
"?newConference <http://purl.obolibrary.org/obo/BFO_0000051> ?newPublication . \n" +
|
||||||
"?newConference <" + label + "> ?conference .";
|
"?newConference <" + label + "> ?conference .";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||||
"?pubUri vivo:proceedingsOf ?newEvent . \n" +
|
"?pubUri vivo:proceedingsOf ?newEvent . \n" +
|
||||||
"?newEvent a <" + conferenceClass + "> . \n" +
|
"?newEvent a <" + conferenceClass + "> . \n" +
|
||||||
"?newEvent vivo:hasProceedings ?pubUri . \n" +
|
"?newEvent vivo:hasProceedings ?pubUri . \n" +
|
||||||
"?newEvent <" + label + "> ?event .";
|
"?newEvent <" + label + "> ?event .";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||||
"?newPublication vivo:proceedingsOf ?newEvent . \n" +
|
"?newPublication vivo:proceedingsOf ?newEvent . \n" +
|
||||||
"?newEvent a <" + conferenceClass + "> . \n" +
|
"?newEvent a <" + conferenceClass + "> . \n" +
|
||||||
"?newEvent vivo:hasProceedings ?newPublication . \n" +
|
"?newEvent vivo:hasProceedings ?newPublication . \n" +
|
||||||
"?newEvent <" + label + "> ?event .";
|
"?newEvent <" + label + "> ?event .";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
"?editorship a vivo:Editorship . \n" +
|
"?editorship a vivo:Editorship . \n" +
|
||||||
"?editorship vivo:relates ?newEditor . \n" +
|
"?editorship vivo:relates ?newEditor . \n" +
|
||||||
"?newEditor a <" + editorClass + "> . \n" +
|
"?newEditor a <" + editorClass + "> . \n" +
|
||||||
"?newEditor vivo:relatedBy ?editorship . \n" +
|
"?newEditor vivo:relatedBy ?editorship . \n" +
|
||||||
"?newEditor <" + label + "> ?editor .";
|
"?newEditor <" + label + "> ?editor .";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,7 +418,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
"?editorship vivo:relates ?pubUri . \n" +
|
"?editorship vivo:relates ?pubUri . \n" +
|
||||||
"?editorship a vivo:Editorship . \n" +
|
"?editorship a vivo:Editorship . \n" +
|
||||||
"?editorship vivo:relates ?editorUri . \n" +
|
"?editorship vivo:relates ?editorUri . \n" +
|
||||||
"?editorUri vivo:relatedBy ?editorship . ";
|
"?editorUri vivo:relatedBy ?editorship . ";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3ForNewEditorNewPub() {
|
private String getN3ForNewEditorNewPub() {
|
||||||
|
@ -429,7 +429,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
"?editorship a vivo:Editorship . \n" +
|
"?editorship a vivo:Editorship . \n" +
|
||||||
"?editorship vivo:relates ?newEditor . \n" +
|
"?editorship vivo:relates ?newEditor . \n" +
|
||||||
"?newEditor a <" + editorClass + "> . \n" +
|
"?newEditor a <" + editorClass + "> . \n" +
|
||||||
"?newEditor vivo:relatedBy ?editorship . \n" +
|
"?newEditor vivo:relatedBy ?editorship . \n" +
|
||||||
"?newEditor <" + label + "> ?editor .";
|
"?newEditor <" + label + "> ?editor .";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,14 +440,14 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
"?newPublication <" + label + "> ?title ." +
|
"?newPublication <" + label + "> ?title ." +
|
||||||
"?editorship vivo:relates ?editorUri . \n" +
|
"?editorship vivo:relates ?editorUri . \n" +
|
||||||
"?editorship a vivo:Editorship . \n" +
|
"?editorship a vivo:Editorship . \n" +
|
||||||
"?editorUri vivo:relatedBy ?editorship . ";
|
"?editorUri vivo:relatedBy ?editorship . ";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getN3ForNewPublisher() {
|
private String getN3ForNewPublisher() {
|
||||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||||
"?pubUri vivo:publisher ?newPublisher . \n" +
|
"?pubUri vivo:publisher ?newPublisher . \n" +
|
||||||
"?newPublisher a <" + publisherClass + "> . \n" +
|
"?newPublisher a <" + publisherClass + "> . \n" +
|
||||||
"?newPublisher vivo:publisherOf ?pubUri . \n" +
|
"?newPublisher vivo:publisherOf ?pubUri . \n" +
|
||||||
"?newPublisher <" + label + "> ?publisher .";
|
"?newPublisher <" + label + "> ?publisher .";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -461,7 +461,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||||
"?newPublication vivo:publisher ?newPublisher . \n" +
|
"?newPublication vivo:publisher ?newPublisher . \n" +
|
||||||
"?newPublisher a <" + publisherClass + "> . \n" +
|
"?newPublisher a <" + publisherClass + "> . \n" +
|
||||||
"?newPublisher vivo:publisherOf ?newPublication . \n" +
|
"?newPublisher vivo:publisherOf ?newPublication . \n" +
|
||||||
"?newPublisher <" + label + "> ?publisher .";
|
"?newPublisher <" + label + "> ?publisher .";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,9 +475,9 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
return "@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
return "@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newEditor <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardEditor . \n" +
|
"?newEditor <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardEditor . \n" +
|
||||||
"?vcardEditor <http://purl.obolibrary.org/obo/ARG_2000029> ?newEditor . \n" +
|
"?vcardEditor <http://purl.obolibrary.org/obo/ARG_2000029> ?newEditor . \n" +
|
||||||
"?vcardEditor a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?vcardEditor a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?vcardEditor vcard:hasName ?vcardName . \n" +
|
"?vcardEditor vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
||||||
"?vcardName vcard:givenName ?firstName .";
|
"?vcardName vcard:givenName ?firstName .";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,9 +485,9 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
return "@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
return "@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newEditor <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardEditor . \n" +
|
"?newEditor <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardEditor . \n" +
|
||||||
"?vcardEditor <http://purl.obolibrary.org/obo/ARG_2000029> ?newEditor . \n" +
|
"?vcardEditor <http://purl.obolibrary.org/obo/ARG_2000029> ?newEditor . \n" +
|
||||||
"?vcardEditor a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?vcardEditor a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?vcardEditor vcard:hasName ?vcardName . \n" +
|
"?vcardEditor vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
||||||
"?vcardName vcard:familyName ?lastName .";
|
"?vcardName vcard:familyName ?lastName .";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,10 +535,10 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get new resources */
|
/** Get new resources */
|
||||||
private Map<String, String> generateNewResources(VitroRequest vreq) {
|
private Map<String, String> generateNewResources(VitroRequest vreq) {
|
||||||
String DEFAULT_NS_TOKEN=null; //null forces the default NS
|
String DEFAULT_NS_TOKEN=null; //null forces the default NS
|
||||||
|
|
||||||
HashMap<String, String> newResources = new HashMap<String, String>();
|
HashMap<String, String> newResources = new HashMap<String, String>();
|
||||||
newResources.put("authorshipUri", DEFAULT_NS_TOKEN);
|
newResources.put("authorshipUri", DEFAULT_NS_TOKEN);
|
||||||
newResources.put("newPublication", DEFAULT_NS_TOKEN);
|
newResources.put("newPublication", DEFAULT_NS_TOKEN);
|
||||||
newResources.put("newCollection", DEFAULT_NS_TOKEN);
|
newResources.put("newCollection", DEFAULT_NS_TOKEN);
|
||||||
|
@ -554,21 +554,21 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
return newResources;
|
return newResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set URIS and Literals In Scope and on form and supporting methods */
|
/** Set URIS and Literals In Scope and on form and supporting methods */
|
||||||
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
||||||
urisInScope.put(editConfiguration.getVarNameForSubject(),
|
urisInScope.put(editConfiguration.getVarNameForSubject(),
|
||||||
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
|
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
|
||||||
urisInScope.put(editConfiguration.getVarNameForPredicate(),
|
urisInScope.put(editConfiguration.getVarNameForPredicate(),
|
||||||
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
|
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
|
||||||
editConfiguration.setUrisInScope(urisInScope);
|
editConfiguration.setUrisInScope(urisInScope);
|
||||||
HashMap<String, List<Literal>> literalsInScope = new HashMap<String, List<Literal>>();
|
HashMap<String, List<Literal>> literalsInScope = new HashMap<String, List<Literal>>();
|
||||||
editConfiguration.setLiteralsInScope(literalsInScope);
|
editConfiguration.setLiteralsInScope(literalsInScope);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
List<String> urisOnForm = new ArrayList<String>();
|
List<String> urisOnForm = new ArrayList<String>();
|
||||||
//add role activity and roleActivityType to uris on form
|
//add role activity and roleActivityType to uris on form
|
||||||
urisOnForm.add("pubType");
|
urisOnForm.add("pubType");
|
||||||
urisOnForm.add("pubUri");
|
urisOnForm.add("pubUri");
|
||||||
|
@ -605,11 +605,11 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
literalsOnForm.add("firstName");
|
literalsOnForm.add("firstName");
|
||||||
literalsOnForm.add("lastName");
|
literalsOnForm.add("lastName");
|
||||||
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set SPARQL Queries and supporting methods. */
|
/** Set SPARQL Queries and supporting methods. */
|
||||||
//In this case no queries for existing
|
//In this case no queries for existing
|
||||||
private void setSparqlQueries(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setSparqlQueries(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
editConfiguration.setSparqlForExistingUris(new HashMap<String, String>());
|
editConfiguration.setSparqlForExistingUris(new HashMap<String, String>());
|
||||||
editConfiguration.setSparqlForAdditionalLiteralsInScope(new HashMap<String, String>());
|
editConfiguration.setSparqlForAdditionalLiteralsInScope(new HashMap<String, String>());
|
||||||
editConfiguration.setSparqlForAdditionalUrisInScope(new HashMap<String, String>());
|
editConfiguration.setSparqlForAdditionalUrisInScope(new HashMap<String, String>());
|
||||||
|
@ -617,9 +617,9 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Set Fields and supporting methods
|
* Set Fields and supporting methods
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq) throws Exception {
|
private void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq) throws Exception {
|
||||||
|
@ -668,7 +668,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
setName("pubType").
|
setName("pubType").
|
||||||
setValidators( list("nonempty") ).
|
setValidators( list("nonempty") ).
|
||||||
setOptions( new ConstantFieldOptions("pubType", getPublicationTypeLiteralOptions() ))
|
setOptions( new ConstantFieldOptions("pubType", getPublicationTypeLiteralOptions() ))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -697,7 +697,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
setName("collectionUri"));
|
setName("collectionUri"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBookLabelField(EditConfigurationVTwo editConfiguration) {
|
private void setBookLabelField(EditConfigurationVTwo editConfiguration) {
|
||||||
String stringDatatypeUri = XSD.xstring.toString();
|
String stringDatatypeUri = XSD.xstring.toString();
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
|
@ -705,7 +705,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
setValidators(list("datatype:" + stringDatatypeUri)).
|
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||||
setRangeDatatypeUri(stringDatatypeUri));
|
setRangeDatatypeUri(stringDatatypeUri));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBookDisplayField(EditConfigurationVTwo editConfiguration) {
|
private void setBookDisplayField(EditConfigurationVTwo editConfiguration) {
|
||||||
String stringDatatypeUri = XSD.xstring.toString();
|
String stringDatatypeUri = XSD.xstring.toString();
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
|
@ -718,7 +718,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
setName("bookUri"));
|
setName("bookUri"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setConferenceLabelField(EditConfigurationVTwo editConfiguration) {
|
private void setConferenceLabelField(EditConfigurationVTwo editConfiguration) {
|
||||||
String stringDatatypeUri = XSD.xstring.toString();
|
String stringDatatypeUri = XSD.xstring.toString();
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
|
@ -726,7 +726,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
setValidators(list("datatype:" + stringDatatypeUri)).
|
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||||
setRangeDatatypeUri(stringDatatypeUri));
|
setRangeDatatypeUri(stringDatatypeUri));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setConferenceDisplayField(EditConfigurationVTwo editConfiguration) {
|
private void setConferenceDisplayField(EditConfigurationVTwo editConfiguration) {
|
||||||
String stringDatatypeUri = XSD.xstring.toString();
|
String stringDatatypeUri = XSD.xstring.toString();
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
|
@ -739,7 +739,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
setName("conferenceUri"));
|
setName("conferenceUri"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEventLabelField(EditConfigurationVTwo editConfiguration) {
|
private void setEventLabelField(EditConfigurationVTwo editConfiguration) {
|
||||||
String stringDatatypeUri = XSD.xstring.toString();
|
String stringDatatypeUri = XSD.xstring.toString();
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
|
@ -747,7 +747,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
setValidators(list("datatype:" + stringDatatypeUri)).
|
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||||
setRangeDatatypeUri(stringDatatypeUri));
|
setRangeDatatypeUri(stringDatatypeUri));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEventDisplayField(EditConfigurationVTwo editConfiguration) {
|
private void setEventDisplayField(EditConfigurationVTwo editConfiguration) {
|
||||||
String stringDatatypeUri = XSD.xstring.toString();
|
String stringDatatypeUri = XSD.xstring.toString();
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
|
@ -756,7 +756,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
setRangeDatatypeUri(stringDatatypeUri));
|
setRangeDatatypeUri(stringDatatypeUri));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setFirstNameField(EditConfigurationVTwo editConfiguration) {
|
private void setFirstNameField(EditConfigurationVTwo editConfiguration) {
|
||||||
String stringDatatypeUri = XSD.xstring.toString();
|
String stringDatatypeUri = XSD.xstring.toString();
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
|
@ -764,7 +764,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
setValidators(list("datatype:" + stringDatatypeUri)).
|
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||||
setRangeDatatypeUri(stringDatatypeUri));
|
setRangeDatatypeUri(stringDatatypeUri));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLastNameField(EditConfigurationVTwo editConfiguration) {
|
private void setLastNameField(EditConfigurationVTwo editConfiguration) {
|
||||||
String stringDatatypeUri = XSD.xstring.toString();
|
String stringDatatypeUri = XSD.xstring.toString();
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
|
@ -776,7 +776,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
setName("eventUri"));
|
setName("eventUri"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEditorLabelField(EditConfigurationVTwo editConfiguration) {
|
private void setEditorLabelField(EditConfigurationVTwo editConfiguration) {
|
||||||
String stringDatatypeUri = XSD.xstring.toString();
|
String stringDatatypeUri = XSD.xstring.toString();
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
|
@ -784,7 +784,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
setValidators(list("datatype:" + stringDatatypeUri)).
|
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||||
setRangeDatatypeUri(stringDatatypeUri));
|
setRangeDatatypeUri(stringDatatypeUri));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEditorDisplayField(EditConfigurationVTwo editConfiguration) {
|
private void setEditorDisplayField(EditConfigurationVTwo editConfiguration) {
|
||||||
String stringDatatypeUri = XSD.xstring.toString();
|
String stringDatatypeUri = XSD.xstring.toString();
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
|
@ -797,7 +797,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
setName("editorUri"));
|
setName("editorUri"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPublisherLabelField(EditConfigurationVTwo editConfiguration) {
|
private void setPublisherLabelField(EditConfigurationVTwo editConfiguration) {
|
||||||
String stringDatatypeUri = XSD.xstring.toString();
|
String stringDatatypeUri = XSD.xstring.toString();
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
|
@ -805,7 +805,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
setValidators(list("datatype:" + stringDatatypeUri)).
|
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||||
setRangeDatatypeUri(stringDatatypeUri));
|
setRangeDatatypeUri(stringDatatypeUri));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPublisherDisplayField(EditConfigurationVTwo editConfiguration) {
|
private void setPublisherDisplayField(EditConfigurationVTwo editConfiguration) {
|
||||||
String stringDatatypeUri = XSD.xstring.toString();
|
String stringDatatypeUri = XSD.xstring.toString();
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
|
@ -818,7 +818,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
setName("publisherUri"));
|
setName("publisherUri"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLocaleField(EditConfigurationVTwo editConfiguration) {
|
private void setLocaleField(EditConfigurationVTwo editConfiguration) {
|
||||||
String stringDatatypeUri = XSD.xstring.toString();
|
String stringDatatypeUri = XSD.xstring.toString();
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
|
@ -879,11 +879,11 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
setName("dateTime").
|
setName("dateTime").
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(null,
|
new DateTimeWithPrecisionVTwo(null,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())
|
VitroVocabulary.Precision.NONE.uri())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<List<String>> getPublicationTypeLiteralOptions() {
|
private List<List<String>> getPublicationTypeLiteralOptions() {
|
||||||
|
@ -930,12 +930,12 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSparqlForAcFilter(VitroRequest vreq) {
|
public String getSparqlForAcFilter(VitroRequest vreq) {
|
||||||
String subject = EditConfigurationUtils.getSubjectUri(vreq);
|
String subject = EditConfigurationUtils.getSubjectUri(vreq);
|
||||||
|
|
||||||
String query = "PREFIX core:<" + vivoCore + "> " +
|
String query = "PREFIX core:<" + vivoCore + "> " +
|
||||||
"SELECT ?pubUri WHERE { " +
|
"SELECT ?pubUri WHERE { " +
|
||||||
"<" + subject + "> core:relatedBy ?authorshipUri . " +
|
"<" + subject + "> core:relatedBy ?authorshipUri . " +
|
||||||
"?authorshipUri a core:Authorship . " +
|
"?authorshipUri a core:Authorship . " +
|
||||||
"?authorshipUri core:relates ?pubUri . }";
|
"?authorshipUri core:relates ?pubUri . }";
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantField
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
||||||
|
|
||||||
public class AddResearcherRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
public class AddResearcherRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
||||||
|
|
||||||
private static String template = "addResearcherRoleToPerson.ftl";
|
private static String template = "addResearcherRoleToPerson.ftl";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getTemplate() {
|
String getTemplate() {
|
||||||
return template;
|
return template;
|
||||||
|
@ -19,21 +19,21 @@ public class AddResearcherRoleToPersonGenerator extends AddRoleToPersonTwoStageG
|
||||||
public String getRoleType() {
|
public String getRoleType() {
|
||||||
return "http://vivoweb.org/ontology/core#ResearcherRole";
|
return "http://vivoweb.org/ontology/core#ResearcherRole";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Researcher role involves hard-coded options for the "right side" of the role or activity. */
|
/** Researcher role involves hard-coded options for the "right side" of the role or activity. */
|
||||||
@Override
|
@Override
|
||||||
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
||||||
return new ConstantFieldOptions(
|
return new ConstantFieldOptions(
|
||||||
"", "Select one",
|
"", "Select one",
|
||||||
"http://vivoweb.org/ontology/core#Grant", "Grant",
|
"http://vivoweb.org/ontology/core#Grant", "Grant",
|
||||||
"http://purl.obolibrary.org/obo/ERO_0000015", "Human Study",
|
"http://purl.obolibrary.org/obo/ERO_0000015", "Human Study",
|
||||||
"http://vivoweb.org/ontology/core#Project", "Project",
|
"http://vivoweb.org/ontology/core#Project", "Project",
|
||||||
"http://purl.obolibrary.org/obo/ERO_0000014", "Research Project");
|
"http://purl.obolibrary.org/obo/ERO_0000014", "Research Project");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isShowRoleLabelField() { return true; }
|
boolean isShowRoleLabelField() { return true; }
|
||||||
/*
|
/*
|
||||||
* Use the methods below to change the date/time precision in the
|
* Use the methods below to change the date/time precision in the
|
||||||
* custom form associated with this generator. When not used, the
|
* custom form associated with this generator. When not used, the
|
||||||
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
||||||
|
@ -49,5 +49,5 @@ public class AddResearcherRoleToPersonGenerator extends AddRoleToPersonTwoStageG
|
||||||
String precision = VitroVocabulary.Precision.DAY.uri();
|
String precision = VitroVocabulary.Precision.DAY.uri();
|
||||||
return precision;
|
return precision;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,36 +6,36 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantFieldOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantFieldOptions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
||||||
|
|
||||||
public class AddReviewerRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
public class AddReviewerRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
||||||
|
|
||||||
private static String OBJECT_VCLASS_URI = "http://purl.org/ontology/bibo/Document";
|
private static String OBJECT_VCLASS_URI = "http://purl.org/ontology/bibo/Document";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getTemplate() { return "addReviewerRoleToPerson.ftl"; }
|
String getTemplate() { return "addReviewerRoleToPerson.ftl"; }
|
||||||
|
|
||||||
//The default activityToRolePredicate and roleToActivityPredicates are
|
//The default activityToRolePredicate and roleToActivityPredicates are
|
||||||
//correct for this subclass so they don't need to be overwritten
|
//correct for this subclass so they don't need to be overwritten
|
||||||
|
|
||||||
/* @Override
|
/* @Override
|
||||||
public String getRoleToActivityPredicate(VitroRequest vreq) {
|
public String getRoleToActivityPredicate(VitroRequest vreq) {
|
||||||
return "<http://purl.obolibrary.org/obo/BFO_0000054>";
|
return "<http://purl.obolibrary.org/obo/BFO_0000054>";
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
//role type will always be set based on particular form
|
//role type will always be set based on particular form
|
||||||
@Override
|
@Override
|
||||||
public String getRoleType() {
|
public String getRoleType() {
|
||||||
//TODO: Get dynamic way of including vivoweb ontology
|
//TODO: Get dynamic way of including vivoweb ontology
|
||||||
return "http://vivoweb.org/ontology/core#ReviewerRole";
|
return "http://vivoweb.org/ontology/core#ReviewerRole";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Each subclass generator will return its own type of option here:
|
* Each subclass generator will return its own type of option here:
|
||||||
* whether literal hardcoded, based on class group, or subclasses of a specific class
|
* whether literal hardcoded, based on class group, or subclasses of a specific class
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
||||||
return new ConstantFieldOptions(
|
return new ConstantFieldOptions(
|
||||||
"", "Select type",
|
"", "Select type",
|
||||||
"http://purl.org/ontology/bibo/AcademicArticle", "Academic Article",
|
"http://purl.org/ontology/bibo/AcademicArticle", "Academic Article",
|
||||||
"http://purl.org/ontology/bibo/Article", "Article",
|
"http://purl.org/ontology/bibo/Article", "Article",
|
||||||
"http://purl.org/ontology/bibo/AudioDocument", "Audio Document",
|
"http://purl.org/ontology/bibo/AudioDocument", "Audio Document",
|
||||||
|
@ -106,13 +106,13 @@ public class AddReviewerRoleToPersonGenerator extends AddRoleToPersonTwoStageGen
|
||||||
"http://vivoweb.org/ontology/core#WorkingPaper", "Working Paper"
|
"http://vivoweb.org/ontology/core#WorkingPaper", "Working Paper"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//isShowRoleLabelField remains true for this so doesn't need to be overwritten
|
//isShowRoleLabelField remains true for this so doesn't need to be overwritten
|
||||||
public boolean isShowRoleLabelField() {
|
public boolean isShowRoleLabelField() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use the methods below to change the date/time precision in the
|
* Use the methods below to change the date/time precision in the
|
||||||
* custom form associated with this generator. When not used, the
|
* custom form associated with this generator. When not used, the
|
||||||
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
||||||
|
@ -128,6 +128,6 @@ public class AddReviewerRoleToPersonGenerator extends AddRoleToPersonTwoStageGen
|
||||||
String precision = VitroVocabulary.Precision.DAY.uri();
|
String precision = VitroVocabulary.Precision.DAY.uri();
|
||||||
return precision;
|
return precision;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -6,19 +6,19 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantFieldOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantFieldOptions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
||||||
|
|
||||||
public class AddServiceProviderRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
public class AddServiceProviderRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
||||||
|
|
||||||
private static String OPTION_CLASS_URI = "http://xmlns.com/foaf/0.1/Organization";
|
private static String OPTION_CLASS_URI = "http://xmlns.com/foaf/0.1/Organization";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getTemplate() { return "addServiceProviderRoleToPerson.ftl"; }
|
String getTemplate() { return "addServiceProviderRoleToPerson.ftl"; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getRoleType() {
|
String getRoleType() {
|
||||||
return "http://purl.obolibrary.org/obo/ERO_0000012";
|
return "http://purl.obolibrary.org/obo/ERO_0000012";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Service Provider role involves hard-coded options for the
|
/** Service Provider role involves hard-coded options for the
|
||||||
* "right side" of the role or activity. */
|
* "right side" of the role or activity. */
|
||||||
@Override
|
@Override
|
||||||
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
||||||
|
@ -74,11 +74,11 @@ FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
||||||
"http://purl.org/ontology/bibo/Workshop", "Workshop",
|
"http://purl.org/ontology/bibo/Workshop", "Workshop",
|
||||||
"http://vivoweb.org/ontology/core#WorkshopSeries", "Workshop Series");
|
"http://vivoweb.org/ontology/core#WorkshopSeries", "Workshop Series");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isShowRoleLabelField(){return true;}
|
boolean isShowRoleLabelField(){return true;}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use the methods below to change the date/time precision in the
|
* Use the methods below to change the date/time precision in the
|
||||||
* custom form associated with this generator. When not used, the
|
* custom form associated with this generator. When not used, the
|
||||||
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
||||||
|
@ -94,5 +94,5 @@ FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
||||||
String precision = VitroVocabulary.Precision.DAY.uri();
|
String precision = VitroVocabulary.Precision.DAY.uri();
|
||||||
return precision;
|
return precision;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,55 +1,55 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantFieldOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantFieldOptions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldOptions;
|
||||||
|
|
||||||
public class AddTeacherRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
public class AddTeacherRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator {
|
||||||
|
|
||||||
private static String template = "addTeacherRoleToPerson.ftl";
|
private static String template = "addTeacherRoleToPerson.ftl";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getTemplate() {
|
String getTemplate() {
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getRoleType() {
|
String getRoleType() {
|
||||||
return "http://vivoweb.org/ontology/core#TeacherRole";
|
return "http://vivoweb.org/ontology/core#TeacherRole";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Teacher role involves hard-coded options for the "right side"
|
/** Teacher role involves hard-coded options for the "right side"
|
||||||
* of the role or activity. */
|
* of the role or activity. */
|
||||||
@Override
|
@Override
|
||||||
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
FieldOptions getRoleActivityFieldOptions(VitroRequest vreq) throws Exception {
|
||||||
return new ConstantFieldOptions(
|
return new ConstantFieldOptions(
|
||||||
"", "Select one",
|
"", "Select one",
|
||||||
"http://purl.org/ontology/bibo/Conference", "Conference",
|
"http://purl.org/ontology/bibo/Conference", "Conference",
|
||||||
"http://vivoweb.org/ontology/core#Course", "Course",
|
"http://vivoweb.org/ontology/core#Course", "Course",
|
||||||
"http://purl.org/ontology/bibo/Workshop", "Workshop");
|
"http://purl.org/ontology/bibo/Workshop", "Workshop");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isShowRoleLabelField(){return true;}
|
boolean isShowRoleLabelField(){return true;}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use the methods below to change the date/time precision in the
|
* Use the methods below to change the date/time precision in the
|
||||||
* custom form associated with this generator. When not used, the
|
* custom form associated with this generator. When not used, the
|
||||||
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
* precision will be YEAR. The other precisons are MONTH, DAY, HOUR,
|
||||||
* MINUTE, TIME and NONE.
|
* MINUTE, TIME and NONE.
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
public String getStartDatePrecision() {
|
public String getStartDatePrecision() {
|
||||||
String precision = VitroVocabulary.Precision.MONTH.uri();
|
String precision = VitroVocabulary.Precision.MONTH.uri();
|
||||||
return precision;
|
return precision;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEndDatePrecision() {
|
public String getEndDatePrecision() {
|
||||||
String precision = VitroVocabulary.Precision.DAY.uri();
|
String precision = VitroVocabulary.Precision.DAY.uri();
|
||||||
return precision;
|
return precision;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,311 +1,311 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
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.rdf.model.Literal;
|
import org.apache.jena.rdf.model.Literal;
|
||||||
import org.apache.jena.vocabulary.XSD;
|
import org.apache.jena.vocabulary.XSD;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
|
||||||
/**
|
/**
|
||||||
* Generates the edit configuration for importing concepts from external
|
* Generates the edit configuration for importing concepts from external
|
||||||
* search services, e.g. UMLS etc.
|
* search services, e.g. UMLS etc.
|
||||||
*/
|
*/
|
||||||
public class AddUserDefinedConceptGenerator extends VivoBaseGenerator implements EditConfigurationGenerator {
|
public class AddUserDefinedConceptGenerator extends VivoBaseGenerator implements EditConfigurationGenerator {
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(AddUserDefinedConceptGenerator.class);
|
private Log log = LogFactory.getLog(AddUserDefinedConceptGenerator.class);
|
||||||
private boolean isObjectPropForm = false;
|
private boolean isObjectPropForm = false;
|
||||||
private String subjectUri = null;
|
private String subjectUri = null;
|
||||||
private String predicateUri = null;
|
private String predicateUri = null;
|
||||||
private String objectUri = null;
|
private String objectUri = null;
|
||||||
private String datapropKeyStr= null;
|
private String datapropKeyStr= null;
|
||||||
private int dataHash = 0;
|
private int dataHash = 0;
|
||||||
private DataPropertyStatement dps = null;
|
private DataPropertyStatement dps = null;
|
||||||
private String dataLiteral = null;
|
private String dataLiteral = null;
|
||||||
private String template = "addUserDefinedConcept.ftl";
|
private String template = "addUserDefinedConcept.ftl";
|
||||||
private static HashMap<String,String> defaultsForXSDtypes ;
|
private static HashMap<String,String> defaultsForXSDtypes ;
|
||||||
private static String SKOSConceptType = "http://www.w3.org/2004/02/skos/core#Concept";
|
private static String SKOSConceptType = "http://www.w3.org/2004/02/skos/core#Concept";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
|
||||||
EditConfigurationVTwo editConfiguration = new EditConfigurationVTwo();
|
EditConfigurationVTwo editConfiguration = new EditConfigurationVTwo();
|
||||||
initBasics(editConfiguration, vreq);
|
initBasics(editConfiguration, vreq);
|
||||||
initPropertyParameters(vreq, session, editConfiguration);
|
initPropertyParameters(vreq, session, editConfiguration);
|
||||||
initObjectPropForm(editConfiguration, vreq);
|
initObjectPropForm(editConfiguration, vreq);
|
||||||
|
|
||||||
editConfiguration.setTemplate(template);
|
editConfiguration.setTemplate(template);
|
||||||
|
|
||||||
setVarNames(editConfiguration);
|
setVarNames(editConfiguration);
|
||||||
|
|
||||||
//Assumes this is a simple case of subject predicate var
|
//Assumes this is a simple case of subject predicate var
|
||||||
editConfiguration.setN3Required(this.generateN3Required(vreq));
|
editConfiguration.setN3Required(this.generateN3Required(vreq));
|
||||||
|
|
||||||
//n3 optional
|
//n3 optional
|
||||||
editConfiguration.setN3Optional(this.generateN3Optional());
|
editConfiguration.setN3Optional(this.generateN3Optional());
|
||||||
|
|
||||||
//Todo: what do new resources depend on here?
|
//Todo: what do new resources depend on here?
|
||||||
//In original form, these variables start off empty
|
//In original form, these variables start off empty
|
||||||
editConfiguration.setNewResources(generateNewResources(vreq));
|
editConfiguration.setNewResources(generateNewResources(vreq));
|
||||||
//In scope
|
//In scope
|
||||||
this.setUrisAndLiteralsInScope(editConfiguration, vreq);
|
this.setUrisAndLiteralsInScope(editConfiguration, vreq);
|
||||||
|
|
||||||
//on Form
|
//on Form
|
||||||
this.setUrisAndLiteralsOnForm(editConfiguration, vreq);
|
this.setUrisAndLiteralsOnForm(editConfiguration, vreq);
|
||||||
|
|
||||||
editConfiguration.setFilesOnForm(new ArrayList<String>());
|
editConfiguration.setFilesOnForm(new ArrayList<String>());
|
||||||
|
|
||||||
//Sparql queries
|
//Sparql queries
|
||||||
this.setSparqlQueries(editConfiguration, vreq);
|
this.setSparqlQueries(editConfiguration, vreq);
|
||||||
|
|
||||||
//set fields
|
//set fields
|
||||||
setFields(editConfiguration, vreq, EditConfigurationUtils.getPredicateUri(vreq));
|
setFields(editConfiguration, vreq, EditConfigurationUtils.getPredicateUri(vreq));
|
||||||
|
|
||||||
|
|
||||||
setTemplate(editConfiguration, vreq);
|
setTemplate(editConfiguration, vreq);
|
||||||
|
|
||||||
editConfiguration.addValidator(new AntiXssValidation());
|
editConfiguration.addValidator(new AntiXssValidation());
|
||||||
|
|
||||||
//Add preprocessors
|
//Add preprocessors
|
||||||
addPreprocessors(editConfiguration, vreq.getWebappDaoFactory());
|
addPreprocessors(editConfiguration, vreq.getWebappDaoFactory());
|
||||||
//Adding additional data, specifically edit mode
|
//Adding additional data, specifically edit mode
|
||||||
addFormSpecificData(editConfiguration, vreq);
|
addFormSpecificData(editConfiguration, vreq);
|
||||||
//One override for basic functionality, changing url pattern
|
//One override for basic functionality, changing url pattern
|
||||||
//and entity
|
//and entity
|
||||||
//Adding term should return to this same page, not the subject
|
//Adding term should return to this same page, not the subject
|
||||||
//Return takes the page back to the individual form
|
//Return takes the page back to the individual form
|
||||||
editConfiguration.setUrlPatternToReturnTo(getUrlPatternToReturnTo(vreq));
|
editConfiguration.setUrlPatternToReturnTo(getUrlPatternToReturnTo(vreq));
|
||||||
prepare(vreq, editConfiguration);
|
prepare(vreq, editConfiguration);
|
||||||
return editConfiguration;
|
return editConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String getUrlPatternToReturnTo(VitroRequest vreq) {
|
private String getUrlPatternToReturnTo(VitroRequest vreq) {
|
||||||
String subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
|
String subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
|
||||||
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||||
String generatorName = "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddAssociatedConceptGenerator";
|
String generatorName = "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddAssociatedConceptGenerator";
|
||||||
String editUrl = EditConfigurationUtils.getEditUrlWithoutContext(vreq);
|
String editUrl = EditConfigurationUtils.getEditUrlWithoutContext(vreq);
|
||||||
return editUrl + "?subjectUri=" + UrlBuilder.urlEncode(subjectUri) +
|
return editUrl + "?subjectUri=" + UrlBuilder.urlEncode(subjectUri) +
|
||||||
"&predicateUri=" + UrlBuilder.urlEncode(predicateUri) +
|
"&predicateUri=" + UrlBuilder.urlEncode(predicateUri) +
|
||||||
"&editForm=" + UrlBuilder.urlEncode(generatorName);
|
"&editForm=" + UrlBuilder.urlEncode(generatorName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void setVarNames(EditConfigurationVTwo editConfiguration) {
|
private void setVarNames(EditConfigurationVTwo editConfiguration) {
|
||||||
editConfiguration.setVarNameForSubject("subject");
|
editConfiguration.setVarNameForSubject("subject");
|
||||||
editConfiguration.setVarNameForPredicate("predicate");
|
editConfiguration.setVarNameForPredicate("predicate");
|
||||||
editConfiguration.setVarNameForObject("conceptNode");
|
editConfiguration.setVarNameForObject("conceptNode");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setTemplate(EditConfigurationVTwo editConfiguration,
|
protected void setTemplate(EditConfigurationVTwo editConfiguration,
|
||||||
VitroRequest vreq) {
|
VitroRequest vreq) {
|
||||||
editConfiguration.setTemplate(template);
|
editConfiguration.setTemplate(template);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* N3 Required and Optional Generators as well as supporting methods
|
* N3 Required and Optional Generators as well as supporting methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private String getPrefixesString() {
|
private String getPrefixesString() {
|
||||||
//TODO: Include dynamic way of including this
|
//TODO: Include dynamic way of including this
|
||||||
return "@prefix core: <http://vivoweb.org/ontology/core#> .";
|
return "@prefix core: <http://vivoweb.org/ontology/core#> .";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Here, the node is typed as a skos concept
|
//Here, the node is typed as a skos concept
|
||||||
private List<String> generateN3Required(VitroRequest vreq) {
|
private List<String> generateN3Required(VitroRequest vreq) {
|
||||||
List<String> n3Required = list(
|
List<String> n3Required = list(
|
||||||
getPrefixesString() + "\n" +
|
getPrefixesString() + "\n" +
|
||||||
"?subject ?predicate ?conceptNode .\n"
|
"?subject ?predicate ?conceptNode .\n"
|
||||||
);
|
);
|
||||||
List<String> inversePredicate = getInversePredicate(vreq);
|
List<String> inversePredicate = getInversePredicate(vreq);
|
||||||
//Adding inverse predicate if it exists
|
//Adding inverse predicate if it exists
|
||||||
if(inversePredicate.size() > 0) {
|
if(inversePredicate.size() > 0) {
|
||||||
n3Required.add("?conceptNode <" + inversePredicate.get(0) + "> ?subject .");
|
n3Required.add("?conceptNode <" + inversePredicate.get(0) + "> ?subject .");
|
||||||
}
|
}
|
||||||
return n3Required;
|
return n3Required;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Optional b/c user may select an existing SKOS concept
|
//Optional b/c user may select an existing SKOS concept
|
||||||
private List<String> generateN3Optional() {
|
private List<String> generateN3Optional() {
|
||||||
return list(
|
return list(
|
||||||
"?conceptNode <" + VitroVocabulary.RDF_TYPE + "> <" + SKOSConceptType + "> .\n" +
|
"?conceptNode <" + VitroVocabulary.RDF_TYPE + "> <" + SKOSConceptType + "> .\n" +
|
||||||
"?conceptNode <" + label + "> ?conceptLabel ."
|
"?conceptNode <" + label + "> ?conceptLabel ."
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get new resources
|
* Get new resources
|
||||||
*/
|
*/
|
||||||
private Map<String, String> generateNewResources(VitroRequest vreq) {
|
private Map<String, String> generateNewResources(VitroRequest vreq) {
|
||||||
HashMap<String, String> newResources = new HashMap<String, String>();
|
HashMap<String, String> newResources = new HashMap<String, String>();
|
||||||
newResources.put("conceptNode", null);
|
newResources.put("conceptNode", null);
|
||||||
//There are no new resources here, the concept node uri doesn't
|
//There are no new resources here, the concept node uri doesn't
|
||||||
//get created but already exists, and vocab uri should already exist as well
|
//get created but already exists, and vocab uri should already exist as well
|
||||||
return newResources;
|
return newResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set URIS and Literals In Scope and on form and supporting methods
|
* Set URIS and Literals In Scope and on form and supporting methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
||||||
//note that at this point the subject, predicate, and object var parameters have already been processed
|
//note that at this point the subject, predicate, and object var parameters have already been processed
|
||||||
//these two were always set when instantiating an edit configuration object from json,
|
//these two were always set when instantiating an edit configuration object from json,
|
||||||
//although the json itself did not specify subject/predicate as part of uris in scope
|
//although the json itself did not specify subject/predicate as part of uris in scope
|
||||||
urisInScope.put(editConfiguration.getVarNameForSubject(),
|
urisInScope.put(editConfiguration.getVarNameForSubject(),
|
||||||
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
|
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
|
||||||
urisInScope.put(editConfiguration.getVarNameForPredicate(),
|
urisInScope.put(editConfiguration.getVarNameForPredicate(),
|
||||||
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
|
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
|
||||||
//Setting inverse role predicate
|
//Setting inverse role predicate
|
||||||
urisInScope.put("inverseRolePredicate", getInversePredicate(vreq));
|
urisInScope.put("inverseRolePredicate", getInversePredicate(vreq));
|
||||||
|
|
||||||
|
|
||||||
editConfiguration.setUrisInScope(urisInScope);
|
editConfiguration.setUrisInScope(urisInScope);
|
||||||
//Uris in scope include subject, predicate, and object var
|
//Uris in scope include subject, predicate, and object var
|
||||||
//literals in scope empty initially, usually populated by code in prepare for update
|
//literals in scope empty initially, usually populated by code in prepare for update
|
||||||
//with existing values for variables
|
//with existing values for variables
|
||||||
editConfiguration.setLiteralsInScope(new HashMap<String, List<Literal>>());
|
editConfiguration.setLiteralsInScope(new HashMap<String, List<Literal>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getInversePredicate(VitroRequest vreq) {
|
private List<String> getInversePredicate(VitroRequest vreq) {
|
||||||
List<String> inversePredicateArray = new ArrayList<String>();
|
List<String> inversePredicateArray = new ArrayList<String>();
|
||||||
ObjectProperty op = EditConfigurationUtils.getObjectProperty(vreq);
|
ObjectProperty op = EditConfigurationUtils.getObjectProperty(vreq);
|
||||||
if(op != null && op.getURIInverse() != null) {
|
if(op != null && op.getURIInverse() != null) {
|
||||||
inversePredicateArray.add(op.getURIInverse());
|
inversePredicateArray.add(op.getURIInverse());
|
||||||
}
|
}
|
||||||
return inversePredicateArray;
|
return inversePredicateArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
//n3 should look as follows
|
//n3 should look as follows
|
||||||
//?subject ?predicate ?objectVar
|
//?subject ?predicate ?objectVar
|
||||||
|
|
||||||
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
List<String> urisOnForm = new ArrayList<String>();
|
List<String> urisOnForm = new ArrayList<String>();
|
||||||
List<String> literalsOnForm = new ArrayList<String>();
|
List<String> literalsOnForm = new ArrayList<String>();
|
||||||
//The URI of the node that defines the concept
|
//The URI of the node that defines the concept
|
||||||
urisOnForm.add("conceptNode");
|
urisOnForm.add("conceptNode");
|
||||||
editConfiguration.setUrisOnform(urisOnForm);
|
editConfiguration.setUrisOnform(urisOnForm);
|
||||||
//In case the user defines a new concept, will add a concept label
|
//In case the user defines a new concept, will add a concept label
|
||||||
literalsOnForm.add("conceptLabel");
|
literalsOnForm.add("conceptLabel");
|
||||||
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set SPARQL Queries and supporting methods
|
* Set SPARQL Queries and supporting methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
private void setSparqlQueries(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setSparqlQueries(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
//Sparql queries defining retrieval of literals etc.
|
//Sparql queries defining retrieval of literals etc.
|
||||||
editConfiguration.setSparqlForAdditionalLiteralsInScope(new HashMap<String, String>());
|
editConfiguration.setSparqlForAdditionalLiteralsInScope(new HashMap<String, String>());
|
||||||
Map<String, String> urisInScope = new HashMap<String, String>();
|
Map<String, String> urisInScope = new HashMap<String, String>();
|
||||||
editConfiguration.setSparqlForAdditionalUrisInScope(new HashMap<String, String>());
|
editConfiguration.setSparqlForAdditionalUrisInScope(new HashMap<String, String>());
|
||||||
editConfiguration.setSparqlForExistingLiterals(new HashMap<String, String>());
|
editConfiguration.setSparqlForExistingLiterals(new HashMap<String, String>());
|
||||||
editConfiguration.setSparqlForExistingUris(new HashMap<String, String>());
|
editConfiguration.setSparqlForExistingUris(new HashMap<String, String>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Set Fields and supporting methods
|
* Set Fields and supporting methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
|
private void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
|
||||||
setConceptNodeField(editConfiguration, vreq);
|
setConceptNodeField(editConfiguration, vreq);
|
||||||
setConceptLabelField(editConfiguration, vreq);
|
setConceptLabelField(editConfiguration, vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
//this field will be hidden and include the concept node URI
|
//this field will be hidden and include the concept node URI
|
||||||
private void setConceptNodeField(EditConfigurationVTwo editConfiguration,
|
private void setConceptNodeField(EditConfigurationVTwo editConfiguration,
|
||||||
VitroRequest vreq) {
|
VitroRequest vreq) {
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
setName("conceptNode"));
|
setName("conceptNode"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setConceptLabelField(EditConfigurationVTwo editConfiguration,
|
private void setConceptLabelField(EditConfigurationVTwo editConfiguration,
|
||||||
VitroRequest vreq) {
|
VitroRequest vreq) {
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
setName("conceptLabel").
|
setName("conceptLabel").
|
||||||
setValidators(list("datatype:" + XSD.xstring.toString())).
|
setValidators(list("datatype:" + XSD.xstring.toString())).
|
||||||
setRangeDatatypeUri(XSD.xstring.toString())
|
setRangeDatatypeUri(XSD.xstring.toString())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Add preprocessor
|
//Add preprocessor
|
||||||
|
|
||||||
private void addPreprocessors(EditConfigurationVTwo editConfiguration, WebappDaoFactory wadf) {
|
private void addPreprocessors(EditConfigurationVTwo editConfiguration, WebappDaoFactory wadf) {
|
||||||
//Will be a completely different type of preprocessor
|
//Will be a completely different type of preprocessor
|
||||||
/*
|
/*
|
||||||
editConfiguration.addEditSubmissionPreprocessor(
|
editConfiguration.addEditSubmissionPreprocessor(
|
||||||
new RoleToActivityPredicatePreprocessor(editConfiguration, wadf));
|
new RoleToActivityPredicatePreprocessor(editConfiguration, wadf));
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Form specific data
|
//Form specific data
|
||||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||||
formSpecificData.put("sparqlForAcFilter", getSparqlForAcFilter(vreq));
|
formSpecificData.put("sparqlForAcFilter", getSparqlForAcFilter(vreq));
|
||||||
formSpecificData.put("conceptType", SKOSConceptType);
|
formSpecificData.put("conceptType", SKOSConceptType);
|
||||||
editConfiguration.setFormSpecificData(formSpecificData);
|
editConfiguration.setFormSpecificData(formSpecificData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getSparqlForAcFilter(VitroRequest vreq) {
|
public String getSparqlForAcFilter(VitroRequest vreq) {
|
||||||
String subject = EditConfigurationUtils.getSubjectUri(vreq);
|
String subject = EditConfigurationUtils.getSubjectUri(vreq);
|
||||||
String predicate = EditConfigurationUtils.getPredicateUri(vreq);
|
String predicate = EditConfigurationUtils.getPredicateUri(vreq);
|
||||||
String query = "PREFIX core:<" + vivoCore + "> " +
|
String query = "PREFIX core:<" + vivoCore + "> " +
|
||||||
"SELECT ?conceptNode WHERE { " +
|
"SELECT ?conceptNode WHERE { " +
|
||||||
"<" + subject + "> <" + predicate + "> ?conceptNode ." +
|
"<" + subject + "> <" + predicate + "> ?conceptNode ." +
|
||||||
"?conceptNode <" + VitroVocabulary.RDF_TYPE + "> <" + SKOSConceptType + "> . }";
|
"?conceptNode <" + VitroVocabulary.RDF_TYPE + "> <" + SKOSConceptType + "> . }";
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
//skos concepts can be added for either research areas or subject areas
|
//skos concepts can be added for either research areas or subject areas
|
||||||
//IF coming in from a different form then can get the predicate here as it will be stored
|
//IF coming in from a different form then can get the predicate here as it will be stored
|
||||||
public String getCurrentPredicate(VitroRequest vreq) {
|
public String getCurrentPredicate(VitroRequest vreq) {
|
||||||
return vreq.getParameter("conceptPredicate");
|
return vreq.getParameter("conceptPredicate");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,67 +1,67 @@
|
||||||
|
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
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 edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the edit configuration for a default property form.
|
* Generates the edit configuration for a default property form.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class AutocompleteDataPropertyFormGenerator extends DefaultDataPropertyFormGenerator {
|
public class AutocompleteDataPropertyFormGenerator extends DefaultDataPropertyFormGenerator {
|
||||||
|
|
||||||
//The only thing that changes here are the templates
|
//The only thing that changes here are the templates
|
||||||
private Log log = LogFactory.getLog(AutocompleteObjectPropertyFormGenerator.class);
|
private Log log = LogFactory.getLog(AutocompleteObjectPropertyFormGenerator.class);
|
||||||
private String dataPropertyTemplate = "autoCompleteDataPropForm.ftl";
|
private String dataPropertyTemplate = "autoCompleteDataPropForm.ftl";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
|
||||||
EditConfigurationVTwo ec = super.getEditConfiguration(vreq, session);
|
EditConfigurationVTwo ec = super.getEditConfiguration(vreq, session);
|
||||||
this.addFormSpecificData(ec, vreq);
|
this.addFormSpecificData(ec, vreq);
|
||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||||
//Filter setting - i.e. sparql query for filtering out results from autocomplete
|
//Filter setting - i.e. sparql query for filtering out results from autocomplete
|
||||||
formSpecificData.put("sparqlForAcFilter", getSparqlForAcFilter(vreq));
|
formSpecificData.put("sparqlForAcFilter", getSparqlForAcFilter(vreq));
|
||||||
editConfiguration.setTemplate(dataPropertyTemplate);
|
editConfiguration.setTemplate(dataPropertyTemplate);
|
||||||
//Add edit model
|
//Add edit model
|
||||||
formSpecificData.put("editMode", getEditMode(vreq));
|
formSpecificData.put("editMode", getEditMode(vreq));
|
||||||
editConfiguration.setFormSpecificData(formSpecificData);
|
editConfiguration.setFormSpecificData(formSpecificData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSparqlForAcFilter(VitroRequest vreq) {
|
public String getSparqlForAcFilter(VitroRequest vreq) {
|
||||||
String subject = EditConfigurationUtils.getSubjectUri(vreq);
|
String subject = EditConfigurationUtils.getSubjectUri(vreq);
|
||||||
String predicate = EditConfigurationUtils.getPredicateUri(vreq);
|
String predicate = EditConfigurationUtils.getPredicateUri(vreq);
|
||||||
//Get all objects for existing predicate, filters out results from addition and edit
|
//Get all objects for existing predicate, filters out results from addition and edit
|
||||||
String query = "SELECT ?dataLiteral WHERE { " +
|
String query = "SELECT ?dataLiteral WHERE { " +
|
||||||
"<" + subject + "> <" + predicate + "> ?dataLiteral .} ";
|
"<" + subject + "> <" + predicate + "> ?dataLiteral .} ";
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get edit mode
|
//Get edit mode
|
||||||
public String getEditMode(VitroRequest vreq) {
|
public String getEditMode(VitroRequest vreq) {
|
||||||
if(isUpdate(vreq))
|
if(isUpdate(vreq))
|
||||||
return "edit";
|
return "edit";
|
||||||
else
|
else
|
||||||
return "add";
|
return "add";
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isUpdate(VitroRequest vreq) {
|
private boolean isUpdate(VitroRequest vreq) {
|
||||||
Integer dataHash = EditConfigurationUtils.getDataHash(vreq);
|
Integer dataHash = EditConfigurationUtils.getDataHash(vreq);
|
||||||
return ( dataHash != null );
|
return ( dataHash != null );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,42 +16,42 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
|
||||||
|
|
||||||
public class GrantAdministeredByGenerator extends VivoBaseGenerator implements
|
public class GrantAdministeredByGenerator extends VivoBaseGenerator implements
|
||||||
EditConfigurationGenerator {
|
EditConfigurationGenerator {
|
||||||
|
|
||||||
public GrantAdministeredByGenerator() {}
|
public GrantAdministeredByGenerator() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
HttpSession session) throws Exception {
|
HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
|
|
||||||
conf.setTemplate("grantAdministeredBy.ftl");
|
conf.setTemplate("grantAdministeredBy.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("grant");
|
conf.setVarNameForSubject("grant");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("adminRole");
|
conf.setVarNameForObject("adminRole");
|
||||||
|
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewAdminRole) );
|
conf.setN3Required( Arrays.asList( n3ForNewAdminRole) );
|
||||||
conf.setN3Optional( Arrays.asList( n3ForNewAdminOrganization,
|
conf.setN3Optional( Arrays.asList( n3ForNewAdminOrganization,
|
||||||
n3ForExistingAdminOrganization ) );
|
n3ForExistingAdminOrganization ) );
|
||||||
|
|
||||||
conf.addNewResource("newOrganization", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("newOrganization", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("adminRole", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("adminRole", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
conf.setUrisOnform(Arrays.asList("existingOrganization"));
|
conf.setUrisOnform(Arrays.asList("existingOrganization"));
|
||||||
conf.setLiteralsOnForm(Arrays.asList("orgLabel", "orgLabelDisplay" ));
|
conf.setLiteralsOnForm(Arrays.asList("orgLabel", "orgLabelDisplay" ));
|
||||||
|
|
||||||
conf.addSparqlForExistingLiteral("orgLabel", orgLabelQuery);
|
conf.addSparqlForExistingLiteral("orgLabel", orgLabelQuery);
|
||||||
conf.addSparqlForExistingUris("existingOrganization", existingOrganizationQuery);
|
conf.addSparqlForExistingUris("existingOrganization", existingOrganizationQuery);
|
||||||
|
|
||||||
|
|
||||||
conf.addField( new FieldVTwo(). // options will be added in browser by auto complete JS
|
conf.addField( new FieldVTwo(). // options will be added in browser by auto complete JS
|
||||||
setName("existingOrganization")
|
setName("existingOrganization")
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("orgLabel").
|
setName("orgLabel").
|
||||||
|
@ -67,7 +67,7 @@ public class GrantAdministeredByGenerator extends VivoBaseGenerator implements
|
||||||
|
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
conf.addValidator(new AutocompleteRequiredInputValidator("existingOrganization", "orgLabel"));
|
conf.addValidator(new AutocompleteRequiredInputValidator("existingOrganization", "orgLabel"));
|
||||||
|
|
||||||
// addFormSpecificData(conf, vreq);
|
// addFormSpecificData(conf, vreq);
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
|
@ -75,29 +75,29 @@ public class GrantAdministeredByGenerator extends VivoBaseGenerator implements
|
||||||
|
|
||||||
/* N3 assertions */
|
/* N3 assertions */
|
||||||
|
|
||||||
final static String n3ForNewAdminRole =
|
final static String n3ForNewAdminRole =
|
||||||
"@prefix vivo: <" + vivoCore + "> . \n" +
|
"@prefix vivo: <" + vivoCore + "> . \n" +
|
||||||
"?grant vivo:relates ?adminRole . \n" +
|
"?grant vivo:relates ?adminRole . \n" +
|
||||||
"?adminRole a vivo:AdministratorRole . \n" +
|
"?adminRole a vivo:AdministratorRole . \n" +
|
||||||
"?adminRole vivo:relatedBy ?grant . " ;
|
"?adminRole vivo:relatedBy ?grant . " ;
|
||||||
|
|
||||||
final static String n3ForNewAdminOrganization =
|
final static String n3ForNewAdminOrganization =
|
||||||
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
||||||
"?adminRole <http://purl.obolibrary.org/obo/RO_0000052> ?newOrganization . \n" +
|
"?adminRole <http://purl.obolibrary.org/obo/RO_0000052> ?newOrganization . \n" +
|
||||||
"?newOrganization a <http://xmlns.com/foaf/0.1/Organization> . \n" +
|
"?newOrganization a <http://xmlns.com/foaf/0.1/Organization> . \n" +
|
||||||
"?newOrganization <http://purl.obolibrary.org/obo/RO_0000053> ?adminRole . \n" +
|
"?newOrganization <http://purl.obolibrary.org/obo/RO_0000053> ?adminRole . \n" +
|
||||||
"?newOrganization vivo:relatedBy ?grant . \n" +
|
"?newOrganization vivo:relatedBy ?grant . \n" +
|
||||||
"?grant vivo:relates ?newOrganization . \n" +
|
"?grant vivo:relates ?newOrganization . \n" +
|
||||||
"?newOrganization <"+ label + "> ?orgLabel .";
|
"?newOrganization <"+ label + "> ?orgLabel .";
|
||||||
|
|
||||||
final static String n3ForExistingAdminOrganization =
|
final static String n3ForExistingAdminOrganization =
|
||||||
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
||||||
"?adminRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingOrganization . \n" +
|
"?adminRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingOrganization . \n" +
|
||||||
"?existingOrganization a <http://xmlns.com/foaf/0.1/Organization> . \n" +
|
"?existingOrganization a <http://xmlns.com/foaf/0.1/Organization> . \n" +
|
||||||
"?existingOrganization <http://purl.obolibrary.org/obo/RO_0000053> ?adminRole . " +
|
"?existingOrganization <http://purl.obolibrary.org/obo/RO_0000053> ?adminRole . " +
|
||||||
"?existingOrganization vivo:relatedBy ?grant . \n" +
|
"?existingOrganization vivo:relatedBy ?grant . \n" +
|
||||||
"?grant vivo:relates ?existingOrganization . \n" ;
|
"?grant vivo:relates ?existingOrganization . \n" ;
|
||||||
|
|
||||||
/* Queries for editing an existing entry */
|
/* Queries for editing an existing entry */
|
||||||
|
|
||||||
final static String existingOrganizationQuery =
|
final static String existingOrganizationQuery =
|
||||||
|
|
|
@ -20,35 +20,35 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
|
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
|
||||||
|
|
||||||
public class GrantHasContributorGenerator extends VivoBaseGenerator implements EditConfigurationGenerator{
|
public class GrantHasContributorGenerator extends VivoBaseGenerator implements EditConfigurationGenerator{
|
||||||
|
|
||||||
// NOTE: This generator is for contract as well as grants.
|
// NOTE: This generator is for contract as well as grants.
|
||||||
//TODO: can we get rid of the session and get it form the vreq?
|
//TODO: can we get rid of the session and get it form the vreq?
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) throws Exception {
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
|
|
||||||
conf.setTemplate("grantHasContributor.ftl");
|
conf.setTemplate("grantHasContributor.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("subject");
|
conf.setVarNameForSubject("subject");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("theRole");
|
conf.setVarNameForObject("theRole");
|
||||||
|
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewProjectRole, roleTypeAssertion ) );
|
conf.setN3Required( Arrays.asList( n3ForNewProjectRole, roleTypeAssertion ) );
|
||||||
conf.setN3Optional(Arrays.asList( n3ForNewPerson, n3ForExistingPerson, firstNameAssertion, lastNameAssertion ) );
|
conf.setN3Optional(Arrays.asList( n3ForNewPerson, n3ForExistingPerson, firstNameAssertion, lastNameAssertion ) );
|
||||||
|
|
||||||
conf.addNewResource("theRole", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("theRole", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("newPerson",DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("newPerson",DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("vcardPerson", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("vcardPerson", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("vcardName", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("vcardName", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
//uris in scope: none
|
//uris in scope: none
|
||||||
//literals in scope: none
|
//literals in scope: none
|
||||||
|
|
||||||
conf.setUrisOnform( Arrays.asList( "existingPerson", "roleType"));
|
conf.setUrisOnform( Arrays.asList( "existingPerson", "roleType"));
|
||||||
conf.setLiteralsOnForm( Arrays.asList("personLabel", "personLabelDisplay", "firstName", "lastName"));
|
conf.setLiteralsOnForm( Arrays.asList("personLabel", "personLabelDisplay", "firstName", "lastName"));
|
||||||
|
|
||||||
|
@ -56,12 +56,12 @@ public class GrantHasContributorGenerator extends VivoBaseGenerator implements
|
||||||
|
|
||||||
conf.addSparqlForExistingUris("existingPerson", existingPersonQuery);
|
conf.addSparqlForExistingUris("existingPerson", existingPersonQuery);
|
||||||
conf.addSparqlForExistingUris("roleType", roleTypeQuery);
|
conf.addSparqlForExistingUris("roleType", roleTypeQuery);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("existingPerson")
|
setName("existingPerson")
|
||||||
//options will be added in browser by auto complete JS
|
//options will be added in browser by auto complete JS
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("personLabel").
|
setName("personLabel").
|
||||||
setRangeDatatypeUri(XSD.xstring.toString() ).
|
setRangeDatatypeUri(XSD.xstring.toString() ).
|
||||||
|
@ -82,27 +82,27 @@ public class GrantHasContributorGenerator extends VivoBaseGenerator implements
|
||||||
setRangeDatatypeUri(XSD.xstring.toString() ).
|
setRangeDatatypeUri(XSD.xstring.toString() ).
|
||||||
setValidators( list("datatype:" + XSD.xstring.toString()) )
|
setValidators( list("datatype:" + XSD.xstring.toString()) )
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("roleType").
|
setName("roleType").
|
||||||
setValidators( list("nonempty") ).
|
setValidators( list("nonempty") ).
|
||||||
setOptions(
|
setOptions(
|
||||||
new ChildVClassesWithParent("http://vivoweb.org/ontology/core#ResearcherRole")));
|
new ChildVClassesWithParent("http://vivoweb.org/ontology/core#ResearcherRole")));
|
||||||
|
|
||||||
|
|
||||||
//Add validator
|
//Add validator
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
conf.addValidator(new FirstAndLastNameValidator("existingPerson"));
|
conf.addValidator(new FirstAndLastNameValidator("existingPerson"));
|
||||||
|
|
||||||
//Adding additional data, specifically edit mode
|
//Adding additional data, specifically edit mode
|
||||||
addFormSpecificData(conf, vreq);
|
addFormSpecificData(conf, vreq);
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* N3 assertions for working with educational training */
|
/* N3 assertions for working with educational training */
|
||||||
|
|
||||||
final static String n3ForNewProjectRole =
|
final static String n3ForNewProjectRole =
|
||||||
"@prefix core: <"+ vivoCore +"> .\n" +
|
"@prefix core: <"+ vivoCore +"> .\n" +
|
||||||
"@prefix rdfs: <"+ rdfs +"> . \n"+
|
"@prefix rdfs: <"+ rdfs +"> . \n"+
|
||||||
"?subject core:relates ?theRole .\n" +
|
"?subject core:relates ?theRole .\n" +
|
||||||
|
@ -111,7 +111,7 @@ public class GrantHasContributorGenerator extends VivoBaseGenerator implements
|
||||||
final static String roleTypeAssertion =
|
final static String roleTypeAssertion =
|
||||||
"?theRole a ?roleType .";
|
"?theRole a ?roleType .";
|
||||||
|
|
||||||
final static String n3ForNewPerson =
|
final static String n3ForNewPerson =
|
||||||
"@prefix core: <"+ vivoCore +"> .\n" +
|
"@prefix core: <"+ vivoCore +"> .\n" +
|
||||||
"?theRole <http://purl.obolibrary.org/obo/RO_0000052> ?newPerson . \n" +
|
"?theRole <http://purl.obolibrary.org/obo/RO_0000052> ?newPerson . \n" +
|
||||||
"?newPerson <http://purl.obolibrary.org/obo/RO_0000053> ?theRole . \n" +
|
"?newPerson <http://purl.obolibrary.org/obo/RO_0000053> ?theRole . \n" +
|
||||||
|
@ -120,40 +120,40 @@ public class GrantHasContributorGenerator extends VivoBaseGenerator implements
|
||||||
"?newPerson a <http://xmlns.com/foaf/0.1/Person> . \n" +
|
"?newPerson a <http://xmlns.com/foaf/0.1/Person> . \n" +
|
||||||
"?newPerson <"+ label +"> ?personLabel . ";
|
"?newPerson <"+ label +"> ?personLabel . ";
|
||||||
|
|
||||||
final static String n3ForExistingPerson =
|
final static String n3ForExistingPerson =
|
||||||
"@prefix core: <"+ vivoCore +"> .\n" +
|
"@prefix core: <"+ vivoCore +"> .\n" +
|
||||||
"?theRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingPerson . \n" +
|
"?theRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingPerson . \n" +
|
||||||
"?existingPerson <http://purl.obolibrary.org/obo/RO_0000053> ?theRole . \n" +
|
"?existingPerson <http://purl.obolibrary.org/obo/RO_0000053> ?theRole . \n" +
|
||||||
"?subject core:relates ?newPerson . \n" +
|
"?subject core:relates ?newPerson . \n" +
|
||||||
"?newPerson core:relatedBy ?subject . \n" +
|
"?newPerson core:relatedBy ?subject . \n" +
|
||||||
" ";
|
" ";
|
||||||
|
|
||||||
final static String firstNameAssertion =
|
final static String firstNameAssertion =
|
||||||
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
||||||
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
||||||
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
||||||
"?vcardName vcard:givenName ?firstName .";
|
"?vcardName vcard:givenName ?firstName .";
|
||||||
|
|
||||||
final static String lastNameAssertion =
|
final static String lastNameAssertion =
|
||||||
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
||||||
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
||||||
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
||||||
"?vcardName vcard:familyName ?lastName .";
|
"?vcardName vcard:familyName ?lastName .";
|
||||||
|
|
||||||
/* Queries for editing an existing educational training entry */
|
/* Queries for editing an existing educational training entry */
|
||||||
|
|
||||||
final static String roleTypeQuery =
|
final static String roleTypeQuery =
|
||||||
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
||||||
"SELECT ?roleType WHERE { \n" +
|
"SELECT ?roleType WHERE { \n" +
|
||||||
" ?theRole vitro:mostSpecificType ?roleType . }";
|
" ?theRole vitro:mostSpecificType ?roleType . }";
|
||||||
|
|
||||||
final static String existingPersonQuery =
|
final static String existingPersonQuery =
|
||||||
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
||||||
"SELECT ?existingPerson WHERE {\n"+
|
"SELECT ?existingPerson WHERE {\n"+
|
||||||
"?theRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingPerson . \n" +
|
"?theRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingPerson . \n" +
|
||||||
|
@ -161,7 +161,7 @@ public class GrantHasContributorGenerator extends VivoBaseGenerator implements
|
||||||
"?existingPerson a <http://xmlns.com/foaf/0.1/Person> . \n " +
|
"?existingPerson a <http://xmlns.com/foaf/0.1/Person> . \n " +
|
||||||
" }";
|
" }";
|
||||||
|
|
||||||
final static String personLabelQuery =
|
final static String personLabelQuery =
|
||||||
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
||||||
"SELECT ?existingPersonLabel WHERE {\n"+
|
"SELECT ?existingPersonLabel WHERE {\n"+
|
||||||
"?theRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingPerson . \n" +
|
"?theRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingPerson . \n" +
|
||||||
|
@ -170,14 +170,14 @@ public class GrantHasContributorGenerator extends VivoBaseGenerator implements
|
||||||
"?existingPerson a <http://xmlns.com/foaf/0.1/Person> . \n " +
|
"?existingPerson a <http://xmlns.com/foaf/0.1/Person> . \n " +
|
||||||
" }";
|
" }";
|
||||||
|
|
||||||
|
|
||||||
//Adding form specific data such as edit mode
|
//Adding form specific data such as edit mode
|
||||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||||
formSpecificData.put("editMode", getEditMode(vreq).name().toLowerCase());
|
formSpecificData.put("editMode", getEditMode(vreq).name().toLowerCase());
|
||||||
editConfiguration.setFormSpecificData(formSpecificData);
|
editConfiguration.setFormSpecificData(formSpecificData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EditMode getEditMode(VitroRequest vreq) {
|
public EditMode getEditMode(VitroRequest vreq) {
|
||||||
List<String> predicates = new ArrayList<String>();
|
List<String> predicates = new ArrayList<String>();
|
||||||
predicates.add("http://purl.obolibrary.org/obo/RO_0000053");
|
predicates.add("http://purl.obolibrary.org/obo/RO_0000053");
|
||||||
|
|
|
@ -46,7 +46,7 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.DataProper
|
||||||
/**
|
/**
|
||||||
* This generator is specifically for handling labels for a FOAF Person individual and is an object property form.
|
* This generator is specifically for handling labels for a FOAF Person individual and is an object property form.
|
||||||
*This allows the page to show all the labels for a particular individual and sets up code
|
*This allows the page to show all the labels for a particular individual and sets up code
|
||||||
*enabling the addition of a new label. Links on the page will allow for removal or editing of a given label.
|
*enabling the addition of a new label. Links on the page will allow for removal or editing of a given label.
|
||||||
*/
|
*/
|
||||||
public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
||||||
public static Log log = LogFactory.getLog(ManageLabelsForIndividualGenerator.class);
|
public static Log log = LogFactory.getLog(ManageLabelsForIndividualGenerator.class);
|
||||||
|
@ -68,13 +68,13 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
//be employed when the 'add' button is used, we will set this is an object property form
|
//be employed when the 'add' button is used, we will set this is an object property form
|
||||||
//although label will mean we need to add a data property statement as well
|
//although label will mean we need to add a data property statement as well
|
||||||
//URL to return to is the same page once addition is complete
|
//URL to return to is the same page once addition is complete
|
||||||
initObjectPropForm(config, vreq);
|
initObjectPropForm(config, vreq);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.setUrlToReturnTo(config, vreq);
|
this.setUrlToReturnTo(config, vreq);
|
||||||
|
|
||||||
config.setSubjectUri(EditConfigurationUtils.getSubjectUri(vreq));
|
config.setSubjectUri(EditConfigurationUtils.getSubjectUri(vreq));
|
||||||
|
|
||||||
setVarNames(config);
|
setVarNames(config);
|
||||||
//config.setDatapropKey( EditConfigurationUtils.getDataHash(vreq) );
|
//config.setDatapropKey( EditConfigurationUtils.getDataHash(vreq) );
|
||||||
//Add n3, fields, etc. in the case where the user wants to add a label
|
//Add n3, fields, etc. in the case where the user wants to add a label
|
||||||
|
@ -86,10 +86,10 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
this.setUrisAndLiteralsInScope(config);
|
this.setUrisAndLiteralsInScope(config);
|
||||||
this.setFields(config, vreq, EditConfigurationUtils
|
this.setFields(config, vreq, EditConfigurationUtils
|
||||||
.getPredicateUri(vreq));
|
.getPredicateUri(vreq));
|
||||||
|
|
||||||
//Get existing labels
|
//Get existing labels
|
||||||
//this.initExistingLabels(config, vreq);
|
//this.initExistingLabels(config, vreq);
|
||||||
|
|
||||||
//Add form specific data used to populate template
|
//Add form specific data used to populate template
|
||||||
addFormSpecificData(config, vreq);
|
addFormSpecificData(config, vreq);
|
||||||
//This preprocessor handles getting the correct label language and putting the attribute on the label
|
//This preprocessor handles getting the correct label language and putting the attribute on the label
|
||||||
|
@ -97,24 +97,24 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
new ManageLabelsForPersonPreprocessor(config));
|
new ManageLabelsForPersonPreprocessor(config));
|
||||||
//This will handle generating the label from the first name, middle, and last names and also make sure to associate
|
//This will handle generating the label from the first name, middle, and last names and also make sure to associate
|
||||||
//a language with that label
|
//a language with that label
|
||||||
config.addModelChangePreprocessor(new FoafNameToRdfsLabelPreprocessor());
|
config.addModelChangePreprocessor(new FoafNameToRdfsLabelPreprocessor());
|
||||||
|
|
||||||
prepare(vreq, config);
|
prepare(vreq, config);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**With ISF Changes**/
|
/**With ISF Changes**/
|
||||||
//For addition of a label, with ISF changes, the name is now linked to a vcard which in turn is linked to a "fullname" that then has first/middle/last names
|
//For addition of a label, with ISF changes, the name is now linked to a vcard which in turn is linked to a "fullname" that then has first/middle/last names
|
||||||
|
|
||||||
private void addNewResources(EditConfigurationVTwo config) {
|
private void addNewResources(EditConfigurationVTwo config) {
|
||||||
config.addNewResource("fullName", DEFAULT_NS_FOR_NEW_RESOURCE);
|
config.addNewResource("fullName", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
config.addNewResource("individualVcard", DEFAULT_NS_FOR_NEW_RESOURCE);
|
config.addNewResource("individualVcard", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUrlToReturnTo(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setUrlToReturnTo(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
editConfiguration.setUrlPatternToReturnTo(EditConfigurationUtils.getFormUrlWithoutContext(vreq));
|
editConfiguration.setUrlPatternToReturnTo(EditConfigurationUtils.getFormUrlWithoutContext(vreq));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setVarNames(EditConfigurationVTwo editConfiguration) {
|
private void setVarNames(EditConfigurationVTwo editConfiguration) {
|
||||||
editConfiguration.setVarNameForSubject("subject");
|
editConfiguration.setVarNameForSubject("subject");
|
||||||
editConfiguration.setVarNameForPredicate("predicate");
|
editConfiguration.setVarNameForPredicate("predicate");
|
||||||
|
@ -129,29 +129,29 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
|
|
||||||
private List<String> generateN3Optional(VitroRequest vreq) {
|
private List<String> generateN3Optional(VitroRequest vreq) {
|
||||||
List<String> n3Optional = new ArrayList<String>();
|
List<String> n3Optional = new ArrayList<String>();
|
||||||
|
|
||||||
String personFullNameN3 = this.N3_PREFIX +
|
String personFullNameN3 = this.N3_PREFIX +
|
||||||
"?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
"?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
||||||
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?subject . \n" +
|
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?subject . \n" +
|
||||||
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasName> ?fullName . \n" +
|
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasName> ?fullName . \n" +
|
||||||
"?fullName a <http://www.w3.org/2006/vcard/ns#Name> .";
|
"?fullName a <http://www.w3.org/2006/vcard/ns#Name> .";
|
||||||
String personFirstNameN3 =
|
String personFirstNameN3 =
|
||||||
"?fullName <http://www.w3.org/2006/vcard/ns#givenName> ?firstName . ";
|
"?fullName <http://www.w3.org/2006/vcard/ns#givenName> ?firstName . ";
|
||||||
String personLastNameN3 =
|
String personLastNameN3 =
|
||||||
"?fullName <http://www.w3.org/2006/vcard/ns#familyName> ?lastName .";
|
"?fullName <http://www.w3.org/2006/vcard/ns#familyName> ?lastName .";
|
||||||
String personMiddleNameN3 = "?subject <http://vivoweb.org/ontology/core#middleName> ?middleName .";
|
String personMiddleNameN3 = "?subject <http://vivoweb.org/ontology/core#middleName> ?middleName .";
|
||||||
n3Optional.add(personFullNameN3 + "\n " + personFirstNameN3 + "\n " + personLastNameN3);
|
n3Optional.add(personFullNameN3 + "\n " + personFirstNameN3 + "\n " + personLastNameN3);
|
||||||
n3Optional.add(personMiddleNameN3);
|
n3Optional.add(personMiddleNameN3);
|
||||||
return n3Optional;
|
return n3Optional;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
|
private void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
|
||||||
Map<String, FieldVTwo> fields = new HashMap<String, FieldVTwo>();
|
Map<String, FieldVTwo> fields = new HashMap<String, FieldVTwo>();
|
||||||
editConfiguration.setFields(fields);
|
editConfiguration.setFields(fields);
|
||||||
|
|
||||||
editConfiguration.addField(new FieldVTwo(
|
editConfiguration.addField(new FieldVTwo(
|
||||||
).setName("newLabelLanguage"));
|
).setName("newLabelLanguage"));
|
||||||
//no validators since all of this is optional
|
//no validators since all of this is optional
|
||||||
|
@ -161,41 +161,41 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
setValidators(getFirstNameValidators(vreq, editConfiguration)));
|
setValidators(getFirstNameValidators(vreq, editConfiguration)));
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
setName("middleName").
|
setName("middleName").
|
||||||
setValidators(getMiddleNameValidators(vreq, editConfiguration)));
|
setValidators(getMiddleNameValidators(vreq, editConfiguration)));
|
||||||
|
|
||||||
editConfiguration.addField(new FieldVTwo().
|
editConfiguration.addField(new FieldVTwo().
|
||||||
setName("lastName").
|
setName("lastName").
|
||||||
setValidators(getLastNameValidators(vreq, editConfiguration)));
|
setValidators(getLastNameValidators(vreq, editConfiguration)));
|
||||||
|
|
||||||
//With ISF Changes, also include middle name
|
//With ISF Changes, also include middle name
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//first and last name have validators if is person is true
|
//first and last name have validators if is person is true
|
||||||
private List<String> getFirstNameValidators(VitroRequest vreq, EditConfigurationVTwo config) {
|
private List<String> getFirstNameValidators(VitroRequest vreq, EditConfigurationVTwo config) {
|
||||||
List<String> validators = new ArrayList<String>();
|
List<String> validators = new ArrayList<String>();
|
||||||
validators.add("nonempty");
|
validators.add("nonempty");
|
||||||
|
|
||||||
return validators;
|
return validators;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getMiddleNameValidators(VitroRequest vreq, EditConfigurationVTwo config) {
|
private List<String> getMiddleNameValidators(VitroRequest vreq, EditConfigurationVTwo config) {
|
||||||
List<String> validators = new ArrayList<String>();
|
List<String> validators = new ArrayList<String>();
|
||||||
|
|
||||||
return validators;
|
return validators;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getLastNameValidators(VitroRequest vreq, EditConfigurationVTwo config) {
|
private List<String> getLastNameValidators(VitroRequest vreq, EditConfigurationVTwo config) {
|
||||||
List<String> validators = new ArrayList<String>();
|
List<String> validators = new ArrayList<String>();
|
||||||
validators.add("nonempty");
|
validators.add("nonempty");
|
||||||
|
|
||||||
return validators;
|
return validators;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo config,
|
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo config,
|
||||||
VitroRequest vreq) {
|
VitroRequest vreq) {
|
||||||
List<String> literalsOnForm = new ArrayList<String>();
|
List<String> literalsOnForm = new ArrayList<String>();
|
||||||
|
@ -205,29 +205,29 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
literalsOnForm.add("lastName");
|
literalsOnForm.add("lastName");
|
||||||
literalsOnForm.add("middleName");
|
literalsOnForm.add("middleName");
|
||||||
config.setLiteralsOnForm(literalsOnForm);
|
config.setLiteralsOnForm(literalsOnForm);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration) {
|
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration) {
|
||||||
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
||||||
//note that at this point the subject, predicate, and object var parameters have already been processed
|
//note that at this point the subject, predicate, and object var parameters have already been processed
|
||||||
urisInScope.put(editConfiguration.getVarNameForSubject(),
|
urisInScope.put(editConfiguration.getVarNameForSubject(),
|
||||||
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
|
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
|
||||||
urisInScope.put(editConfiguration.getVarNameForPredicate(),
|
urisInScope.put(editConfiguration.getVarNameForPredicate(),
|
||||||
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
|
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
|
||||||
editConfiguration.setUrisInScope(urisInScope);
|
editConfiguration.setUrisInScope(urisInScope);
|
||||||
//Uris in scope include subject, predicate, and object var
|
//Uris in scope include subject, predicate, and object var
|
||||||
|
|
||||||
editConfiguration.setLiteralsInScope(new HashMap<String, List<Literal>>());
|
editConfiguration.setLiteralsInScope(new HashMap<String, List<Literal>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initExistingLabels(EditConfigurationVTwo config,
|
private void initExistingLabels(EditConfigurationVTwo config,
|
||||||
VitroRequest vreq) {
|
VitroRequest vreq) {
|
||||||
this.existingLabelLiterals = this.getExistingLabels(config.getSubjectUri(), vreq);
|
this.existingLabelLiterals = this.getExistingLabels(config.getSubjectUri(), vreq);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<String> getExistingSortedLanguageNamesList() {
|
private List<String> getExistingSortedLanguageNamesList() {
|
||||||
HashSet<String> existingLanguages = new HashSet<String>();
|
HashSet<String> existingLanguages = new HashSet<String>();
|
||||||
|
@ -258,7 +258,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
//Get available locales for the drop down for adding a new label, also sorted by language name
|
//Get available locales for the drop down for adding a new label, also sorted by language name
|
||||||
HashSet<String> existingLanguageNames = new HashSet<String>(existingLabelsByLanguageName.keySet());
|
HashSet<String> existingLanguageNames = new HashSet<String>(existingLabelsByLanguageName.keySet());
|
||||||
List<HashMap<String, String>> availableLocalesForAdd = getAvailableLocales(locales, existingLanguageNames);
|
List<HashMap<String, String>> availableLocalesForAdd = getAvailableLocales(locales, existingLanguageNames);
|
||||||
|
|
||||||
|
|
||||||
//Save all locales
|
//Save all locales
|
||||||
config.addFormSpecificData("selectLocaleFullList", locales);
|
config.addFormSpecificData("selectLocaleFullList", locales);
|
||||||
|
@ -266,27 +266,27 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
config.addFormSpecificData("labelsSortedByLanguageName", existingLabelsByLanguageName);
|
config.addFormSpecificData("labelsSortedByLanguageName", existingLabelsByLanguageName);
|
||||||
config.addFormSpecificData("selectLocale",availableLocalesForAdd);
|
config.addFormSpecificData("selectLocale",availableLocalesForAdd);
|
||||||
config.addFormSpecificData("displayRemoveLink", (numberExistingLabels > 1));
|
config.addFormSpecificData("displayRemoveLink", (numberExistingLabels > 1));
|
||||||
|
|
||||||
|
|
||||||
//How do we edit? Will need to see
|
|
||||||
config.addFormSpecificData("deleteWebpageUrl", "/edit/primitiveDelete");
|
|
||||||
|
|
||||||
|
|
||||||
|
//How do we edit? Will need to see
|
||||||
|
config.addFormSpecificData("deleteWebpageUrl", "/edit/primitiveDelete");
|
||||||
|
|
||||||
|
|
||||||
Individual subject = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(config.getSubjectUri());
|
Individual subject = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(config.getSubjectUri());
|
||||||
if( subject != null && subject.getName() != null ){
|
if( subject != null && subject.getName() != null ){
|
||||||
config.addFormSpecificData("subjectName", subject.getName());
|
config.addFormSpecificData("subjectName", subject.getName());
|
||||||
}else{
|
}else{
|
||||||
config.addFormSpecificData("subjectName", null);
|
config.addFormSpecificData("subjectName", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
config.addFormSpecificData("isPersonType", "true");
|
config.addFormSpecificData("isPersonType", "true");
|
||||||
//Include whether or not editable to enable edit/remove links and add to show up
|
//Include whether or not editable to enable edit/remove links and add to show up
|
||||||
config.addFormSpecificData("editable", isEditable(vreq, config));
|
config.addFormSpecificData("editable", isEditable(vreq, config));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Based on what locales have already been selected for labels, return a list of
|
|
||||||
|
//Based on what locales have already been selected for labels, return a list of
|
||||||
//locales for which new labels can be added and have these sorted by the name of the language
|
//locales for which new labels can be added and have these sorted by the name of the language
|
||||||
private List<HashMap<String, String>> getAvailableLocales(List<HashMap<String, String>> allLocales,
|
private List<HashMap<String, String>> getAvailableLocales(List<HashMap<String, String>> allLocales,
|
||||||
HashSet<String> existingLabelsLanguageNames) {
|
HashSet<String> existingLabelsLanguageNames) {
|
||||||
|
@ -309,7 +309,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
return languageName1.compareTo(languageName2);
|
return languageName1.compareTo(languageName2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return availableLocales;
|
return availableLocales;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
AddDataPropertyStatement adps = new AddDataPropertyStatement(
|
AddDataPropertyStatement adps = new AddDataPropertyStatement(
|
||||||
vreq.getJenaOntModel(), individual.getURI(),
|
vreq.getJenaOntModel(), individual.getURI(),
|
||||||
SOME_URI, SOME_LITERAL);
|
SOME_URI, SOME_LITERAL);
|
||||||
|
|
||||||
AddObjectPropertyStatement aops = new AddObjectPropertyStatement(
|
AddObjectPropertyStatement aops = new AddObjectPropertyStatement(
|
||||||
vreq.getJenaOntModel(), individual.getURI(),
|
vreq.getJenaOntModel(), individual.getURI(),
|
||||||
SOME_PREDICATE, SOME_URI);
|
SOME_PREDICATE, SOME_URI);
|
||||||
|
@ -331,7 +331,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
public String getFOAFPersonClassURI() {
|
public String getFOAFPersonClassURI() {
|
||||||
return "http://xmlns.com/foaf/0.1/Person";
|
return "http://xmlns.com/foaf/0.1/Person";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPersonType(VitroRequest vreq, EditConfigurationVTwo config) {
|
public boolean isPersonType(VitroRequest vreq, EditConfigurationVTwo config) {
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||||
Boolean isPersonType = Boolean.FALSE;
|
Boolean isPersonType = Boolean.FALSE;
|
||||||
|
@ -344,11 +344,11 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
isPersonType = Boolean.TRUE;
|
isPersonType = Boolean.TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isPersonType;
|
return isPersonType;
|
||||||
}
|
}
|
||||||
|
|
||||||
//how to get the type of the individual in question
|
//how to get the type of the individual in question
|
||||||
public List<VClass> getVClasses(EditConfigurationVTwo config, VitroRequest vreq) {
|
public List<VClass> getVClasses(EditConfigurationVTwo config, VitroRequest vreq) {
|
||||||
Individual subject = EditConfigurationUtils.getIndividual(vreq, config.getSubjectUri());
|
Individual subject = EditConfigurationUtils.getIndividual(vreq, config.getSubjectUri());
|
||||||
|
@ -365,7 +365,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
prop.setURI(propertyUri);
|
prop.setURI(propertyUri);
|
||||||
//Iterate through the labels and create a hashmap
|
//Iterate through the labels and create a hashmap
|
||||||
HashMap<String, List<LabelInformation>> labelsHash= new HashMap<String, List<LabelInformation>>();
|
HashMap<String, List<LabelInformation>> labelsHash= new HashMap<String, List<LabelInformation>>();
|
||||||
|
|
||||||
for(Literal l: labels) {
|
for(Literal l: labels) {
|
||||||
String languageTag = l.getLanguage();
|
String languageTag = l.getLanguage();
|
||||||
String languageName = "";
|
String languageName = "";
|
||||||
|
@ -377,7 +377,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
} else {
|
} else {
|
||||||
log.warn("This language tag " + languageTag + " does not have corresponding name in the system and was not processed");
|
log.warn("This language tag " + languageTag + " does not have corresponding name in the system and was not processed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!StringUtils.isEmpty(languageName)) {
|
if(!StringUtils.isEmpty(languageName)) {
|
||||||
if(!labelsHash.containsKey(languageName)) {
|
if(!labelsHash.containsKey(languageName)) {
|
||||||
labelsHash.put(languageName, new ArrayList<LabelInformation>());
|
labelsHash.put(languageName, new ArrayList<LabelInformation>());
|
||||||
|
@ -386,14 +386,14 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
//This should put the label in the list
|
//This should put the label in the list
|
||||||
//Create label information instance with the required information
|
//Create label information instance with the required information
|
||||||
//To generate link
|
//To generate link
|
||||||
|
|
||||||
DataPropertyStatementTemplateModel dpstm = new DataPropertyStatementTemplateModel(subjectUri, prop, l,
|
DataPropertyStatementTemplateModel dpstm = new DataPropertyStatementTemplateModel(subjectUri, prop, l,
|
||||||
template, vreq);
|
template, vreq);
|
||||||
labelsList.add(new LabelInformation(
|
labelsList.add(new LabelInformation(
|
||||||
l, dpstm.getEditUrl(), dpstm.getDeleteUrl(), languageTag, languageName));
|
l, dpstm.getEditUrl(), dpstm.getDeleteUrl(), languageTag, languageName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Sort each label list
|
//Sort each label list
|
||||||
LabelInformationComparator lic = new LabelInformationComparator();
|
LabelInformationComparator lic = new LabelInformationComparator();
|
||||||
for(String languageName: labelsHash.keySet()) {
|
for(String languageName: labelsHash.keySet()) {
|
||||||
|
@ -401,12 +401,12 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
labelInfo.sort(lic);
|
labelInfo.sort(lic);
|
||||||
}
|
}
|
||||||
return labelsHash;
|
return labelsHash;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class LabelInformationComparator implements Comparator<LabelInformation> {
|
public static class LabelInformationComparator implements Comparator<LabelInformation> {
|
||||||
|
|
||||||
public int compare(LabelInformation l1, LabelInformation l2) {
|
public int compare(LabelInformation l1, LabelInformation l2) {
|
||||||
return l1.getLabelStringValue().compareTo(l2.getLabelStringValue());
|
return l1.getLabelStringValue().compareTo(l2.getLabelStringValue());
|
||||||
}
|
}
|
||||||
|
@ -418,8 +418,8 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
+ "SELECT DISTINCT ?label WHERE { \n"
|
+ "SELECT DISTINCT ?label WHERE { \n"
|
||||||
+ " ?subject rdfs:label ?label \n"
|
+ " ?subject rdfs:label ?label \n"
|
||||||
+ "} ORDER BY ?label";
|
+ "} ORDER BY ?label";
|
||||||
|
|
||||||
|
|
||||||
private ArrayList<Literal> getExistingLabels(String subjectUri, VitroRequest vreq) {
|
private ArrayList<Literal> getExistingLabels(String subjectUri, VitroRequest vreq) {
|
||||||
String queryStr = QueryUtils.subUriForQueryVar(LABEL_QUERY, "subject", subjectUri);
|
String queryStr = QueryUtils.subUriForQueryVar(LABEL_QUERY, "subject", subjectUri);
|
||||||
log.debug("queryStr = " + queryStr);
|
log.debug("queryStr = " + queryStr);
|
||||||
|
@ -431,31 +431,31 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
while (results.hasNext()) {
|
while (results.hasNext()) {
|
||||||
QuerySolution soln = results.nextSolution();
|
QuerySolution soln = results.nextSolution();
|
||||||
Literal nodeLiteral = soln.get("label").asLiteral();
|
Literal nodeLiteral = soln.get("label").asLiteral();
|
||||||
labels.add(nodeLiteral);
|
labels.add(nodeLiteral);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
}
|
}
|
||||||
return labels;
|
return labels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Putting this into a method allows overriding it in subclasses
|
//Putting this into a method allows overriding it in subclasses
|
||||||
protected String getEditForm() {
|
protected String getEditForm() {
|
||||||
return null;
|
return null;
|
||||||
//return AddEditWebpageFormGenerator.class.getName();
|
//return AddEditWebpageFormGenerator.class.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected String getTemplate() {
|
protected String getTemplate() {
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//get locales
|
//get locales
|
||||||
public List<HashMap<String, String>> getLocales(VitroRequest vreq) {
|
public List<HashMap<String, String>> getLocales(VitroRequest vreq) {
|
||||||
List<Locale> selectables = SelectedLocale.getSelectableLocales(vreq);
|
List<Locale> selectables = SelectedLocale.getSelectableLocales(vreq);
|
||||||
|
@ -472,27 +472,27 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
+ "': " + e);
|
+ "': " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public HashMap<String, String> getFullCodeToLanguageNameMap(List<HashMap<String, String>> localesList) {
|
public HashMap<String, String> getFullCodeToLanguageNameMap(List<HashMap<String, String>> localesList) {
|
||||||
HashMap<String, String> codeToLanguageMap = new HashMap<String, String>();
|
HashMap<String, String> codeToLanguageMap = new HashMap<String, String>();
|
||||||
for(Map<String, String> locale: localesList) {
|
for(Map<String, String> locale: localesList) {
|
||||||
String code = (String) locale.get("code");
|
String code = (String) locale.get("code");
|
||||||
String label = (String) locale.get("label");
|
String label = (String) locale.get("label");
|
||||||
if(!codeToLanguageMap.containsKey(code)) {
|
if(!codeToLanguageMap.containsKey(code)) {
|
||||||
codeToLanguageMap.put(code, label);
|
codeToLanguageMap.put(code, label);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn("Language code " + code + " for " + label + " was not associated in map becayse label already exists");
|
log.warn("Language code " + code + " for " + label + " was not associated in map becayse label already exists");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return codeToLanguageMap;
|
return codeToLanguageMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getFullLanguagesNamesSortedList(List<Map<String, Object>> localesList) {
|
public List<String> getFullLanguagesNamesSortedList(List<Map<String, Object>> localesList) {
|
||||||
HashSet<String> languageNamesSet = new HashSet<String>();
|
HashSet<String> languageNamesSet = new HashSet<String>();
|
||||||
for(Map<String, Object> locale: localesList) {
|
for(Map<String, Object> locale: localesList) {
|
||||||
|
@ -500,13 +500,13 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
if(!languageNamesSet.contains(label)) {
|
if(!languageNamesSet.contains(label)) {
|
||||||
languageNamesSet.add(label);
|
languageNamesSet.add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
List<String> languageNames = new ArrayList<String>(languageNamesSet);
|
List<String> languageNames = new ArrayList<String>(languageNamesSet);
|
||||||
Collections.sort(languageNames);
|
Collections.sort(languageNames);
|
||||||
return languageNames;
|
return languageNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
//copied from locale selection data getter but don't need all this information
|
//copied from locale selection data getter but don't need all this information
|
||||||
private HashMap<String, String> buildLocaleMap(Locale locale,
|
private HashMap<String, String> buildLocaleMap(Locale locale,
|
||||||
Locale currentLocale) throws FileNotFoundException {
|
Locale currentLocale) throws FileNotFoundException {
|
||||||
|
@ -516,14 +516,14 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
map.put("label", locale.getDisplayName(currentLocale));
|
map.put("label", locale.getDisplayName(currentLocale));
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Class used to store the information needed for the template, such as the labels, their languages, their edit links
|
//Class used to store the information needed for the template, such as the labels, their languages, their edit links
|
||||||
public class LabelInformation {
|
public class LabelInformation {
|
||||||
private Literal labelLiteral = null;
|
private Literal labelLiteral = null;
|
||||||
private String editLinkURL;
|
private String editLinkURL;
|
||||||
private String deleteLinkURL;
|
private String deleteLinkURL;
|
||||||
private String languageCode; //languageCode
|
private String languageCode; //languageCode
|
||||||
private String languageName;
|
private String languageName;
|
||||||
public LabelInformation(Literal inputLiteral, String inputEditLinkURL, String inputDeleteLinkURL, String inputLanguageCode, String inputLanguageName) {
|
public LabelInformation(Literal inputLiteral, String inputEditLinkURL, String inputDeleteLinkURL, String inputLanguageCode, String inputLanguageName) {
|
||||||
this.labelLiteral = inputLiteral;
|
this.labelLiteral = inputLiteral;
|
||||||
this.editLinkURL = inputEditLinkURL;
|
this.editLinkURL = inputEditLinkURL;
|
||||||
|
@ -531,32 +531,32 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
|
||||||
this.languageCode = inputLanguageCode;
|
this.languageCode = inputLanguageCode;
|
||||||
this.languageName = inputLanguageName;
|
this.languageName = inputLanguageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Literal getLabelLiteral() {
|
public Literal getLabelLiteral() {
|
||||||
return this.labelLiteral;
|
return this.labelLiteral;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLabelStringValue() {
|
public String getLabelStringValue() {
|
||||||
return this.labelLiteral.getString();
|
return this.labelLiteral.getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEditLinkURL() {
|
public String getEditLinkURL() {
|
||||||
return this.editLinkURL;
|
return this.editLinkURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDeleteLinkURL() {
|
public String getDeleteLinkURL() {
|
||||||
return this.deleteLinkURL;
|
return this.deleteLinkURL;
|
||||||
}
|
}
|
||||||
public String getLanguageCode() {
|
public String getLanguageCode() {
|
||||||
return this.languageCode;
|
return this.languageCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLanguageName() {
|
public String getLanguageName() {
|
||||||
return this.languageName;
|
return this.languageName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String N3_PREFIX = "@prefix foaf: <http://xmlns.com/foaf/0.1/> .\n";
|
private String N3_PREFIX = "@prefix foaf: <http://xmlns.com/foaf/0.1/> .\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,13 +31,13 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTw
|
||||||
* This is an odd controller that is just drawing a page with links on it.
|
* This is an odd controller that is just drawing a page with links on it.
|
||||||
* It is not an example of the normal use of the RDF editing system and
|
* It is not an example of the normal use of the RDF editing system and
|
||||||
* was just migrated over from an odd use of the JSP RDF editing system
|
* was just migrated over from an odd use of the JSP RDF editing system
|
||||||
* during the 1.4 release.
|
* during the 1.4 release.
|
||||||
*
|
*
|
||||||
* This mainly sets up pageData for the template to use.
|
* This mainly sets up pageData for the template to use.
|
||||||
*/
|
*/
|
||||||
public class ManageWebpagesForIndividualGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
public class ManageWebpagesForIndividualGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
||||||
public static Log log = LogFactory.getLog(ManageWebpagesForIndividualGenerator.class);
|
public static Log log = LogFactory.getLog(ManageWebpagesForIndividualGenerator.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
|
||||||
|
|
||||||
|
@ -55,8 +55,8 @@ public class ManageWebpagesForIndividualGenerator extends BaseEditConfigurationG
|
||||||
config.addFormSpecificData("webpages",webpages);
|
config.addFormSpecificData("webpages",webpages);
|
||||||
|
|
||||||
config.addFormSpecificData("rankPredicate", "http://vivoweb.org/ontology/core#rank" );
|
config.addFormSpecificData("rankPredicate", "http://vivoweb.org/ontology/core#rank" );
|
||||||
config.addFormSpecificData("reorderUrl", "/edit/reorder" );
|
config.addFormSpecificData("reorderUrl", "/edit/reorder" );
|
||||||
config.addFormSpecificData("deleteWebpageUrl", "/edit/primitiveDelete");
|
config.addFormSpecificData("deleteWebpageUrl", "/edit/primitiveDelete");
|
||||||
|
|
||||||
ParamMap paramMap = new ParamMap();
|
ParamMap paramMap = new ParamMap();
|
||||||
paramMap.put("subjectUri", config.getSubjectUri());
|
paramMap.put("subjectUri", config.getSubjectUri());
|
||||||
|
@ -64,7 +64,7 @@ public class ManageWebpagesForIndividualGenerator extends BaseEditConfigurationG
|
||||||
paramMap.put("view", "form");
|
paramMap.put("view", "form");
|
||||||
String path = UrlBuilder.getUrl( UrlBuilder.Route.EDIT_REQUEST_DISPATCH ,paramMap);
|
String path = UrlBuilder.getUrl( UrlBuilder.Route.EDIT_REQUEST_DISPATCH ,paramMap);
|
||||||
|
|
||||||
config.addFormSpecificData("baseEditWebpageUrl", path);
|
config.addFormSpecificData("baseEditWebpageUrl", path);
|
||||||
|
|
||||||
//Also add domainUri and rangeUri if they exist, adding here instead of template
|
//Also add domainUri and rangeUri if they exist, adding here instead of template
|
||||||
String domainUri = (String) vreq.getParameter("domainUri");
|
String domainUri = (String) vreq.getParameter("domainUri");
|
||||||
|
@ -82,7 +82,7 @@ public class ManageWebpagesForIndividualGenerator extends BaseEditConfigurationG
|
||||||
}
|
}
|
||||||
path = UrlBuilder.getUrl( UrlBuilder.Route.EDIT_REQUEST_DISPATCH ,paramMap);
|
path = UrlBuilder.getUrl( UrlBuilder.Route.EDIT_REQUEST_DISPATCH ,paramMap);
|
||||||
|
|
||||||
config.addFormSpecificData("showAddFormUrl", path);
|
config.addFormSpecificData("showAddFormUrl", path);
|
||||||
|
|
||||||
Individual subject = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(config.getSubjectUri());
|
Individual subject = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(config.getSubjectUri());
|
||||||
if( subject != null && subject.getName() != null ){
|
if( subject != null && subject.getName() != null ){
|
||||||
|
@ -162,10 +162,10 @@ public class ManageWebpagesForIndividualGenerator extends BaseEditConfigurationG
|
||||||
+ " OPTIONAL { ?link core:rank ?rank } \n"
|
+ " OPTIONAL { ?link core:rank ?rank } \n"
|
||||||
+ " OPTIONAL { ?link vitro:mostSpecificType ?type } \n"
|
+ " OPTIONAL { ?link vitro:mostSpecificType ?type } \n"
|
||||||
+ " OPTIONAL { ?type rdfs:label ?typeLabel } \n"
|
+ " OPTIONAL { ?type rdfs:label ?typeLabel } \n"
|
||||||
+ "} GROUP BY ?rank ?vcard ?link ?url ?typeLabel \n"
|
+ "} GROUP BY ?rank ?vcard ?link ?url ?typeLabel \n"
|
||||||
+ " ORDER BY ?rank";
|
+ " ORDER BY ?rank";
|
||||||
|
|
||||||
|
|
||||||
private List<Map<String, String>> getWebpages(String subjectUri, VitroRequest vreq) {
|
private List<Map<String, String>> getWebpages(String subjectUri, VitroRequest vreq) {
|
||||||
RDFService rdfService = vreq.getRDFService();
|
RDFService rdfService = vreq.getRDFService();
|
||||||
|
|
||||||
|
@ -195,20 +195,20 @@ public class ManageWebpagesForIndividualGenerator extends BaseEditConfigurationG
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
}
|
}
|
||||||
log.debug("webpages = " + webpages);
|
log.debug("webpages = " + webpages);
|
||||||
return webpages;
|
return webpages;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Putting this into a method allows overriding it in subclasses
|
//Putting this into a method allows overriding it in subclasses
|
||||||
protected String getEditForm() {
|
protected String getEditForm() {
|
||||||
return AddEditWebpageFormGenerator.class.getName();
|
return AddEditWebpageFormGenerator.class.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getQuery() {
|
protected String getQuery() {
|
||||||
return WEBPAGE_QUERY;
|
return WEBPAGE_QUERY;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getTemplate() {
|
protected String getTemplate() {
|
||||||
return "manageWebpagesForIndividual.ftl";
|
return "manageWebpagesForIndividual.ftl";
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,42 +16,42 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
|
||||||
|
|
||||||
public class OrganizationAdministersGrantGenerator extends VivoBaseGenerator implements
|
public class OrganizationAdministersGrantGenerator extends VivoBaseGenerator implements
|
||||||
EditConfigurationGenerator {
|
EditConfigurationGenerator {
|
||||||
|
|
||||||
public OrganizationAdministersGrantGenerator() {}
|
public OrganizationAdministersGrantGenerator() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
HttpSession session) throws Exception {
|
HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
|
|
||||||
conf.setTemplate("organizationAdministersGrant.ftl");
|
conf.setTemplate("organizationAdministersGrant.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("organization");
|
conf.setVarNameForSubject("organization");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("adminRole");
|
conf.setVarNameForObject("adminRole");
|
||||||
|
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewAdminRole) );
|
conf.setN3Required( Arrays.asList( n3ForNewAdminRole) );
|
||||||
conf.setN3Optional( Arrays.asList( n3ForNewAdminGrant,
|
conf.setN3Optional( Arrays.asList( n3ForNewAdminGrant,
|
||||||
n3ForExistingAdminGrant ) );
|
n3ForExistingAdminGrant ) );
|
||||||
|
|
||||||
conf.addNewResource("newGrant", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("newGrant", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("adminRole", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("adminRole", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
conf.setUrisOnform(Arrays.asList("existingGrant"));
|
conf.setUrisOnform(Arrays.asList("existingGrant"));
|
||||||
conf.setLiteralsOnForm(Arrays.asList("grantLabel", "grantLabelDisplay" ));
|
conf.setLiteralsOnForm(Arrays.asList("grantLabel", "grantLabelDisplay" ));
|
||||||
|
|
||||||
conf.addSparqlForExistingLiteral("grantLabel", grantLabelQuery);
|
conf.addSparqlForExistingLiteral("grantLabel", grantLabelQuery);
|
||||||
conf.addSparqlForExistingUris("existingGrant", existingGrantQuery);
|
conf.addSparqlForExistingUris("existingGrant", existingGrantQuery);
|
||||||
|
|
||||||
|
|
||||||
conf.addField( new FieldVTwo(). // options will be added in browser by auto complete JS
|
conf.addField( new FieldVTwo(). // options will be added in browser by auto complete JS
|
||||||
setName("existingGrant")
|
setName("existingGrant")
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("grantLabel").
|
setName("grantLabel").
|
||||||
|
@ -67,7 +67,7 @@ public class OrganizationAdministersGrantGenerator extends VivoBaseGenerator imp
|
||||||
|
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
conf.addValidator(new AutocompleteRequiredInputValidator("existingGrant", "grantLabel"));
|
conf.addValidator(new AutocompleteRequiredInputValidator("existingGrant", "grantLabel"));
|
||||||
|
|
||||||
// addFormSpecificData(conf, vreq);
|
// addFormSpecificData(conf, vreq);
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
|
@ -75,29 +75,29 @@ public class OrganizationAdministersGrantGenerator extends VivoBaseGenerator imp
|
||||||
|
|
||||||
/* N3 assertions */
|
/* N3 assertions */
|
||||||
|
|
||||||
final static String n3ForNewAdminRole =
|
final static String n3ForNewAdminRole =
|
||||||
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
||||||
"?organization <http://purl.obolibrary.org/obo/RO_0000053> ?adminRole . \n" +
|
"?organization <http://purl.obolibrary.org/obo/RO_0000053> ?adminRole . \n" +
|
||||||
"?adminRole a vivo:AdministratorRole . \n" +
|
"?adminRole a vivo:AdministratorRole . \n" +
|
||||||
"?adminRole <http://purl.obolibrary.org/obo/RO_0000052> ?organization . " ;
|
"?adminRole <http://purl.obolibrary.org/obo/RO_0000052> ?organization . " ;
|
||||||
|
|
||||||
final static String n3ForNewAdminGrant =
|
final static String n3ForNewAdminGrant =
|
||||||
"@prefix vivo: <" + vivoCore + "> . \n" +
|
"@prefix vivo: <" + vivoCore + "> . \n" +
|
||||||
"?adminRole vivo:relatedBy ?newGrant . \n" +
|
"?adminRole vivo:relatedBy ?newGrant . \n" +
|
||||||
"?newGrant a vivo:Grant . \n" +
|
"?newGrant a vivo:Grant . \n" +
|
||||||
"?newGrant vivo:relates ?adminRole . \n" +
|
"?newGrant vivo:relates ?adminRole . \n" +
|
||||||
"?organization vivo:relatedBy ?newGrant . \n" +
|
"?organization vivo:relatedBy ?newGrant . \n" +
|
||||||
"?newGrant vivo:relates ?organization . \n" +
|
"?newGrant vivo:relates ?organization . \n" +
|
||||||
"?newGrant <"+ label + "> ?grantLabel .";
|
"?newGrant <"+ label + "> ?grantLabel .";
|
||||||
|
|
||||||
final static String n3ForExistingAdminGrant =
|
final static String n3ForExistingAdminGrant =
|
||||||
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
||||||
"?adminRole vivo:relatedBy ?existingGrant . \n" +
|
"?adminRole vivo:relatedBy ?existingGrant . \n" +
|
||||||
"?existingGrant a <http://xmlns.com/foaf/0.1/Grant> . \n" +
|
"?existingGrant a <http://xmlns.com/foaf/0.1/Grant> . \n" +
|
||||||
"?existingGrant vivo:relates ?adminRole . \n" +
|
"?existingGrant vivo:relates ?adminRole . \n" +
|
||||||
"?organization vivo:relatedBy ?newGrant . \n" +
|
"?organization vivo:relatedBy ?newGrant . \n" +
|
||||||
"?newGrant vivo:relates ?organization . " ;
|
"?newGrant vivo:relates ?organization . " ;
|
||||||
|
|
||||||
/* Queries for editing an existing entry */
|
/* Queries for editing an existing entry */
|
||||||
|
|
||||||
final static String existingGrantQuery =
|
final static String existingGrantQuery =
|
||||||
|
|
|
@ -23,28 +23,28 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
|
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
|
||||||
|
|
||||||
public class OrganizationForTrainingGenerator extends VivoBaseGenerator implements EditConfigurationGenerator{
|
public class OrganizationForTrainingGenerator extends VivoBaseGenerator implements EditConfigurationGenerator{
|
||||||
|
|
||||||
//TODO: can we get rid of the session and get it form the vreq?
|
//TODO: can we get rid of the session and get it form the vreq?
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) throws Exception {
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
|
|
||||||
conf.setTemplate("organizationForTraining.ftl");
|
conf.setTemplate("organizationForTraining.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("organization");
|
conf.setVarNameForSubject("organization");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("edTraining");
|
conf.setVarNameForObject("edTraining");
|
||||||
|
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewEdTraining, trainingTypeAssertion ) );
|
conf.setN3Required( Arrays.asList( n3ForNewEdTraining, trainingTypeAssertion ) );
|
||||||
conf.setN3Optional(Arrays.asList( majorFieldAssertion, n3ForAwardedDegree, n3ForNewPerson, n3ForExistingPerson,
|
conf.setN3Optional(Arrays.asList( majorFieldAssertion, n3ForAwardedDegree, n3ForNewPerson, n3ForExistingPerson,
|
||||||
n3ForNewPersonAwardedDegree, n3ForExistingPersonAwardedDegree, deptAssertion, infoAssertion, n3ForStart,
|
n3ForNewPersonAwardedDegree, n3ForExistingPersonAwardedDegree, deptAssertion, infoAssertion, n3ForStart,
|
||||||
n3ForEnd, firstNameAssertion, lastNameAssertion ));
|
n3ForEnd, firstNameAssertion, lastNameAssertion ));
|
||||||
|
|
||||||
conf.addNewResource("edTraining", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("edTraining", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("awardedDegree",DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("awardedDegree",DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("newPerson",DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("newPerson",DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
@ -53,10 +53,10 @@ public class OrganizationForTrainingGenerator extends VivoBaseGenerator impleme
|
||||||
conf.addNewResource("endNode",DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("endNode",DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("vcardPerson", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("vcardPerson", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("vcardName", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("vcardName", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
//uris in scope: none
|
//uris in scope: none
|
||||||
//literals in scope: none
|
//literals in scope: none
|
||||||
|
|
||||||
conf.setUrisOnform( Arrays.asList( "existingPerson", "degreeType", "trainingType"));
|
conf.setUrisOnform( Arrays.asList( "existingPerson", "degreeType", "trainingType"));
|
||||||
conf.setLiteralsOnForm( Arrays.asList("personLabel", "personLabelDisplay", "awardedDegreeLabel",
|
conf.setLiteralsOnForm( Arrays.asList("personLabel", "personLabelDisplay", "awardedDegreeLabel",
|
||||||
"majorField", "dept", "info", "firstName", "lastName"));
|
"majorField", "dept", "info", "firstName", "lastName"));
|
||||||
|
@ -68,7 +68,7 @@ public class OrganizationForTrainingGenerator extends VivoBaseGenerator impleme
|
||||||
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
|
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
|
||||||
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
|
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
|
||||||
|
|
||||||
|
|
||||||
conf.addSparqlForExistingUris("awardedDegree", existingAwardedDegreeQuery);
|
conf.addSparqlForExistingUris("awardedDegree", existingAwardedDegreeQuery);
|
||||||
conf.addSparqlForExistingUris("existingPerson", existingPersonQuery);
|
conf.addSparqlForExistingUris("existingPerson", existingPersonQuery);
|
||||||
conf.addSparqlForExistingUris("trainingType", trainingTypeQuery);
|
conf.addSparqlForExistingUris("trainingType", trainingTypeQuery);
|
||||||
|
@ -80,8 +80,8 @@ public class OrganizationForTrainingGenerator extends VivoBaseGenerator impleme
|
||||||
conf.addSparqlForExistingUris("endField-precision", existingEndPrecisionQuery);
|
conf.addSparqlForExistingUris("endField-precision", existingEndPrecisionQuery);
|
||||||
//Add sparql to include inverse property as well
|
//Add sparql to include inverse property as well
|
||||||
conf.addSparqlForAdditionalUrisInScope("inverseTrainingAtPerson", inverseTrainingAtPersonQuery);
|
conf.addSparqlForAdditionalUrisInScope("inverseTrainingAtPerson", inverseTrainingAtPersonQuery);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("degreeType").
|
setName("degreeType").
|
||||||
setOptions( new IndividualsViaVClassOptions(
|
setOptions( new IndividualsViaVClassOptions(
|
||||||
degreeTypeClass)));
|
degreeTypeClass)));
|
||||||
|
@ -90,16 +90,16 @@ public class OrganizationForTrainingGenerator extends VivoBaseGenerator impleme
|
||||||
setName("majorField").
|
setName("majorField").
|
||||||
setRangeDatatypeUri( XSD.xstring.toString() ).
|
setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators(list("datatype:" + XSD.xstring.toString())));
|
setValidators(list("datatype:" + XSD.xstring.toString())));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("existingPerson")
|
setName("existingPerson")
|
||||||
//options will be added in browser by auto complete JS
|
//options will be added in browser by auto complete JS
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("awardedDegree")
|
setName("awardedDegree")
|
||||||
//options will be added in browser by auto complete JS
|
//options will be added in browser by auto complete JS
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("personLabel").
|
setName("personLabel").
|
||||||
|
@ -115,11 +115,11 @@ public class OrganizationForTrainingGenerator extends VivoBaseGenerator impleme
|
||||||
setName("existingAwardedDegreeLabel").
|
setName("existingAwardedDegreeLabel").
|
||||||
setRangeDatatypeUri(XSD.xstring.toString() ).
|
setRangeDatatypeUri(XSD.xstring.toString() ).
|
||||||
setValidators( list("datatype:" + XSD.xstring.toString())));
|
setValidators( list("datatype:" + XSD.xstring.toString())));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("personLabelDisplay").
|
setName("personLabelDisplay").
|
||||||
setRangeDatatypeUri(XSD.xstring.toString() ));
|
setRangeDatatypeUri(XSD.xstring.toString() ));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("firstName").
|
setName("firstName").
|
||||||
setRangeDatatypeUri(XSD.xstring.toString() ).
|
setRangeDatatypeUri(XSD.xstring.toString() ).
|
||||||
|
@ -135,14 +135,14 @@ public class OrganizationForTrainingGenerator extends VivoBaseGenerator impleme
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("trainingType").
|
setName("trainingType").
|
||||||
setValidators( list("nonempty") ).
|
setValidators( list("nonempty") ).
|
||||||
setOptions(
|
setOptions(
|
||||||
new ChildVClassesWithParent(edProcessClass)));
|
new ChildVClassesWithParent(edProcessClass)));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("dept").
|
setName("dept").
|
||||||
setRangeDatatypeUri( XSD.xstring.toString() ).
|
setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators(list("datatype:" + XSD.xstring.toString())));
|
setValidators(list("datatype:" + XSD.xstring.toString())));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("info").
|
setName("info").
|
||||||
setRangeDatatypeUri( XSD.xstring.toString() ).
|
setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
|
@ -150,33 +150,33 @@ public class OrganizationForTrainingGenerator extends VivoBaseGenerator impleme
|
||||||
|
|
||||||
FieldVTwo startField = new FieldVTwo().
|
FieldVTwo startField = new FieldVTwo().
|
||||||
setName("startField");
|
setName("startField");
|
||||||
conf.addField(startField.
|
conf.addField(startField.
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(startField,
|
new DateTimeWithPrecisionVTwo(startField,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())));
|
VitroVocabulary.Precision.NONE.uri())));
|
||||||
|
|
||||||
FieldVTwo endField = new FieldVTwo().
|
FieldVTwo endField = new FieldVTwo().
|
||||||
setName("endField");
|
setName("endField");
|
||||||
conf.addField( endField.
|
conf.addField( endField.
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(endField,
|
new DateTimeWithPrecisionVTwo(endField,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())));
|
VitroVocabulary.Precision.NONE.uri())));
|
||||||
//Add validator
|
//Add validator
|
||||||
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
|
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
conf.addValidator(new FirstAndLastNameValidator("existingPerson"));
|
conf.addValidator(new FirstAndLastNameValidator("existingPerson"));
|
||||||
|
|
||||||
//Adding additional data, specifically edit mode
|
//Adding additional data, specifically edit mode
|
||||||
addFormSpecificData(conf, vreq);
|
addFormSpecificData(conf, vreq);
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* N3 assertions for working with educational training */
|
/* N3 assertions for working with educational training */
|
||||||
|
|
||||||
final static String n3ForNewEdTraining =
|
final static String n3ForNewEdTraining =
|
||||||
"@prefix core: <"+ vivoCore +"> .\n"+
|
"@prefix core: <"+ vivoCore +"> .\n"+
|
||||||
"?organization <http://purl.obolibrary.org/obo/RO_0000056> ?edTraining .\n" +
|
"?organization <http://purl.obolibrary.org/obo/RO_0000056> ?edTraining .\n" +
|
||||||
"?edTraining a core:EducationalProcess .\n" +
|
"?edTraining a core:EducationalProcess .\n" +
|
||||||
|
@ -185,7 +185,7 @@ public class OrganizationForTrainingGenerator extends VivoBaseGenerator impleme
|
||||||
final static String trainingTypeAssertion =
|
final static String trainingTypeAssertion =
|
||||||
"?edTraining a ?trainingType .";
|
"?edTraining a ?trainingType .";
|
||||||
|
|
||||||
final static String n3ForAwardedDegree =
|
final static String n3ForAwardedDegree =
|
||||||
"@prefix core: <"+ vivoCore +"> .\n"+
|
"@prefix core: <"+ vivoCore +"> .\n"+
|
||||||
"?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?awardedDegree . \n" +
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?awardedDegree . \n" +
|
||||||
"?awardedDegree <http://purl.obolibrary.org/obo/RO_0002353> ?edTraining . \n" +
|
"?awardedDegree <http://purl.obolibrary.org/obo/RO_0002353> ?edTraining . \n" +
|
||||||
|
@ -196,49 +196,49 @@ public class OrganizationForTrainingGenerator extends VivoBaseGenerator impleme
|
||||||
"?degreeType <http://vivoweb.org/ontology/core#relatedBy> ?awardedDegree . \n"+
|
"?degreeType <http://vivoweb.org/ontology/core#relatedBy> ?awardedDegree . \n"+
|
||||||
"?awardedDegree a core:AwardedDegree .";
|
"?awardedDegree a core:AwardedDegree .";
|
||||||
|
|
||||||
final static String n3ForNewPerson =
|
final static String n3ForNewPerson =
|
||||||
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?newPerson . \n" +
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?newPerson . \n" +
|
||||||
"?newPerson <http://purl.obolibrary.org/obo/RO_0000056> ?edTraining . \n" +
|
"?newPerson <http://purl.obolibrary.org/obo/RO_0000056> ?edTraining . \n" +
|
||||||
"?newPerson a <http://xmlns.com/foaf/0.1/Person> . \n" +
|
"?newPerson a <http://xmlns.com/foaf/0.1/Person> . \n" +
|
||||||
"?newPerson <"+ label +"> ?personLabel . ";
|
"?newPerson <"+ label +"> ?personLabel . ";
|
||||||
|
|
||||||
final static String n3ForExistingPerson =
|
final static String n3ForExistingPerson =
|
||||||
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?existingPerson . \n" +
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?existingPerson . \n" +
|
||||||
"?existingPerson <http://purl.obolibrary.org/obo/RO_0000056> ?edTraining . \n" +
|
"?existingPerson <http://purl.obolibrary.org/obo/RO_0000056> ?edTraining . \n" +
|
||||||
" ";
|
" ";
|
||||||
|
|
||||||
final static String n3ForNewPersonAwardedDegree =
|
final static String n3ForNewPersonAwardedDegree =
|
||||||
"?awardedDegree <http://vivoweb.org/ontology/core#relates> ?newPerson . \n" +
|
"?awardedDegree <http://vivoweb.org/ontology/core#relates> ?newPerson . \n" +
|
||||||
"?newPerson <http://vivoweb.org/ontology/core#releatedBy> ?awardedDegree . \n" +
|
"?newPerson <http://vivoweb.org/ontology/core#releatedBy> ?awardedDegree . \n" +
|
||||||
"?newPerson a <http://xmlns.com/foaf/0.1/Person> . \n" +
|
"?newPerson a <http://xmlns.com/foaf/0.1/Person> . \n" +
|
||||||
"?awardedDegree <"+ label +"> ?awardedDegreeLabel . \n" +
|
"?awardedDegree <"+ label +"> ?awardedDegreeLabel . \n" +
|
||||||
"?newPerson <"+ label +"> ?personLabel . ";
|
"?newPerson <"+ label +"> ?personLabel . ";
|
||||||
|
|
||||||
final static String firstNameAssertion =
|
final static String firstNameAssertion =
|
||||||
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
||||||
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
||||||
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
||||||
"?vcardName vcard:givenName ?firstName .";
|
"?vcardName vcard:givenName ?firstName .";
|
||||||
|
|
||||||
final static String lastNameAssertion =
|
final static String lastNameAssertion =
|
||||||
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
||||||
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
||||||
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
||||||
"?vcardName vcard:familyName ?lastName .";
|
"?vcardName vcard:familyName ?lastName .";
|
||||||
|
|
||||||
final static String n3ForExistingPersonAwardedDegree =
|
final static String n3ForExistingPersonAwardedDegree =
|
||||||
"?awardedDegree <http://vivoweb.org/ontology/core#relates> ?existingPerson . \n" +
|
"?awardedDegree <http://vivoweb.org/ontology/core#relates> ?existingPerson . \n" +
|
||||||
"?existingPerson <http://vivoweb.org/ontology/core#relatedBy> ?awardedDegree . \n" +
|
"?existingPerson <http://vivoweb.org/ontology/core#relatedBy> ?awardedDegree . \n" +
|
||||||
"?awardedDegree <"+ label +"> ?awardedDegreeLabel . \n" +
|
"?awardedDegree <"+ label +"> ?awardedDegreeLabel . \n" +
|
||||||
"?existingPerson a <http://xmlns.com/foaf/0.1/Person> . ";
|
"?existingPerson a <http://xmlns.com/foaf/0.1/Person> . ";
|
||||||
|
|
||||||
final static String majorFieldAssertion =
|
final static String majorFieldAssertion =
|
||||||
"?edTraining <"+ majorFieldPred +"> ?majorField .";
|
"?edTraining <"+ majorFieldPred +"> ?majorField .";
|
||||||
|
|
||||||
final static String n3ForStart =
|
final static String n3ForStart =
|
||||||
|
@ -257,24 +257,24 @@ public class OrganizationForTrainingGenerator extends VivoBaseGenerator impleme
|
||||||
"?endNode <"+ dateTimeValue +"> ?endField-value .\n"+
|
"?endNode <"+ dateTimeValue +"> ?endField-value .\n"+
|
||||||
"?endNode <"+ dateTimePrecision +"> ?endField-precision .";
|
"?endNode <"+ dateTimePrecision +"> ?endField-precision .";
|
||||||
|
|
||||||
final static String deptAssertion =
|
final static String deptAssertion =
|
||||||
"?edTraining <"+ deptPred +"> ?dept .";
|
"?edTraining <"+ deptPred +"> ?dept .";
|
||||||
|
|
||||||
final static String infoAssertion =
|
final static String infoAssertion =
|
||||||
"?edTraining <"+ infoPred +"> ?info .";
|
"?edTraining <"+ infoPred +"> ?info .";
|
||||||
|
|
||||||
/* Queries for editing an existing educational training entry */
|
/* Queries for editing an existing educational training entry */
|
||||||
|
|
||||||
final static String existingAwardedDegreeQuery =
|
final static String existingAwardedDegreeQuery =
|
||||||
"SELECT ?existingAwardedDegree WHERE {\n"+
|
"SELECT ?existingAwardedDegree WHERE {\n"+
|
||||||
"?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?existingAwardedDegree . }\n";
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?existingAwardedDegree . }\n";
|
||||||
|
|
||||||
final static String existingAwardedDegreeLabelQuery =
|
final static String existingAwardedDegreeLabelQuery =
|
||||||
"SELECT ?existingAwardedDegreeLabel WHERE {\n"+
|
"SELECT ?existingAwardedDegreeLabel WHERE {\n"+
|
||||||
"?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?existingAwardedDegree . \n" +
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?existingAwardedDegree . \n" +
|
||||||
"?existingAwardedDegree <"+ label +"> ?existingAwardedDegreeLabel }\n";
|
"?existingAwardedDegree <"+ label +"> ?existingAwardedDegreeLabel }\n";
|
||||||
|
|
||||||
final static String existingPersonQuery =
|
final static String existingPersonQuery =
|
||||||
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
||||||
"SELECT ?existingPerson WHERE {\n"+
|
"SELECT ?existingPerson WHERE {\n"+
|
||||||
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?existingPerson . \n" +
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?existingPerson . \n" +
|
||||||
|
@ -282,7 +282,7 @@ public class OrganizationForTrainingGenerator extends VivoBaseGenerator impleme
|
||||||
"?existingPerson a <http://xmlns.com/foaf/0.1/Person> . \n " +
|
"?existingPerson a <http://xmlns.com/foaf/0.1/Person> . \n " +
|
||||||
" }";
|
" }";
|
||||||
|
|
||||||
final static String personLabelQuery =
|
final static String personLabelQuery =
|
||||||
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
||||||
"SELECT ?existingPersonLabel WHERE {\n"+
|
"SELECT ?existingPersonLabel WHERE {\n"+
|
||||||
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?existingPerson . \n" +
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?existingPerson . \n" +
|
||||||
|
@ -291,12 +291,12 @@ public class OrganizationForTrainingGenerator extends VivoBaseGenerator impleme
|
||||||
"?existingPerson a <http://xmlns.com/foaf/0.1/Person> . \n " +
|
"?existingPerson a <http://xmlns.com/foaf/0.1/Person> . \n " +
|
||||||
" }";
|
" }";
|
||||||
|
|
||||||
final static String trainingTypeQuery =
|
final static String trainingTypeQuery =
|
||||||
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
||||||
"SELECT ?existingTrainingType WHERE { \n" +
|
"SELECT ?existingTrainingType WHERE { \n" +
|
||||||
" ?edTraining vitro:mostSpecificType ?existingTrainingType . }";
|
" ?edTraining vitro:mostSpecificType ?existingTrainingType . }";
|
||||||
|
|
||||||
final static String degreeTypeQuery =
|
final static String degreeTypeQuery =
|
||||||
"PREFIX core: <"+ vivoCore +"> \n"+
|
"PREFIX core: <"+ vivoCore +"> \n"+
|
||||||
"SELECT ?existingDegreeType WHERE {\n"+
|
"SELECT ?existingDegreeType WHERE {\n"+
|
||||||
"?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?existingAwardedDegree . \n"+
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?existingAwardedDegree . \n"+
|
||||||
|
@ -304,31 +304,31 @@ public class OrganizationForTrainingGenerator extends VivoBaseGenerator impleme
|
||||||
"?existingAwardedDegree core:relates ?existingDegreeType . \n" +
|
"?existingAwardedDegree core:relates ?existingDegreeType . \n" +
|
||||||
"?existingDegreeType a core:AcademicDegree }";
|
"?existingDegreeType a core:AcademicDegree }";
|
||||||
|
|
||||||
final static String majorFieldQuery =
|
final static String majorFieldQuery =
|
||||||
"SELECT ?existingMajorField WHERE {\n"+
|
"SELECT ?existingMajorField WHERE {\n"+
|
||||||
"?edTraining <"+ majorFieldPred +"> ?existingMajorField . }";
|
"?edTraining <"+ majorFieldPred +"> ?existingMajorField . }";
|
||||||
|
|
||||||
final static String deptQuery =
|
final static String deptQuery =
|
||||||
"SELECT ?existingDept WHERE {\n"+
|
"SELECT ?existingDept WHERE {\n"+
|
||||||
"?edTraining <"+ deptPred +"> ?existingDept . }";
|
"?edTraining <"+ deptPred +"> ?existingDept . }";
|
||||||
|
|
||||||
final static String infoQuery =
|
final static String infoQuery =
|
||||||
"SELECT ?existingInfo WHERE {\n"+
|
"SELECT ?existingInfo WHERE {\n"+
|
||||||
"?edTraining <"+ infoPred +"> ?existingInfo . }";
|
"?edTraining <"+ infoPred +"> ?existingInfo . }";
|
||||||
|
|
||||||
final static String existingIntervalNodeQuery =
|
final static String existingIntervalNodeQuery =
|
||||||
"SELECT ?existingIntervalNode WHERE {\n"+
|
"SELECT ?existingIntervalNode WHERE {\n"+
|
||||||
"?edTraining <"+ toInterval +"> ?existingIntervalNode .\n"+
|
"?edTraining <"+ toInterval +"> ?existingIntervalNode .\n"+
|
||||||
"?existingIntervalNode <"+ type +"> <"+ intervalType +"> . }";
|
"?existingIntervalNode <"+ type +"> <"+ intervalType +"> . }";
|
||||||
|
|
||||||
final static String existingStartNodeQuery =
|
final static String existingStartNodeQuery =
|
||||||
"SELECT ?existingStartNode WHERE {\n"+
|
"SELECT ?existingStartNode WHERE {\n"+
|
||||||
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
||||||
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
||||||
"?intervalNode <"+ intervalToStart +"> ?existingStartNode . \n"+
|
"?intervalNode <"+ intervalToStart +"> ?existingStartNode . \n"+
|
||||||
"?existingStartNode <"+ type +"> <"+ dateTimeValueType +"> .}";
|
"?existingStartNode <"+ type +"> <"+ dateTimeValueType +"> .}";
|
||||||
|
|
||||||
final static String existingStartDateQuery =
|
final static String existingStartDateQuery =
|
||||||
"SELECT ?existingDateStart WHERE {\n"+
|
"SELECT ?existingDateStart WHERE {\n"+
|
||||||
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
||||||
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
||||||
|
@ -336,7 +336,7 @@ public class OrganizationForTrainingGenerator extends VivoBaseGenerator impleme
|
||||||
"?startNode <"+ type +"> <"+ dateTimeValueType +"> .\n"+
|
"?startNode <"+ type +"> <"+ dateTimeValueType +"> .\n"+
|
||||||
"?startNode <"+ dateTimeValue +"> ?existingDateStart . }";
|
"?startNode <"+ dateTimeValue +"> ?existingDateStart . }";
|
||||||
|
|
||||||
final static String existingStartPrecisionQuery =
|
final static String existingStartPrecisionQuery =
|
||||||
"SELECT ?existingStartPrecision WHERE {\n"+
|
"SELECT ?existingStartPrecision WHERE {\n"+
|
||||||
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
||||||
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
||||||
|
@ -344,14 +344,14 @@ public class OrganizationForTrainingGenerator extends VivoBaseGenerator impleme
|
||||||
"?startNode <"+ type +"> <"+ dateTimeValueType +"> . \n"+
|
"?startNode <"+ type +"> <"+ dateTimeValueType +"> . \n"+
|
||||||
"?startNode <"+ dateTimePrecision +"> ?existingStartPrecision . }";
|
"?startNode <"+ dateTimePrecision +"> ?existingStartPrecision . }";
|
||||||
|
|
||||||
final static String existingEndNodeQuery =
|
final static String existingEndNodeQuery =
|
||||||
"SELECT ?existingEndNode WHERE { \n"+
|
"SELECT ?existingEndNode WHERE { \n"+
|
||||||
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
||||||
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
||||||
"?intervalNode <"+ intervalToEnd +"> ?existingEndNode . \n"+
|
"?intervalNode <"+ intervalToEnd +"> ?existingEndNode . \n"+
|
||||||
"?existingEndNode <"+ type +"> <"+ dateTimeValueType +"> .}";
|
"?existingEndNode <"+ type +"> <"+ dateTimeValueType +"> .}";
|
||||||
|
|
||||||
final static String existingEndDateQuery =
|
final static String existingEndDateQuery =
|
||||||
"SELECT ?existingEndDate WHERE {\n"+
|
"SELECT ?existingEndDate WHERE {\n"+
|
||||||
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
||||||
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
||||||
|
@ -359,28 +359,28 @@ public class OrganizationForTrainingGenerator extends VivoBaseGenerator impleme
|
||||||
"?endNode <"+ type +"> <"+ dateTimeValueType +"> .\n"+
|
"?endNode <"+ type +"> <"+ dateTimeValueType +"> .\n"+
|
||||||
"?endNode <"+ dateTimeValue +"> ?existingEndDate . }";
|
"?endNode <"+ dateTimeValue +"> ?existingEndDate . }";
|
||||||
|
|
||||||
final static String existingEndPrecisionQuery =
|
final static String existingEndPrecisionQuery =
|
||||||
"SELECT ?existingEndPrecision WHERE {\n"+
|
"SELECT ?existingEndPrecision WHERE {\n"+
|
||||||
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
||||||
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
||||||
"?intervalNode <"+ intervalToEnd +"> ?endNode .\n"+
|
"?intervalNode <"+ intervalToEnd +"> ?endNode .\n"+
|
||||||
"?endNode <"+ type +"> <"+ dateTimeValueType +"> .\n"+
|
"?endNode <"+ type +"> <"+ dateTimeValueType +"> .\n"+
|
||||||
"?endNode <"+ dateTimePrecision +"> ?existingEndPrecision . }";
|
"?endNode <"+ dateTimePrecision +"> ?existingEndPrecision . }";
|
||||||
|
|
||||||
//Query for inverse property
|
//Query for inverse property
|
||||||
final static String inverseTrainingAtPersonQuery =
|
final static String inverseTrainingAtPersonQuery =
|
||||||
"PREFIX owl: <http://www.w3.person/2002/07/owl#>"
|
"PREFIX owl: <http://www.w3.person/2002/07/owl#>"
|
||||||
+ " SELECT ?inverseTrainingAtPerson "
|
+ " SELECT ?inverseTrainingAtPerson "
|
||||||
+ " WHERE { ?inverseTrainingAtPerson owl:inverseOf <http://vivoweb.org/ontology/core#relates> . } ";
|
+ " WHERE { ?inverseTrainingAtPerson owl:inverseOf <http://vivoweb.org/ontology/core#relates> . } ";
|
||||||
|
|
||||||
|
|
||||||
//Adding form specific data such as edit mode
|
//Adding form specific data such as edit mode
|
||||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||||
formSpecificData.put("editMode", getEditMode(vreq).name().toLowerCase());
|
formSpecificData.put("editMode", getEditMode(vreq).name().toLowerCase());
|
||||||
editConfiguration.setFormSpecificData(formSpecificData);
|
editConfiguration.setFormSpecificData(formSpecificData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EditMode getEditMode(VitroRequest vreq) {
|
public EditMode getEditMode(VitroRequest vreq) {
|
||||||
List<String> predicates = new ArrayList<String>();
|
List<String> predicates = new ArrayList<String>();
|
||||||
predicates.add("http://vivoweb.org/ontology/core#relates");
|
predicates.add("http://vivoweb.org/ontology/core#relates");
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
|
||||||
+ "@prefix core: <http://vivoweb.org/ontology/core#> . \n"
|
+ "@prefix core: <http://vivoweb.org/ontology/core#> . \n"
|
||||||
+ "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . \n"
|
+ "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . \n"
|
||||||
+ "?organization core:relatedBy ?position . \n"
|
+ "?organization core:relatedBy ?position . \n"
|
||||||
+ "?position a core:Position . \n"
|
+ "?position a core:Position . \n"
|
||||||
+ "?position a ?positionType . \n"
|
+ "?position a ?positionType . \n"
|
||||||
+ "?position rdfs:label ?positionTitle . \n"
|
+ "?position rdfs:label ?positionTitle . \n"
|
||||||
+ "?position core:relates ?organization . ";
|
+ "?position core:relates ?organization . ";
|
||||||
|
@ -122,7 +122,7 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
|
||||||
+ "@prefix core: <http://vivoweb.org/ontology/core#> . \n"
|
+ "@prefix core: <http://vivoweb.org/ontology/core#> . \n"
|
||||||
+ "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . \n"
|
+ "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . \n"
|
||||||
+ "@prefix foaf: <http://xmlns.com/foaf/0.1/> . \n"
|
+ "@prefix foaf: <http://xmlns.com/foaf/0.1/> . \n"
|
||||||
+ "?position core:relates ?person . \n"
|
+ "?position core:relates ?person . \n"
|
||||||
+ "?person core:relatedBy ?position . \n"
|
+ "?person core:relatedBy ?position . \n"
|
||||||
+ "?person a foaf:Person . \n"
|
+ "?person a foaf:Person . \n"
|
||||||
+ "?person rdfs:label ?personLabel . ";
|
+ "?person rdfs:label ?personLabel . ";
|
||||||
|
@ -147,7 +147,7 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
|
||||||
|
|
||||||
private static final String N3_EXISTING_PERSON = ""
|
private static final String N3_EXISTING_PERSON = ""
|
||||||
+ "@prefix core: <http://vivoweb.org/ontology/core#> . \n"
|
+ "@prefix core: <http://vivoweb.org/ontology/core#> . \n"
|
||||||
+ "?position core:relates ?existingPerson . \n"
|
+ "?position core:relates ?existingPerson . \n"
|
||||||
+ "?existingPerson core:relatedBy ?position . \n";
|
+ "?existingPerson core:relatedBy ?position . \n";
|
||||||
|
|
||||||
private static final String N3_NEW_START_NODE = ""
|
private static final String N3_NEW_START_NODE = ""
|
||||||
|
@ -221,7 +221,7 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
|
||||||
conf.addField(new FieldVTwo()
|
conf.addField(new FieldVTwo()
|
||||||
.setName("positionType")
|
.setName("positionType")
|
||||||
.setValidators(list("nonempty"))
|
.setValidators(list("nonempty"))
|
||||||
.setOptions(
|
.setOptions(
|
||||||
new ChildVClassesWithParent(URI_POSITION_CLASS))
|
new ChildVClassesWithParent(URI_POSITION_CLASS))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
conf.addValidator(new DateTimeIntervalValidationVTwo("startField",
|
conf.addValidator(new DateTimeIntervalValidationVTwo("startField",
|
||||||
"endField"));
|
"endField"));
|
||||||
|
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,25 +37,25 @@ public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
final static String dateTimeValueType = vivoCore + "DateTimeValue";
|
final static String dateTimeValueType = vivoCore + "DateTimeValue";
|
||||||
final static String dateTimeValue = vivoCore + "dateTime";
|
final static String dateTimeValue = vivoCore + "dateTime";
|
||||||
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
|
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
|
||||||
|
|
||||||
public PersonHasAdviseeRelationshipGenerator() {}
|
public PersonHasAdviseeRelationshipGenerator() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
HttpSession session) throws Exception {
|
HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
|
|
||||||
conf.setTemplate("personHasAdviseeRelationship.ftl");
|
conf.setTemplate("personHasAdviseeRelationship.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("person");
|
conf.setVarNameForSubject("person");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("adviseeRole");
|
conf.setVarNameForObject("adviseeRole");
|
||||||
|
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewAdvisingRelationship,
|
conf.setN3Required( Arrays.asList( n3ForNewAdvisingRelationship,
|
||||||
advisingRelLabelAssertion,
|
advisingRelLabelAssertion,
|
||||||
advisingRelTypeAssertion ) );
|
advisingRelTypeAssertion ) );
|
||||||
|
@ -66,9 +66,9 @@ public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
lastNameAssertion,
|
lastNameAssertion,
|
||||||
n3ForExistingSubjAreaAssertion, //relationship to existing subject area
|
n3ForExistingSubjAreaAssertion, //relationship to existing subject area
|
||||||
n3ForNewSubjAreaAssertion, //this will include all the new information that needs to be captured
|
n3ForNewSubjAreaAssertion, //this will include all the new information that needs to be captured
|
||||||
n3ForStart,
|
n3ForStart,
|
||||||
n3ForEnd ) );
|
n3ForEnd ) );
|
||||||
|
|
||||||
conf.addNewResource("advisingRelationship", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("advisingRelationship", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("newAdvisor", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("newAdvisor", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("vcardAdvisor", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("vcardAdvisor", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
@ -79,19 +79,19 @@ public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
//uris in scope: none
|
//uris in scope: none
|
||||||
//literals in scope: none
|
//literals in scope: none
|
||||||
|
|
||||||
conf.setUrisOnform(Arrays.asList("advisingRelType", "existingSubjArea", "degree", "existingAdvisor"));
|
conf.setUrisOnform(Arrays.asList("advisingRelType", "existingSubjArea", "degree", "existingAdvisor"));
|
||||||
conf.setLiteralsOnForm(Arrays.asList("advisingRelLabel", "subjAreaLabel", "advisorLabel", "firstName", "lastName", "subjAreaLabelDisplay", "advisorLabelDisplay" ));
|
conf.setLiteralsOnForm(Arrays.asList("advisingRelLabel", "subjAreaLabel", "advisorLabel", "firstName", "lastName", "subjAreaLabelDisplay", "advisorLabelDisplay" ));
|
||||||
|
|
||||||
conf.addSparqlForExistingLiteral("advisingRelLabel", advisingRelLabelQuery);
|
conf.addSparqlForExistingLiteral("advisingRelLabel", advisingRelLabelQuery);
|
||||||
conf.addSparqlForExistingLiteral("advisorLabel", advisorLabelQuery);
|
conf.addSparqlForExistingLiteral("advisorLabel", advisorLabelQuery);
|
||||||
conf.addSparqlForExistingLiteral("subjAreaLabel", subjAreaLabelQuery);
|
conf.addSparqlForExistingLiteral("subjAreaLabel", subjAreaLabelQuery);
|
||||||
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
|
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
|
||||||
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
|
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
|
||||||
|
|
||||||
conf.addSparqlForExistingUris("advisingRelType", advisingRelTypeQuery);
|
conf.addSparqlForExistingUris("advisingRelType", advisingRelTypeQuery);
|
||||||
conf.addSparqlForExistingUris("advisingRelationship", existingAdvisingRelQuery);
|
conf.addSparqlForExistingUris("advisingRelationship", existingAdvisingRelQuery);
|
||||||
conf.addSparqlForExistingUris("advisorRole", existingAdvisorRoleQuery);
|
conf.addSparqlForExistingUris("advisorRole", existingAdvisorRoleQuery);
|
||||||
|
@ -103,8 +103,8 @@ public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
conf.addSparqlForExistingUris("endNode", existingEndNodeQuery);
|
conf.addSparqlForExistingUris("endNode", existingEndNodeQuery);
|
||||||
conf.addSparqlForExistingUris("startField-precision", existingStartPrecisionQuery);
|
conf.addSparqlForExistingUris("startField-precision", existingStartPrecisionQuery);
|
||||||
conf.addSparqlForExistingUris("endField-precision", existingEndPrecisionQuery);
|
conf.addSparqlForExistingUris("endField-precision", existingEndPrecisionQuery);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("advisingRelType").
|
setName("advisingRelType").
|
||||||
setValidators( list("nonempty") ).
|
setValidators( list("nonempty") ).
|
||||||
setOptions( new ChildVClassesWithParent(advisingRelClass))
|
setOptions( new ChildVClassesWithParent(advisingRelClass))
|
||||||
|
@ -129,8 +129,8 @@ public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo(). // options set by auto complete JS
|
conf.addField( new FieldVTwo(). // options set by auto complete JS
|
||||||
setName("existingSubjArea")
|
setName("existingSubjArea")
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("subjAreaLabel").
|
setName("subjAreaLabel").
|
||||||
|
@ -140,13 +140,13 @@ public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("degree").
|
setName("degree").
|
||||||
setOptions(
|
setOptions(
|
||||||
new IndividualsViaVClassOptions(degreeClass))
|
new IndividualsViaVClassOptions(degreeClass))
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo(). // options set by auto complete JS
|
conf.addField( new FieldVTwo(). // options set by auto complete JS
|
||||||
setName("existingAdvisor")
|
setName("existingAdvisor")
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("advisorLabel").
|
setName("advisorLabel").
|
||||||
|
@ -167,16 +167,16 @@ public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().setName("startField").
|
conf.addField( new FieldVTwo().setName("startField").
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(null,
|
new DateTimeWithPrecisionVTwo(null,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())
|
VitroVocabulary.Precision.NONE.uri())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().setName("endField").
|
conf.addField( new FieldVTwo().setName("endField").
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(null,
|
new DateTimeWithPrecisionVTwo(null,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())
|
VitroVocabulary.Precision.NONE.uri())
|
||||||
)
|
)
|
||||||
|
@ -186,98 +186,98 @@ public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
conf.addValidator(new FirstAndLastNameValidator("existingAdvisor"));
|
conf.addValidator(new FirstAndLastNameValidator("existingAdvisor"));
|
||||||
addFormSpecificData(conf, vreq);
|
addFormSpecificData(conf, vreq);
|
||||||
|
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* N3 assertions */
|
/* N3 assertions */
|
||||||
|
|
||||||
final static String n3ForNewAdvisingRelationship =
|
final static String n3ForNewAdvisingRelationship =
|
||||||
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
||||||
"?person <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
"?person <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
"?advisingRelationship a <" + advisingRelClass + "> . \n" +
|
"?advisingRelationship a <" + advisingRelClass + "> . \n" +
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?person . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?person . \n" +
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
||||||
"?adviseeRole a <" + adviseeRoleClass + "> . \n" +
|
"?adviseeRole a <" + adviseeRoleClass + "> . \n" +
|
||||||
"?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
"?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
"?person <http://purl.obolibrary.org/obo/RO_0000053> ?adviseeRole . \n" +
|
"?person <http://purl.obolibrary.org/obo/RO_0000053> ?adviseeRole . \n" +
|
||||||
"?adviseeRole <http://purl.obolibrary.org/obo/RO_0000052> ?person . ";
|
"?adviseeRole <http://purl.obolibrary.org/obo/RO_0000052> ?person . ";
|
||||||
|
|
||||||
final static String advisingRelLabelAssertion =
|
final static String advisingRelLabelAssertion =
|
||||||
"?advisingRelationship <"+ label + "> ?advisingRelLabel .";
|
"?advisingRelationship <"+ label + "> ?advisingRelLabel .";
|
||||||
|
|
||||||
final static String advisingRelTypeAssertion =
|
final static String advisingRelTypeAssertion =
|
||||||
"?advisingRelationship a ?advisingRelType .";
|
"?advisingRelationship a ?advisingRelType .";
|
||||||
|
|
||||||
final static String n3ForNewAdvisorAssertion =
|
final static String n3ForNewAdvisorAssertion =
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?newAdvisor . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?newAdvisor . \n" +
|
||||||
"?newAdvisor <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
"?newAdvisor <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
"?newAdvisor <" + label + "> ?advisorLabel . \n" +
|
"?newAdvisor <" + label + "> ?advisorLabel . \n" +
|
||||||
"?newAdvisor a <" + advisorClass + "> . \n" +
|
"?newAdvisor a <" + advisorClass + "> . \n" +
|
||||||
"?newAdvisor <http://purl.obolibrary.org/obo/RO_0000053> ?advisorRole . \n" +
|
"?newAdvisor <http://purl.obolibrary.org/obo/RO_0000053> ?advisorRole . \n" +
|
||||||
"?advisorRole <http://purl.obolibrary.org/obo/RO_0000052> ?newAdvisor . \n" +
|
"?advisorRole <http://purl.obolibrary.org/obo/RO_0000052> ?newAdvisor . \n" +
|
||||||
"?advisorRole a <" + advisorRoleClass + "> . \n" +
|
"?advisorRole a <" + advisorRoleClass + "> . \n" +
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
||||||
"?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . ";
|
"?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . ";
|
||||||
|
|
||||||
final static String n3ForExistingAdvisorAssertion =
|
final static String n3ForExistingAdvisorAssertion =
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?existingAdvisor . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?existingAdvisor . \n" +
|
||||||
"?existingAdvisor <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
"?existingAdvisor <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
"?existingAdvisor <http://purl.obolibrary.org/obo/RO_0000053> ?advisorRole . \n" +
|
"?existingAdvisor <http://purl.obolibrary.org/obo/RO_0000053> ?advisorRole . \n" +
|
||||||
"?advisorRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingAdvisor . \n" +
|
"?advisorRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingAdvisor . \n" +
|
||||||
"?advisorRole a <" + advisorRoleClass + "> . \n" +
|
"?advisorRole a <" + advisorRoleClass + "> . \n" +
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
||||||
"?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . ";
|
"?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . ";
|
||||||
|
|
||||||
final static String firstNameAssertion =
|
final static String firstNameAssertion =
|
||||||
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newAdvisor <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardAdvisor . \n" +
|
"?newAdvisor <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardAdvisor . \n" +
|
||||||
"?vcardAdvisor <http://purl.obolibrary.org/obo/ARG_2000029> ?newAdvisor . \n" +
|
"?vcardAdvisor <http://purl.obolibrary.org/obo/ARG_2000029> ?newAdvisor . \n" +
|
||||||
"?vcardAdvisor a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?vcardAdvisor a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?vcardAdvisor vcard:hasName ?vcardName . \n" +
|
"?vcardAdvisor vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
||||||
"?vcardName vcard:givenName ?firstName .";
|
"?vcardName vcard:givenName ?firstName .";
|
||||||
|
|
||||||
final static String lastNameAssertion =
|
final static String lastNameAssertion =
|
||||||
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newAdvisor <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardAdvisor . \n" +
|
"?newAdvisor <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardAdvisor . \n" +
|
||||||
"?vcardAdvisor <http://purl.obolibrary.org/obo/ARG_2000029> ?newAdvisor . \n" +
|
"?vcardAdvisor <http://purl.obolibrary.org/obo/ARG_2000029> ?newAdvisor . \n" +
|
||||||
"?vcardAdvisor a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?vcardAdvisor a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?vcardAdvisor vcard:hasName ?vcardName . \n" +
|
"?vcardAdvisor vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
||||||
"?vcardName vcard:familyName ?lastName .";
|
"?vcardName vcard:familyName ?lastName .";
|
||||||
|
|
||||||
final static String degreeAssertion =
|
final static String degreeAssertion =
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#degreeCandidacy> ?degree . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#degreeCandidacy> ?degree . \n" +
|
||||||
" ";
|
" ";
|
||||||
|
|
||||||
//This is for an existing subject area
|
//This is for an existing subject area
|
||||||
//Where we only need the existing subject area label
|
//Where we only need the existing subject area label
|
||||||
final static String n3ForExistingSubjAreaAssertion =
|
final static String n3ForExistingSubjAreaAssertion =
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#hasSubjectArea> ?existingSubjArea . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#hasSubjectArea> ?existingSubjArea . \n" +
|
||||||
"?existingSubjArea <http://vivoweb.org/ontology/core#subjectAreaOf> ?advisingRelationship . ";
|
"?existingSubjArea <http://vivoweb.org/ontology/core#subjectAreaOf> ?advisingRelationship . ";
|
||||||
//For new subject area, we include all new information
|
//For new subject area, we include all new information
|
||||||
//new subject area should always be a new resource
|
//new subject area should always be a new resource
|
||||||
//and the following should only get evaluated
|
//and the following should only get evaluated
|
||||||
//when there is something in the label
|
//when there is something in the label
|
||||||
|
|
||||||
final static String n3ForNewSubjAreaAssertion =
|
final static String n3ForNewSubjAreaAssertion =
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#hasSubjectArea> ?newSubjArea . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#hasSubjectArea> ?newSubjArea . \n" +
|
||||||
"?newSubjArea <http://vivoweb.org/ontology/core#subjectAreaOf> ?advisingRelationship . \n" +
|
"?newSubjArea <http://vivoweb.org/ontology/core#subjectAreaOf> ?advisingRelationship . \n" +
|
||||||
"?newSubjArea <"+ label + "> ?subjAreaLabel . \n" +
|
"?newSubjArea <"+ label + "> ?subjAreaLabel . \n" +
|
||||||
"?newSubjArea a <" + subjAreaClass + "> . ";
|
"?newSubjArea a <" + subjAreaClass + "> . ";
|
||||||
|
|
||||||
final static String n3ForStart =
|
final static String n3ForStart =
|
||||||
"?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
"?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
||||||
"?intervalNode a <" + intervalType + "> . \n" +
|
"?intervalNode a <" + intervalType + "> . \n" +
|
||||||
"?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
"?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
"?startNode a <" + dateTimeValueType + "> . \n" +
|
"?startNode a <" + dateTimeValueType + "> . \n" +
|
||||||
"?startNode <" + dateTimeValue + "> ?startField-value . \n" +
|
"?startNode <" + dateTimeValue + "> ?startField-value . \n" +
|
||||||
"?startNode <" + dateTimePrecision + "> ?startField-precision . \n";
|
"?startNode <" + dateTimePrecision + "> ?startField-precision . \n";
|
||||||
|
|
||||||
final static String n3ForEnd =
|
final static String n3ForEnd =
|
||||||
"?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
"?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
||||||
"?intervalNode a <" + intervalType + "> . \n" +
|
"?intervalNode a <" + intervalType + "> . \n" +
|
||||||
"?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
"?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
||||||
"?endNode a <" + dateTimeValueType + "> . \n" +
|
"?endNode a <" + dateTimeValueType + "> . \n" +
|
||||||
|
@ -286,7 +286,7 @@ public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
|
|
||||||
/* Queries for editing an existing entry */
|
/* Queries for editing an existing entry */
|
||||||
|
|
||||||
final static String existingAdvisingRelQuery =
|
final static String existingAdvisingRelQuery =
|
||||||
"SELECT ?advisingRelationship WHERE { \n" +
|
"SELECT ?advisingRelationship WHERE { \n" +
|
||||||
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
||||||
|
@ -297,7 +297,7 @@ public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
"SELECT ?advisingRelType WHERE { \n" +
|
"SELECT ?advisingRelType WHERE { \n" +
|
||||||
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
||||||
" ?advisingRelationship vitro:mostSpecificType ?advisingRelType . \n" +
|
" ?advisingRelationship vitro:mostSpecificType ?advisingRelType . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String advisingRelLabelQuery =
|
final static String advisingRelLabelQuery =
|
||||||
|
@ -307,7 +307,7 @@ public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
" ?advisingRelationship <" + label + "> ?existingAdvisingRelLabel . \n" +
|
" ?advisingRelationship <" + label + "> ?existingAdvisingRelLabel . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String advisorQuery =
|
final static String advisorQuery =
|
||||||
"SELECT ?existingAdvisor WHERE { \n" +
|
"SELECT ?existingAdvisor WHERE { \n" +
|
||||||
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
||||||
|
@ -330,13 +330,13 @@ public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
" ?existingAdvisorRole a <" + advisorRoleClass + "> . \n" +
|
" ?existingAdvisorRole a <" + advisorRoleClass + "> . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String existingAdvisorRoleQuery =
|
final static String existingAdvisorRoleQuery =
|
||||||
"SELECT ?existingAdvisorRole WHERE { \n" +
|
"SELECT ?existingAdvisorRole WHERE { \n" +
|
||||||
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?existingAdvisorRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?existingAdvisorRole . \n" +
|
||||||
" ?existingAdvisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?existingAdvisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?existingAdvisorRole a <" + advisorRoleClass + "> . \n" +
|
" ?existingAdvisorRole a <" + advisorRoleClass + "> . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String subjAreaQuery =
|
final static String subjAreaQuery =
|
||||||
|
@ -348,7 +348,7 @@ public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
" ?existingSubjArea <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> ?type \n" +
|
" ?existingSubjArea <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> ?type \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String subjAreaLabelQuery =
|
final static String subjAreaLabelQuery =
|
||||||
"SELECT ?existingSubjAreaLabel WHERE { \n" +
|
"SELECT ?existingSubjAreaLabel WHERE { \n" +
|
||||||
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
||||||
|
@ -358,14 +358,14 @@ public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
" ?existingSubjArea <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> ?type \n" +
|
" ?existingSubjArea <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> ?type \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String degreeQuery =
|
final static String degreeQuery =
|
||||||
"SELECT ?existingDegree WHERE {\n"+
|
"SELECT ?existingDegree WHERE {\n"+
|
||||||
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#degreeCandidacy> ?existingDegree . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#degreeCandidacy> ?existingDegree . \n" +
|
||||||
" ?existingDegree a <" + degreeClass + "> . \n" +
|
" ?existingDegree a <" + degreeClass + "> . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String existingStartDateQuery =
|
final static String existingStartDateQuery =
|
||||||
"SELECT ?existingDateStart WHERE { \n" +
|
"SELECT ?existingDateStart WHERE { \n" +
|
||||||
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
|
@ -375,7 +375,7 @@ public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
" ?startNode a <" + dateTimeValueType +"> . \n" +
|
" ?startNode a <" + dateTimeValueType +"> . \n" +
|
||||||
" ?startNode <" + dateTimeValue + "> ?existingDateStart . }";
|
" ?startNode <" + dateTimeValue + "> ?existingDateStart . }";
|
||||||
|
|
||||||
final static String existingEndDateQuery =
|
final static String existingEndDateQuery =
|
||||||
"SELECT ?existingEndDate WHERE { \n" +
|
"SELECT ?existingEndDate WHERE { \n" +
|
||||||
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
|
@ -387,48 +387,48 @@ public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
" ?endNode <" + dateTimeValue + "> ?existingEndDate . }";
|
" ?endNode <" + dateTimeValue + "> ?existingEndDate . }";
|
||||||
|
|
||||||
final static String existingIntervalNodeQuery =
|
final static String existingIntervalNodeQuery =
|
||||||
"SELECT ?existingIntervalNode WHERE { \n" +
|
"SELECT ?existingIntervalNode WHERE { \n" +
|
||||||
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
||||||
" ?advisingRelationship <" + advisingRelToInterval + "> ?existingIntervalNode . \n" +
|
" ?advisingRelationship <" + advisingRelToInterval + "> ?existingIntervalNode . \n" +
|
||||||
" ?existingIntervalNode a <" + intervalType + "> . }";
|
" ?existingIntervalNode a <" + intervalType + "> . }";
|
||||||
|
|
||||||
final static String existingStartNodeQuery =
|
final static String existingStartNodeQuery =
|
||||||
"SELECT ?existingStartNode WHERE { \n" +
|
"SELECT ?existingStartNode WHERE { \n" +
|
||||||
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
||||||
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToStart + "> ?existingStartNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?existingStartNode . \n" +
|
||||||
" ?existingStartNode a <" + dateTimeValueType + "> .} ";
|
" ?existingStartNode a <" + dateTimeValueType + "> .} ";
|
||||||
|
|
||||||
final static String existingEndNodeQuery =
|
final static String existingEndNodeQuery =
|
||||||
"SELECT ?existingEndNode WHERE { \n" +
|
"SELECT ?existingEndNode WHERE { \n" +
|
||||||
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
||||||
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToEnd + "> ?existingEndNode . \n" +
|
" ?intervalNode <" + intervalToEnd + "> ?existingEndNode . \n" +
|
||||||
" ?existingEndNode a <" + dateTimeValueType + "> } ";
|
" ?existingEndNode a <" + dateTimeValueType + "> } ";
|
||||||
|
|
||||||
final static String existingStartPrecisionQuery =
|
final static String existingStartPrecisionQuery =
|
||||||
"SELECT ?existingStartPrecision WHERE { \n" +
|
"SELECT ?existingStartPrecision WHERE { \n" +
|
||||||
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
||||||
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
" ?startNode a <" + dateTimeValueType + "> . \n" +
|
" ?startNode a <" + dateTimeValueType + "> . \n" +
|
||||||
" ?startNode <" + dateTimePrecision + "> ?existingStartPrecision . }";
|
" ?startNode <" + dateTimePrecision + "> ?existingStartPrecision . }";
|
||||||
|
|
||||||
final static String existingEndPrecisionQuery =
|
final static String existingEndPrecisionQuery =
|
||||||
"SELECT ?existingEndPrecision WHERE { \n" +
|
"SELECT ?existingEndPrecision WHERE { \n" +
|
||||||
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
||||||
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
" ?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
||||||
" ?endNode a <" + dateTimeValueType + "> . \n" +
|
" ?endNode a <" + dateTimeValueType + "> . \n" +
|
||||||
" ?endNode <" + dateTimePrecision + "> ?existingEndPrecision . }";
|
" ?endNode <" + dateTimePrecision + "> ?existingEndPrecision . }";
|
||||||
|
|
||||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
|
@ -438,10 +438,10 @@ public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSparqlForAcFilter(VitroRequest vreq) {
|
public String getSparqlForAcFilter(VitroRequest vreq) {
|
||||||
String subject = EditConfigurationUtils.getSubjectUri(vreq);
|
String subject = EditConfigurationUtils.getSubjectUri(vreq);
|
||||||
String predicate = EditConfigurationUtils.getPredicateUri(vreq);
|
String predicate = EditConfigurationUtils.getPredicateUri(vreq);
|
||||||
//Get all objects for existing predicate, filters out results from addition and edit
|
//Get all objects for existing predicate, filters out results from addition and edit
|
||||||
String query = "SELECT ?objectVar WHERE { " +
|
String query = "SELECT ?objectVar WHERE { " +
|
||||||
"<" + subject + "> <" + predicate + "> ?objectVar .} ";
|
"<" + subject + "> <" + predicate + "> ?objectVar .} ";
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,25 +37,25 @@ public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
final static String dateTimeValueType = vivoCore + "DateTimeValue";
|
final static String dateTimeValueType = vivoCore + "DateTimeValue";
|
||||||
final static String dateTimeValue = vivoCore + "dateTime";
|
final static String dateTimeValue = vivoCore + "dateTime";
|
||||||
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
|
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
|
||||||
|
|
||||||
public PersonHasAdvisorRelationshipGenerator() {}
|
public PersonHasAdvisorRelationshipGenerator() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
HttpSession session) throws Exception {
|
HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
|
|
||||||
conf.setTemplate("personHasAdvisorRelationship.ftl");
|
conf.setTemplate("personHasAdvisorRelationship.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("person");
|
conf.setVarNameForSubject("person");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("advisorRole");
|
conf.setVarNameForObject("advisorRole");
|
||||||
|
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewAdvisingRelationship,
|
conf.setN3Required( Arrays.asList( n3ForNewAdvisingRelationship,
|
||||||
advisingRelLabelAssertion,
|
advisingRelLabelAssertion,
|
||||||
advisingRelTypeAssertion ) );
|
advisingRelTypeAssertion ) );
|
||||||
|
@ -66,9 +66,9 @@ public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
lastNameAssertion,
|
lastNameAssertion,
|
||||||
n3ForExistingSubjAreaAssertion, //relationship to existing subject area
|
n3ForExistingSubjAreaAssertion, //relationship to existing subject area
|
||||||
n3ForNewSubjAreaAssertion, //this will include all the new information that needs to be captured
|
n3ForNewSubjAreaAssertion, //this will include all the new information that needs to be captured
|
||||||
n3ForStart,
|
n3ForStart,
|
||||||
n3ForEnd ) );
|
n3ForEnd ) );
|
||||||
|
|
||||||
conf.addNewResource("advisingRelationship", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("advisingRelationship", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("newAdvisee", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("newAdvisee", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("vcardAdvisee", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("vcardAdvisee", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
@ -79,19 +79,19 @@ public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
//uris in scope: none
|
//uris in scope: none
|
||||||
//literals in scope: none
|
//literals in scope: none
|
||||||
|
|
||||||
conf.setUrisOnform(Arrays.asList("advisingRelType", "existingSubjArea", "degree", "existingAdvisee"));
|
conf.setUrisOnform(Arrays.asList("advisingRelType", "existingSubjArea", "degree", "existingAdvisee"));
|
||||||
conf.setLiteralsOnForm(Arrays.asList("advisingRelLabel", "subjAreaLabel", "adviseeLabel", "firstName", "lastName", "subjAreaLabelDisplay", "adviseeLabelDisplay" ));
|
conf.setLiteralsOnForm(Arrays.asList("advisingRelLabel", "subjAreaLabel", "adviseeLabel", "firstName", "lastName", "subjAreaLabelDisplay", "adviseeLabelDisplay" ));
|
||||||
|
|
||||||
conf.addSparqlForExistingLiteral("advisingRelLabel", advisingRelLabelQuery);
|
conf.addSparqlForExistingLiteral("advisingRelLabel", advisingRelLabelQuery);
|
||||||
conf.addSparqlForExistingLiteral("adviseeLabel", adviseeLabelQuery);
|
conf.addSparqlForExistingLiteral("adviseeLabel", adviseeLabelQuery);
|
||||||
conf.addSparqlForExistingLiteral("subjAreaLabel", subjAreaLabelQuery);
|
conf.addSparqlForExistingLiteral("subjAreaLabel", subjAreaLabelQuery);
|
||||||
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
|
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
|
||||||
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
|
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
|
||||||
|
|
||||||
conf.addSparqlForExistingUris("advisingRelType", advisingRelTypeQuery);
|
conf.addSparqlForExistingUris("advisingRelType", advisingRelTypeQuery);
|
||||||
conf.addSparqlForExistingUris("advisingRelationship", existingAdvisingRelQuery);
|
conf.addSparqlForExistingUris("advisingRelationship", existingAdvisingRelQuery);
|
||||||
conf.addSparqlForExistingUris("adviseeRole", existingAdviseeRoleQuery);
|
conf.addSparqlForExistingUris("adviseeRole", existingAdviseeRoleQuery);
|
||||||
|
@ -103,8 +103,8 @@ public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
conf.addSparqlForExistingUris("endNode", existingEndNodeQuery);
|
conf.addSparqlForExistingUris("endNode", existingEndNodeQuery);
|
||||||
conf.addSparqlForExistingUris("startField-precision", existingStartPrecisionQuery);
|
conf.addSparqlForExistingUris("startField-precision", existingStartPrecisionQuery);
|
||||||
conf.addSparqlForExistingUris("endField-precision", existingEndPrecisionQuery);
|
conf.addSparqlForExistingUris("endField-precision", existingEndPrecisionQuery);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("advisingRelType").
|
setName("advisingRelType").
|
||||||
setValidators( list("nonempty") ).
|
setValidators( list("nonempty") ).
|
||||||
setOptions( new ChildVClassesWithParent(advisingRelClass))
|
setOptions( new ChildVClassesWithParent(advisingRelClass))
|
||||||
|
@ -129,8 +129,8 @@ public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo(). // options set by auto complete JS
|
conf.addField( new FieldVTwo(). // options set by auto complete JS
|
||||||
setName("existingSubjArea")
|
setName("existingSubjArea")
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("subjAreaLabel").
|
setName("subjAreaLabel").
|
||||||
|
@ -140,13 +140,13 @@ public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("degree").
|
setName("degree").
|
||||||
setOptions(
|
setOptions(
|
||||||
new IndividualsViaVClassOptions(degreeClass))
|
new IndividualsViaVClassOptions(degreeClass))
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo(). // options set by auto complete JS
|
conf.addField( new FieldVTwo(). // options set by auto complete JS
|
||||||
setName("existingAdvisee")
|
setName("existingAdvisee")
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("adviseeLabel").
|
setName("adviseeLabel").
|
||||||
|
@ -167,16 +167,16 @@ public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().setName("startField").
|
conf.addField( new FieldVTwo().setName("startField").
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(null,
|
new DateTimeWithPrecisionVTwo(null,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())
|
VitroVocabulary.Precision.NONE.uri())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().setName("endField").
|
conf.addField( new FieldVTwo().setName("endField").
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(null,
|
new DateTimeWithPrecisionVTwo(null,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())
|
VitroVocabulary.Precision.NONE.uri())
|
||||||
)
|
)
|
||||||
|
@ -186,98 +186,98 @@ public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
conf.addValidator(new FirstAndLastNameValidator("existingAdvisee"));
|
conf.addValidator(new FirstAndLastNameValidator("existingAdvisee"));
|
||||||
addFormSpecificData(conf, vreq);
|
addFormSpecificData(conf, vreq);
|
||||||
|
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* N3 assertions */
|
/* N3 assertions */
|
||||||
|
|
||||||
final static String n3ForNewAdvisingRelationship =
|
final static String n3ForNewAdvisingRelationship =
|
||||||
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
||||||
"?person <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
"?person <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
"?advisingRelationship a <" + advisingRelClass + "> . \n" +
|
"?advisingRelationship a <" + advisingRelClass + "> . \n" +
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?person . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?person . \n" +
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
||||||
"?advisorRole a <" + advisorRoleClass + "> . \n" +
|
"?advisorRole a <" + advisorRoleClass + "> . \n" +
|
||||||
"?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
"?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
"?person <http://purl.obolibrary.org/obo/RO_0000053> ?advisorRole . \n" +
|
"?person <http://purl.obolibrary.org/obo/RO_0000053> ?advisorRole . \n" +
|
||||||
"?advisorRole <http://purl.obolibrary.org/obo/RO_0000052> ?person . ";
|
"?advisorRole <http://purl.obolibrary.org/obo/RO_0000052> ?person . ";
|
||||||
|
|
||||||
final static String advisingRelLabelAssertion =
|
final static String advisingRelLabelAssertion =
|
||||||
"?advisingRelationship <"+ label + "> ?advisingRelLabel .";
|
"?advisingRelationship <"+ label + "> ?advisingRelLabel .";
|
||||||
|
|
||||||
final static String advisingRelTypeAssertion =
|
final static String advisingRelTypeAssertion =
|
||||||
"?advisingRelationship a ?advisingRelType .";
|
"?advisingRelationship a ?advisingRelType .";
|
||||||
|
|
||||||
final static String n3ForNewAdviseeAssertion =
|
final static String n3ForNewAdviseeAssertion =
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?newAdvisee . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?newAdvisee . \n" +
|
||||||
"?newAdvisee <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
"?newAdvisee <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
"?newAdvisee <" + label + "> ?adviseeLabel . \n" +
|
"?newAdvisee <" + label + "> ?adviseeLabel . \n" +
|
||||||
"?newAdvisee a <" + adviseeClass + "> . \n" +
|
"?newAdvisee a <" + adviseeClass + "> . \n" +
|
||||||
"?newAdvisee <http://purl.obolibrary.org/obo/RO_0000053> ?adviseeRole . \n" +
|
"?newAdvisee <http://purl.obolibrary.org/obo/RO_0000053> ?adviseeRole . \n" +
|
||||||
"?adviseeRole <http://purl.obolibrary.org/obo/RO_0000052> ?newAdvisee . \n" +
|
"?adviseeRole <http://purl.obolibrary.org/obo/RO_0000052> ?newAdvisee . \n" +
|
||||||
"?adviseeRole a <" + adviseeRoleClass + "> . \n" +
|
"?adviseeRole a <" + adviseeRoleClass + "> . \n" +
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
||||||
"?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . ";
|
"?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . ";
|
||||||
|
|
||||||
final static String n3ForExistingAdviseeAssertion =
|
final static String n3ForExistingAdviseeAssertion =
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?existingAdvisee . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?existingAdvisee . \n" +
|
||||||
"?existingAdvisee <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
"?existingAdvisee <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
"?existingAdvisee <http://purl.obolibrary.org/obo/RO_0000053> ?adviseeRole . \n" +
|
"?existingAdvisee <http://purl.obolibrary.org/obo/RO_0000053> ?adviseeRole . \n" +
|
||||||
"?adviseeRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingAdvisee . \n" +
|
"?adviseeRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingAdvisee . \n" +
|
||||||
"?adviseeRole a <" + adviseeRoleClass + "> . \n" +
|
"?adviseeRole a <" + adviseeRoleClass + "> . \n" +
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
|
||||||
"?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . ";
|
"?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . ";
|
||||||
|
|
||||||
final static String firstNameAssertion =
|
final static String firstNameAssertion =
|
||||||
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newAdvisee <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardAdvisee . \n" +
|
"?newAdvisee <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardAdvisee . \n" +
|
||||||
"?vcardAdvisee <http://purl.obolibrary.org/obo/ARG_2000029> ?newAdvisee . \n" +
|
"?vcardAdvisee <http://purl.obolibrary.org/obo/ARG_2000029> ?newAdvisee . \n" +
|
||||||
"?vcardAdvisee a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?vcardAdvisee a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?vcardAdvisee vcard:hasName ?vcardName . \n" +
|
"?vcardAdvisee vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
||||||
"?vcardName vcard:givenName ?firstName .";
|
"?vcardName vcard:givenName ?firstName .";
|
||||||
|
|
||||||
final static String lastNameAssertion =
|
final static String lastNameAssertion =
|
||||||
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newAdvisee <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardAdvisee . \n" +
|
"?newAdvisee <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardAdvisee . \n" +
|
||||||
"?vcardAdvisee <http://purl.obolibrary.org/obo/ARG_2000029> ?newAdvisee . \n" +
|
"?vcardAdvisee <http://purl.obolibrary.org/obo/ARG_2000029> ?newAdvisee . \n" +
|
||||||
"?vcardAdvisee a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?vcardAdvisee a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?vcardAdvisee vcard:hasName ?vcardName . \n" +
|
"?vcardAdvisee vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
||||||
"?vcardName vcard:familyName ?lastName .";
|
"?vcardName vcard:familyName ?lastName .";
|
||||||
|
|
||||||
final static String degreeAssertion =
|
final static String degreeAssertion =
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#degreeCandidacy> ?degree . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#degreeCandidacy> ?degree . \n" +
|
||||||
" ";
|
" ";
|
||||||
|
|
||||||
//This is for an existing subject area
|
//This is for an existing subject area
|
||||||
//Where we only need the existing subject area label
|
//Where we only need the existing subject area label
|
||||||
final static String n3ForExistingSubjAreaAssertion =
|
final static String n3ForExistingSubjAreaAssertion =
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#hasSubjectArea> ?existingSubjArea . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#hasSubjectArea> ?existingSubjArea . \n" +
|
||||||
"?existingSubjArea <http://vivoweb.org/ontology/core#subjectAreaOf> ?advisingRelationship";
|
"?existingSubjArea <http://vivoweb.org/ontology/core#subjectAreaOf> ?advisingRelationship";
|
||||||
//For new subject area, we include all new information
|
//For new subject area, we include all new information
|
||||||
//new subject area should always be a new resource
|
//new subject area should always be a new resource
|
||||||
//and the following should only get evaluated
|
//and the following should only get evaluated
|
||||||
//when there is something in the label
|
//when there is something in the label
|
||||||
|
|
||||||
final static String n3ForNewSubjAreaAssertion =
|
final static String n3ForNewSubjAreaAssertion =
|
||||||
"?advisingRelationship <http://vivoweb.org/ontology/core#hasSubjectArea> ?newSubjArea . \n" +
|
"?advisingRelationship <http://vivoweb.org/ontology/core#hasSubjectArea> ?newSubjArea . \n" +
|
||||||
"?newSubjArea <http://vivoweb.org/ontology/core#subjectAreaOf> ?advisingRelationship . \n" +
|
"?newSubjArea <http://vivoweb.org/ontology/core#subjectAreaOf> ?advisingRelationship . \n" +
|
||||||
"?newSubjArea <"+ label + "> ?subjAreaLabel . \n" +
|
"?newSubjArea <"+ label + "> ?subjAreaLabel . \n" +
|
||||||
"?newSubjArea a <" + subjAreaClass + "> . ";
|
"?newSubjArea a <" + subjAreaClass + "> . ";
|
||||||
|
|
||||||
final static String n3ForStart =
|
final static String n3ForStart =
|
||||||
"?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
"?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
||||||
"?intervalNode a <" + intervalType + "> . \n" +
|
"?intervalNode a <" + intervalType + "> . \n" +
|
||||||
"?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
"?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
"?startNode a <" + dateTimeValueType + "> . \n" +
|
"?startNode a <" + dateTimeValueType + "> . \n" +
|
||||||
"?startNode <" + dateTimeValue + "> ?startField-value . \n" +
|
"?startNode <" + dateTimeValue + "> ?startField-value . \n" +
|
||||||
"?startNode <" + dateTimePrecision + "> ?startField-precision . \n";
|
"?startNode <" + dateTimePrecision + "> ?startField-precision . \n";
|
||||||
|
|
||||||
final static String n3ForEnd =
|
final static String n3ForEnd =
|
||||||
"?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
"?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
||||||
"?intervalNode a <" + intervalType + "> . \n" +
|
"?intervalNode a <" + intervalType + "> . \n" +
|
||||||
"?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
"?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
||||||
"?endNode a <" + dateTimeValueType + "> . \n" +
|
"?endNode a <" + dateTimeValueType + "> . \n" +
|
||||||
|
@ -286,7 +286,7 @@ public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
|
|
||||||
/* Queries for editing an existing entry */
|
/* Queries for editing an existing entry */
|
||||||
|
|
||||||
final static String existingAdvisingRelQuery =
|
final static String existingAdvisingRelQuery =
|
||||||
"SELECT ?advisingRelationship WHERE { \n" +
|
"SELECT ?advisingRelationship WHERE { \n" +
|
||||||
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
||||||
|
@ -294,10 +294,10 @@ public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
|
|
||||||
final static String advisingRelTypeQuery =
|
final static String advisingRelTypeQuery =
|
||||||
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
||||||
"SELECT ?advisingRelType WHERE { \n" +
|
"SELECT ?advisingRelType WHERE { \n" +
|
||||||
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
||||||
" ?advisingRelationship vitro:mostSpecificType ?advisingRelType . \n" +
|
" ?advisingRelationship vitro:mostSpecificType ?advisingRelType . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String advisingRelLabelQuery =
|
final static String advisingRelLabelQuery =
|
||||||
|
@ -307,7 +307,7 @@ public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
" ?advisingRelationship <" + label + "> ?existingAdvisingRelLabel . \n" +
|
" ?advisingRelationship <" + label + "> ?existingAdvisingRelLabel . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String adviseeQuery =
|
final static String adviseeQuery =
|
||||||
"SELECT ?existingAdvisee WHERE { \n" +
|
"SELECT ?existingAdvisee WHERE { \n" +
|
||||||
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
||||||
|
@ -332,13 +332,13 @@ public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
" ?existingAdviseeRole a <" + adviseeRoleClass + "> . \n" +
|
" ?existingAdviseeRole a <" + adviseeRoleClass + "> . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String existingAdviseeRoleQuery =
|
final static String existingAdviseeRoleQuery =
|
||||||
"SELECT ?existingAdviseeRole WHERE { \n" +
|
"SELECT ?existingAdviseeRole WHERE { \n" +
|
||||||
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?existingAdviseeRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?existingAdviseeRole . \n" +
|
||||||
" ?existingAdviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?existingAdviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?existingAdviseeRole a <" + adviseeRoleClass + "> . \n" +
|
" ?existingAdviseeRole a <" + adviseeRoleClass + "> . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String subjAreaQuery =
|
final static String subjAreaQuery =
|
||||||
|
@ -350,7 +350,7 @@ public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
" ?existingSubjArea <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> ?type \n" +
|
" ?existingSubjArea <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> ?type \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String subjAreaLabelQuery =
|
final static String subjAreaLabelQuery =
|
||||||
"SELECT ?existingSubjAreaLabel WHERE { \n" +
|
"SELECT ?existingSubjAreaLabel WHERE { \n" +
|
||||||
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
||||||
|
@ -360,14 +360,14 @@ public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
" ?existingSubjArea <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> ?type \n" +
|
" ?existingSubjArea <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> ?type \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String degreeQuery =
|
final static String degreeQuery =
|
||||||
"SELECT ?existingDegree WHERE {\n"+
|
"SELECT ?existingDegree WHERE {\n"+
|
||||||
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#degreeCandidacy> ?existingDegree . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#degreeCandidacy> ?existingDegree . \n" +
|
||||||
" ?existingDegree a <" + degreeClass + "> . \n" +
|
" ?existingDegree a <" + degreeClass + "> . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String existingStartDateQuery =
|
final static String existingStartDateQuery =
|
||||||
"SELECT ?existingDateStart WHERE { \n" +
|
"SELECT ?existingDateStart WHERE { \n" +
|
||||||
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
|
@ -377,7 +377,7 @@ public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
" ?startNode a <" + dateTimeValueType +"> . \n" +
|
" ?startNode a <" + dateTimeValueType +"> . \n" +
|
||||||
" ?startNode <" + dateTimeValue + "> ?existingDateStart . }";
|
" ?startNode <" + dateTimeValue + "> ?existingDateStart . }";
|
||||||
|
|
||||||
final static String existingEndDateQuery =
|
final static String existingEndDateQuery =
|
||||||
"SELECT ?existingEndDate WHERE { \n" +
|
"SELECT ?existingEndDate WHERE { \n" +
|
||||||
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
|
@ -389,48 +389,48 @@ public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
" ?endNode <" + dateTimeValue + "> ?existingEndDate . }";
|
" ?endNode <" + dateTimeValue + "> ?existingEndDate . }";
|
||||||
|
|
||||||
final static String existingIntervalNodeQuery =
|
final static String existingIntervalNodeQuery =
|
||||||
"SELECT ?existingIntervalNode WHERE { \n" +
|
"SELECT ?existingIntervalNode WHERE { \n" +
|
||||||
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
||||||
" ?advisingRelationship <" + advisingRelToInterval + "> ?existingIntervalNode . \n" +
|
" ?advisingRelationship <" + advisingRelToInterval + "> ?existingIntervalNode . \n" +
|
||||||
" ?existingIntervalNode a <" + intervalType + "> . }";
|
" ?existingIntervalNode a <" + intervalType + "> . }";
|
||||||
|
|
||||||
final static String existingStartNodeQuery =
|
final static String existingStartNodeQuery =
|
||||||
"SELECT ?existingStartNode WHERE { \n" +
|
"SELECT ?existingStartNode WHERE { \n" +
|
||||||
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
||||||
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToStart + "> ?existingStartNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?existingStartNode . \n" +
|
||||||
" ?existingStartNode a <" + dateTimeValueType + "> .} ";
|
" ?existingStartNode a <" + dateTimeValueType + "> .} ";
|
||||||
|
|
||||||
final static String existingEndNodeQuery =
|
final static String existingEndNodeQuery =
|
||||||
"SELECT ?existingEndNode WHERE { \n" +
|
"SELECT ?existingEndNode WHERE { \n" +
|
||||||
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
||||||
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToEnd + "> ?existingEndNode . \n" +
|
" ?intervalNode <" + intervalToEnd + "> ?existingEndNode . \n" +
|
||||||
" ?existingEndNode a <" + dateTimeValueType + "> } ";
|
" ?existingEndNode a <" + dateTimeValueType + "> } ";
|
||||||
|
|
||||||
final static String existingStartPrecisionQuery =
|
final static String existingStartPrecisionQuery =
|
||||||
"SELECT ?existingStartPrecision WHERE { \n" +
|
"SELECT ?existingStartPrecision WHERE { \n" +
|
||||||
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
||||||
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
" ?startNode a <" + dateTimeValueType + "> . \n" +
|
" ?startNode a <" + dateTimeValueType + "> . \n" +
|
||||||
" ?startNode <" + dateTimePrecision + "> ?existingStartPrecision . }";
|
" ?startNode <" + dateTimePrecision + "> ?existingStartPrecision . }";
|
||||||
|
|
||||||
final static String existingEndPrecisionQuery =
|
final static String existingEndPrecisionQuery =
|
||||||
"SELECT ?existingEndPrecision WHERE { \n" +
|
"SELECT ?existingEndPrecision WHERE { \n" +
|
||||||
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
" ?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
|
||||||
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
|
||||||
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
" ?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
||||||
" ?endNode a <" + dateTimeValueType + "> . \n" +
|
" ?endNode a <" + dateTimeValueType + "> . \n" +
|
||||||
" ?endNode <" + dateTimePrecision + "> ?existingEndPrecision . }";
|
" ?endNode <" + dateTimePrecision + "> ?existingEndPrecision . }";
|
||||||
|
|
||||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
|
@ -440,10 +440,10 @@ public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator imp
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSparqlForAcFilter(VitroRequest vreq) {
|
public String getSparqlForAcFilter(VitroRequest vreq) {
|
||||||
String subject = EditConfigurationUtils.getSubjectUri(vreq);
|
String subject = EditConfigurationUtils.getSubjectUri(vreq);
|
||||||
String predicate = EditConfigurationUtils.getPredicateUri(vreq);
|
String predicate = EditConfigurationUtils.getPredicateUri(vreq);
|
||||||
//Get all objects for existing predicate, filters out results from addition and edit
|
//Get all objects for existing predicate, filters out results from addition and edit
|
||||||
String query = "SELECT ?objectVar WHERE { " +
|
String query = "SELECT ?objectVar WHERE { " +
|
||||||
"<" + subject + "> <" + predicate + "> ?objectVar .} ";
|
"<" + subject + "> <" + predicate + "> ?objectVar .} ";
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,38 +38,38 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
||||||
final static String dateTimeValueType = vivoCore + "DateTimeValue";
|
final static String dateTimeValueType = vivoCore + "DateTimeValue";
|
||||||
final static String dateTimeValue = vivoCore + "dateTime";
|
final static String dateTimeValue = vivoCore + "dateTime";
|
||||||
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
|
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
|
||||||
|
|
||||||
public PersonHasAwardOrHonorGenerator() {}
|
public PersonHasAwardOrHonorGenerator() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
HttpSession session) throws Exception {
|
HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
|
|
||||||
conf.setTemplate("personHasAwardOrHonor.ftl");
|
conf.setTemplate("personHasAwardOrHonor.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("person");
|
conf.setVarNameForSubject("person");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("awardReceipt");
|
conf.setVarNameForObject("awardReceipt");
|
||||||
|
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewAwardReceipt,
|
conf.setN3Required( Arrays.asList( n3ForNewAwardReceipt,
|
||||||
awardReceiptLabelAssertion ) );
|
awardReceiptLabelAssertion ) );
|
||||||
conf.setN3Optional( Arrays.asList( n3ForNewAwardAssertion,
|
conf.setN3Optional( Arrays.asList( n3ForNewAwardAssertion,
|
||||||
n3ForExistingAwardAssertion,
|
n3ForExistingAwardAssertion,
|
||||||
descriptionAssertion,
|
descriptionAssertion,
|
||||||
n3ForNewOrgNewAwardAssertion,
|
n3ForNewOrgNewAwardAssertion,
|
||||||
n3ForExistingOrgNewAwardAssertion,
|
n3ForExistingOrgNewAwardAssertion,
|
||||||
n3ForNewOrgExistingAwardAssertion,
|
n3ForNewOrgExistingAwardAssertion,
|
||||||
n3ForExistingOrgExistingAwardAssertion,
|
n3ForExistingOrgExistingAwardAssertion,
|
||||||
n3ForYearAwarded,
|
n3ForYearAwarded,
|
||||||
n3ForStart,
|
n3ForStart,
|
||||||
n3ForEnd ) );
|
n3ForEnd ) );
|
||||||
|
|
||||||
conf.addNewResource("award", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("award", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("awardReceipt", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("awardReceipt", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("newOrg", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("newOrg", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
@ -77,13 +77,13 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
||||||
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
//uris in scope: none
|
//uris in scope: none
|
||||||
//literals in scope: none
|
//literals in scope: none
|
||||||
|
|
||||||
conf.setUrisOnform(Arrays.asList("existingAward", "existingOrg"));
|
conf.setUrisOnform(Arrays.asList("existingAward", "existingOrg"));
|
||||||
conf.setLiteralsOnForm(Arrays.asList("description", "awardReceiptLabel", "awardLabel", "orgLabel", "yearAwardedDisplay", "orgLabelDisplay", "awardLabelDisplay" ));
|
conf.setLiteralsOnForm(Arrays.asList("description", "awardReceiptLabel", "awardLabel", "orgLabel", "yearAwardedDisplay", "orgLabelDisplay", "awardLabelDisplay" ));
|
||||||
|
|
||||||
conf.addSparqlForExistingLiteral("awardReceiptLabel", awardReceiptLabelQuery);
|
conf.addSparqlForExistingLiteral("awardReceiptLabel", awardReceiptLabelQuery);
|
||||||
conf.addSparqlForExistingLiteral("awardLabel", awardLabelQuery);
|
conf.addSparqlForExistingLiteral("awardLabel", awardLabelQuery);
|
||||||
conf.addSparqlForExistingLiteral("orgLabel", orgLabelQuery);
|
conf.addSparqlForExistingLiteral("orgLabel", orgLabelQuery);
|
||||||
|
@ -91,9 +91,9 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
||||||
conf.addSparqlForExistingLiteral("yearAwarded-value", existingYearAwardedQuery);
|
conf.addSparqlForExistingLiteral("yearAwarded-value", existingYearAwardedQuery);
|
||||||
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
|
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
|
||||||
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
|
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
|
||||||
|
|
||||||
conf.addSparqlForExistingUris("existingAward", existingAwardQuery);
|
conf.addSparqlForExistingUris("existingAward", existingAwardQuery);
|
||||||
conf.addSparqlForExistingUris("existingOrg", existingOrgQuery);
|
conf.addSparqlForExistingUris("existingOrg", existingOrgQuery);
|
||||||
conf.addSparqlForExistingUris("yearAwardedNode",existingYearAwardedNodeQuery);
|
conf.addSparqlForExistingUris("yearAwardedNode",existingYearAwardedNodeQuery);
|
||||||
conf.addSparqlForExistingUris("intervalNode",existingIntervalNodeQuery);
|
conf.addSparqlForExistingUris("intervalNode",existingIntervalNodeQuery);
|
||||||
conf.addSparqlForExistingUris("startNode", existingStartNodeQuery);
|
conf.addSparqlForExistingUris("startNode", existingStartNodeQuery);
|
||||||
|
@ -101,20 +101,20 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
||||||
conf.addSparqlForExistingUris("yearAwarded-precision", existingYearAwardedPrecisionQuery);
|
conf.addSparqlForExistingUris("yearAwarded-precision", existingYearAwardedPrecisionQuery);
|
||||||
conf.addSparqlForExistingUris("startField-precision", existingStartPrecisionQuery);
|
conf.addSparqlForExistingUris("startField-precision", existingStartPrecisionQuery);
|
||||||
conf.addSparqlForExistingUris("endField-precision", existingEndPrecisionQuery);
|
conf.addSparqlForExistingUris("endField-precision", existingEndPrecisionQuery);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("description")
|
setName("description")
|
||||||
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators( list("datatype:" + XSD.xstring.toString()) )
|
setValidators( list("datatype:" + XSD.xstring.toString()) )
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo(). // options will be added in browser by auto complete JS
|
conf.addField( new FieldVTwo(). // options will be added in browser by auto complete JS
|
||||||
setName("existingOrg")
|
setName("existingOrg")
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo(). // options will be added in browser by auto complete JS
|
conf.addField( new FieldVTwo(). // options will be added in browser by auto complete JS
|
||||||
setName("existingAward")
|
setName("existingAward")
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("awardReceiptLabel").
|
setName("awardReceiptLabel").
|
||||||
|
@ -153,24 +153,24 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().setName("yearAwarded").
|
conf.addField( new FieldVTwo().setName("yearAwarded").
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(null,
|
new DateTimeWithPrecisionVTwo(null,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())
|
VitroVocabulary.Precision.NONE.uri())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().setName("startField").
|
conf.addField( new FieldVTwo().setName("startField").
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(null,
|
new DateTimeWithPrecisionVTwo(null,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())
|
VitroVocabulary.Precision.NONE.uri())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().setName("endField").
|
conf.addField( new FieldVTwo().setName("endField").
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(null,
|
new DateTimeWithPrecisionVTwo(null,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())
|
VitroVocabulary.Precision.NONE.uri())
|
||||||
)
|
)
|
||||||
|
@ -185,66 +185,66 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
||||||
|
|
||||||
/* N3 assertions */
|
/* N3 assertions */
|
||||||
|
|
||||||
final static String n3ForNewAwardReceipt =
|
final static String n3ForNewAwardReceipt =
|
||||||
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
||||||
"?person <" + awardReceiptPred + "> ?awardReceipt . \n" +
|
"?person <" + awardReceiptPred + "> ?awardReceipt . \n" +
|
||||||
"?awardReceipt a <" + awardReceiptClass + "> . \n" +
|
"?awardReceipt a <" + awardReceiptClass + "> . \n" +
|
||||||
"?awardReceipt <" + awardForPred + "> ?person . " ;
|
"?awardReceipt <" + awardForPred + "> ?person . " ;
|
||||||
|
|
||||||
final static String awardReceiptLabelAssertion =
|
final static String awardReceiptLabelAssertion =
|
||||||
"?awardReceipt <"+ label + "> ?awardReceiptLabel .";
|
"?awardReceipt <"+ label + "> ?awardReceiptLabel .";
|
||||||
|
|
||||||
final static String n3ForNewAwardAssertion =
|
final static String n3ForNewAwardAssertion =
|
||||||
"?awardReceipt <" + receiptOfPred + "> ?award . \n" +
|
"?awardReceipt <" + receiptOfPred + "> ?award . \n" +
|
||||||
"?award a <" + awardClass + "> . \n" +
|
"?award a <" + awardClass + "> . \n" +
|
||||||
"?award <" + receiptPred + "> ?awardReceipt . \n" +
|
"?award <" + receiptPred + "> ?awardReceipt . \n" +
|
||||||
"?award <"+ label + "> ?awardLabel .";
|
"?award <"+ label + "> ?awardLabel .";
|
||||||
|
|
||||||
final static String n3ForExistingAwardAssertion =
|
final static String n3ForExistingAwardAssertion =
|
||||||
"?awardReceipt <" + receiptOfPred + "> ?existingAward . \n" +
|
"?awardReceipt <" + receiptOfPred + "> ?existingAward . \n" +
|
||||||
"?existingAward <" + receiptPred + "> ?awardReceipt . " ;
|
"?existingAward <" + receiptPred + "> ?awardReceipt . " ;
|
||||||
|
|
||||||
final static String descriptionAssertion =
|
final static String descriptionAssertion =
|
||||||
"?awardReceipt <"+ descriptionPred +"> ?description .";
|
"?awardReceipt <"+ descriptionPred +"> ?description .";
|
||||||
|
|
||||||
final static String n3ForExistingOrgNewAwardAssertion =
|
final static String n3ForExistingOrgNewAwardAssertion =
|
||||||
"?awardReceipt <" + awardConferredByPred +"> ?existingOrg . \n" +
|
"?awardReceipt <" + awardConferredByPred +"> ?existingOrg . \n" +
|
||||||
"?existingOrg <" + awardConferredPred + "> ?awardReceipt . \n" +
|
"?existingOrg <" + awardConferredPred + "> ?awardReceipt . \n" +
|
||||||
"?award <"+ label + "> ?awardLabel .";
|
"?award <"+ label + "> ?awardLabel .";
|
||||||
|
|
||||||
final static String n3ForExistingOrgExistingAwardAssertion =
|
final static String n3ForExistingOrgExistingAwardAssertion =
|
||||||
"?awardReceipt <" + awardConferredByPred +"> ?existingOrg . \n" +
|
"?awardReceipt <" + awardConferredByPred +"> ?existingOrg . \n" +
|
||||||
"?existingOrg <" + awardConferredPred + "> ?awardReceipt . ";
|
"?existingOrg <" + awardConferredPred + "> ?awardReceipt . ";
|
||||||
|
|
||||||
final static String n3ForNewOrgNewAwardAssertion =
|
final static String n3ForNewOrgNewAwardAssertion =
|
||||||
"?newOrg a <" + orgClass + "> . \n" +
|
"?newOrg a <" + orgClass + "> . \n" +
|
||||||
"?awardReceipt <" + awardConferredByPred +"> ?newOrg . \n" +
|
"?awardReceipt <" + awardConferredByPred +"> ?newOrg . \n" +
|
||||||
"?newOrg <" + awardConferredPred + "> ?awardReceipt . \n" +
|
"?newOrg <" + awardConferredPred + "> ?awardReceipt . \n" +
|
||||||
"?award <"+ label + "> ?awardLabel . \n" +
|
"?award <"+ label + "> ?awardLabel . \n" +
|
||||||
"?newOrg <"+ label + "> ?orgLabel .";
|
"?newOrg <"+ label + "> ?orgLabel .";
|
||||||
|
|
||||||
final static String n3ForNewOrgExistingAwardAssertion =
|
final static String n3ForNewOrgExistingAwardAssertion =
|
||||||
"?newOrg a <" + orgClass + "> . \n" +
|
"?newOrg a <" + orgClass + "> . \n" +
|
||||||
"?awardReceipt <" + awardConferredByPred +"> ?newOrg . \n" +
|
"?awardReceipt <" + awardConferredByPred +"> ?newOrg . \n" +
|
||||||
"?newOrg <" + awardConferredPred + "> ?awardReceipt . \n" +
|
"?newOrg <" + awardConferredPred + "> ?awardReceipt . \n" +
|
||||||
"?newOrg <"+ label + "> ?orgLabel .";
|
"?newOrg <"+ label + "> ?orgLabel .";
|
||||||
|
|
||||||
final static String n3ForYearAwarded =
|
final static String n3ForYearAwarded =
|
||||||
"?awardReceipt <" + yearAwardedPred + "> ?yearAwardedNode . \n" +
|
"?awardReceipt <" + yearAwardedPred + "> ?yearAwardedNode . \n" +
|
||||||
"?yearAwardedNode a <" + dateTimeValueType + "> . \n" +
|
"?yearAwardedNode a <" + dateTimeValueType + "> . \n" +
|
||||||
"?yearAwardedNode <" + dateTimeValue + "> ?yearAwarded-value . \n" +
|
"?yearAwardedNode <" + dateTimeValue + "> ?yearAwarded-value . \n" +
|
||||||
"?yearAwardedNode <" + dateTimePrecision + "> ?yearAwarded-precision .";
|
"?yearAwardedNode <" + dateTimePrecision + "> ?yearAwarded-precision .";
|
||||||
|
|
||||||
final static String n3ForStart =
|
final static String n3ForStart =
|
||||||
"?awardReceipt <" + awardReceiptToInterval + "> ?intervalNode . \n" +
|
"?awardReceipt <" + awardReceiptToInterval + "> ?intervalNode . \n" +
|
||||||
"?intervalNode a <" + intervalType + "> . \n" +
|
"?intervalNode a <" + intervalType + "> . \n" +
|
||||||
"?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
"?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
"?startNode a <" + dateTimeValueType + "> . \n" +
|
"?startNode a <" + dateTimeValueType + "> . \n" +
|
||||||
"?startNode <" + dateTimeValue + "> ?startField-value . \n" +
|
"?startNode <" + dateTimeValue + "> ?startField-value . \n" +
|
||||||
"?startNode <" + dateTimePrecision + "> ?startField-precision . \n";
|
"?startNode <" + dateTimePrecision + "> ?startField-precision . \n";
|
||||||
|
|
||||||
final static String n3ForEnd =
|
final static String n3ForEnd =
|
||||||
"?awardReceipt <" + awardReceiptToInterval + "> ?intervalNode . \n" +
|
"?awardReceipt <" + awardReceiptToInterval + "> ?intervalNode . \n" +
|
||||||
"?intervalNode a <" + intervalType + "> . \n" +
|
"?intervalNode a <" + intervalType + "> . \n" +
|
||||||
"?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
"?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
||||||
"?endNode a <" + dateTimeValueType + "> . \n" +
|
"?endNode a <" + dateTimeValueType + "> . \n" +
|
||||||
|
@ -259,7 +259,7 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
||||||
" ?existingAward a <" + awardClass + "> . \n" +
|
" ?existingAward a <" + awardClass + "> . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String existingOrgQuery =
|
final static String existingOrgQuery =
|
||||||
"SELECT ?existingOrg WHERE { \n" +
|
"SELECT ?existingOrg WHERE { \n" +
|
||||||
" ?awardReceipt <" + awardConferredByPred + "> ?existingOrg . \n" +
|
" ?awardReceipt <" + awardConferredByPred + "> ?existingOrg . \n" +
|
||||||
" ?existingOrg a <" + orgClass + "> . \n" +
|
" ?existingOrg a <" + orgClass + "> . \n" +
|
||||||
|
@ -277,24 +277,24 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
||||||
" ?existingAward <" + label + "> ?existingAwardLabel . \n" +
|
" ?existingAward <" + label + "> ?existingAwardLabel . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String orgLabelQuery =
|
final static String orgLabelQuery =
|
||||||
"SELECT ?existingOrgLabel WHERE { \n" +
|
"SELECT ?existingOrgLabel WHERE { \n" +
|
||||||
" ?awardReceipt <" + awardConferredByPred + "> ?existingOrg . \n" +
|
" ?awardReceipt <" + awardConferredByPred + "> ?existingOrg . \n" +
|
||||||
" ?existingOrg a <" + orgClass + "> . \n" +
|
" ?existingOrg a <" + orgClass + "> . \n" +
|
||||||
" ?existingOrg <" + label + "> ?existingOrgLabel . \n" +
|
" ?existingOrg <" + label + "> ?existingOrgLabel . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String descriptionQuery =
|
final static String descriptionQuery =
|
||||||
"SELECT ?existingDescription WHERE {\n"+
|
"SELECT ?existingDescription WHERE {\n"+
|
||||||
" ?awardReceipt <"+ descriptionPred +"> ?existingDescription . }";
|
" ?awardReceipt <"+ descriptionPred +"> ?existingDescription . }";
|
||||||
|
|
||||||
final static String existingYearAwardedQuery =
|
final static String existingYearAwardedQuery =
|
||||||
"SELECT ?existingYearAwardedValue WHERE { \n" +
|
"SELECT ?existingYearAwardedValue WHERE { \n" +
|
||||||
" ?awardReceipt <" + yearAwardedPred + "> ?yearAwardedNode . \n" +
|
" ?awardReceipt <" + yearAwardedPred + "> ?yearAwardedNode . \n" +
|
||||||
" ?yearAwardedNode a <" + dateTimeValueType + "> . \n" +
|
" ?yearAwardedNode a <" + dateTimeValueType + "> . \n" +
|
||||||
" ?yearAwardedNode <" + dateTimeValue + "> ?existingYearAwardedValue }";
|
" ?yearAwardedNode <" + dateTimeValue + "> ?existingYearAwardedValue }";
|
||||||
|
|
||||||
final static String existingYearAwardedNodeQuery =
|
final static String existingYearAwardedNodeQuery =
|
||||||
"SELECT ?existingYearAwardedNode WHERE { \n" +
|
"SELECT ?existingYearAwardedNode WHERE { \n" +
|
||||||
" ?awardReceipt <" + yearAwardedPred + "> ?existingYearAwardedNode . }";
|
" ?awardReceipt <" + yearAwardedPred + "> ?existingYearAwardedNode . }";
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
||||||
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
" ?startNode a <" + dateTimeValueType +"> . \n" +
|
" ?startNode a <" + dateTimeValueType +"> . \n" +
|
||||||
" ?startNode <" + dateTimeValue + "> ?existingStartDate . }";
|
" ?startNode <" + dateTimeValue + "> ?existingStartDate . }";
|
||||||
|
|
||||||
final static String existingEndDateQuery =
|
final static String existingEndDateQuery =
|
||||||
"SELECT ?existingEndDate WHERE { \n" +
|
"SELECT ?existingEndDate WHERE { \n" +
|
||||||
" ?awardReceipt <" + awardReceiptToInterval + "> ?intervalNode . \n" +
|
" ?awardReceipt <" + awardReceiptToInterval + "> ?intervalNode . \n" +
|
||||||
|
@ -315,44 +315,44 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
||||||
" ?endNode <" + dateTimeValue + "> ?existingEndDate . }";
|
" ?endNode <" + dateTimeValue + "> ?existingEndDate . }";
|
||||||
|
|
||||||
final static String existingIntervalNodeQuery =
|
final static String existingIntervalNodeQuery =
|
||||||
"SELECT ?existingIntervalNode WHERE { \n" +
|
"SELECT ?existingIntervalNode WHERE { \n" +
|
||||||
" ?awardReceipt <" + awardReceiptToInterval + "> ?existingIntervalNode . \n" +
|
" ?awardReceipt <" + awardReceiptToInterval + "> ?existingIntervalNode . \n" +
|
||||||
" ?existingIntervalNode a <" + intervalType + "> . }";
|
" ?existingIntervalNode a <" + intervalType + "> . }";
|
||||||
|
|
||||||
final static String existingStartNodeQuery =
|
final static String existingStartNodeQuery =
|
||||||
"SELECT ?existingStartNode WHERE { \n" +
|
"SELECT ?existingStartNode WHERE { \n" +
|
||||||
" ?awardReceipt <" + awardReceiptToInterval + "> ?intervalNode . \n" +
|
" ?awardReceipt <" + awardReceiptToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToStart + "> ?existingStartNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?existingStartNode . \n" +
|
||||||
" ?existingStartNode a <" + dateTimeValueType + "> . } ";
|
" ?existingStartNode a <" + dateTimeValueType + "> . } ";
|
||||||
|
|
||||||
final static String existingEndNodeQuery =
|
final static String existingEndNodeQuery =
|
||||||
"SELECT ?existingEndNode WHERE { \n" +
|
"SELECT ?existingEndNode WHERE { \n" +
|
||||||
" ?awardReceipt <" + awardReceiptToInterval + "> ?intervalNode . \n" +
|
" ?awardReceipt <" + awardReceiptToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToEnd + "> ?existingEndNode . \n" +
|
" ?intervalNode <" + intervalToEnd + "> ?existingEndNode . \n" +
|
||||||
" ?existingEndNode a <" + dateTimeValueType + "> } ";
|
" ?existingEndNode a <" + dateTimeValueType + "> } ";
|
||||||
|
|
||||||
final static String existingYearAwardedPrecisionQuery =
|
final static String existingYearAwardedPrecisionQuery =
|
||||||
"SELECT ?existingYearAwardedPrecision WHERE { \n" +
|
"SELECT ?existingYearAwardedPrecision WHERE { \n" +
|
||||||
" ?awardReceipt <" + yearAwardedPred + "> ?yearAwarded . \n" +
|
" ?awardReceipt <" + yearAwardedPred + "> ?yearAwarded . \n" +
|
||||||
" ?yearAwarded a <" + dateTimeValueType + "> . \n" +
|
" ?yearAwarded a <" + dateTimeValueType + "> . \n" +
|
||||||
" ?yearAwarded <" + dateTimePrecision + "> ?existingYearAwardedPrecision . }";
|
" ?yearAwarded <" + dateTimePrecision + "> ?existingYearAwardedPrecision . }";
|
||||||
|
|
||||||
final static String existingStartPrecisionQuery =
|
final static String existingStartPrecisionQuery =
|
||||||
"SELECT ?existingStartPrecision WHERE { \n" +
|
"SELECT ?existingStartPrecision WHERE { \n" +
|
||||||
" ?awardReceipt <" + awardReceiptToInterval + "> ?intervalNode . \n" +
|
" ?awardReceipt <" + awardReceiptToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
" ?startNode a <" + dateTimeValueType + "> . \n" +
|
" ?startNode a <" + dateTimeValueType + "> . \n" +
|
||||||
" ?startNode <" + dateTimePrecision + "> ?existingStartPrecision . }";
|
" ?startNode <" + dateTimePrecision + "> ?existingStartPrecision . }";
|
||||||
|
|
||||||
final static String existingEndPrecisionQuery =
|
final static String existingEndPrecisionQuery =
|
||||||
"SELECT ?existingEndPrecision WHERE { \n" +
|
"SELECT ?existingEndPrecision WHERE { \n" +
|
||||||
" ?awardReceipt <" + awardReceiptToInterval + "> ?intervalNode . \n" +
|
" ?awardReceipt <" + awardReceiptToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
" ?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
||||||
" ?endNode a <" + dateTimeValueType + "> . \n" +
|
" ?endNode a <" + dateTimeValueType + "> . \n" +
|
||||||
" ?endNode <" + dateTimePrecision + "> ?existingEndPrecision . }";
|
" ?endNode <" + dateTimePrecision + "> ?existingEndPrecision . }";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,60 +26,60 @@ import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
|
||||||
/**
|
/**
|
||||||
Form for adding an educational attainment to an individual
|
Form for adding an educational attainment to an individual
|
||||||
|
|
||||||
Classes:
|
Classes:
|
||||||
core:EducationalProcess - primary new individual being created
|
core:EducationalProcess - primary new individual being created
|
||||||
foaf:Person - existing individual
|
foaf:Person - existing individual
|
||||||
foaf:Organization - new or existing individual
|
foaf:Organization - new or existing individual
|
||||||
core:AcademicDegree - existing individual
|
core:AcademicDegree - existing individual
|
||||||
core:AwardedDegree - new or existing individual
|
core:AwardedDegree - new or existing individual
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
There are 4 modes that this form can be in:
|
|
||||||
1. Add, there is a subject and a predicate but no position and nothing else.
|
There are 4 modes that this form can be in:
|
||||||
|
1. Add, there is a subject and a predicate but no position and nothing else.
|
||||||
|
|
||||||
2. normal edit where everything should already be filled out. There is a subject, a object and an individual on
|
2. normal edit where everything should already be filled out. There is a subject, a object and an individual on
|
||||||
the other end of the object's relationship.
|
the other end of the object's relationship.
|
||||||
|
|
||||||
3. Repair a bad role node. There is a subject, prediate and object but there is no individual on the
|
3. Repair a bad role node. There is a subject, prediate and object but there is no individual on the
|
||||||
other end of the object's relationship. This should be similar to an add but the form should be expanded.
|
other end of the object's relationship. This should be similar to an add but the form should be expanded.
|
||||||
|
|
||||||
4. Really bad node. multiple statements on the other end of the object's relationship.
|
4. Really bad node. multiple statements on the other end of the object's relationship.
|
||||||
|
|
||||||
* @author bdc34
|
* @author bdc34
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PersonHasEducationalTraining extends VivoBaseGenerator implements EditConfigurationGenerator{
|
public class PersonHasEducationalTraining extends VivoBaseGenerator implements EditConfigurationGenerator{
|
||||||
|
|
||||||
//TODO: can we get rid of the session and get it form the vreq?
|
//TODO: can we get rid of the session and get it form the vreq?
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) throws Exception {
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
|
|
||||||
conf.setTemplate("personHasEducationalTraining.ftl");
|
conf.setTemplate("personHasEducationalTraining.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("person");
|
conf.setVarNameForSubject("person");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("edTraining");
|
conf.setVarNameForObject("edTraining");
|
||||||
|
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewEdTraining, trainingTypeAssertion ) );
|
conf.setN3Required( Arrays.asList( n3ForNewEdTraining, trainingTypeAssertion ) );
|
||||||
conf.setN3Optional(Arrays.asList( majorFieldAssertion, n3ForAwardedDegree, n3ForNewOrganization, n3ForExistingOrganization,
|
conf.setN3Optional(Arrays.asList( majorFieldAssertion, n3ForAwardedDegree, n3ForNewOrganization, n3ForExistingOrganization,
|
||||||
n3ForNewOrgAwardedDegree, n3ForExistingOrgAwardedDegree, deptAssertion, infoAssertion, n3ForStart, n3ForEnd ));
|
n3ForNewOrgAwardedDegree, n3ForExistingOrgAwardedDegree, deptAssertion, infoAssertion, n3ForStart, n3ForEnd ));
|
||||||
|
|
||||||
conf.addNewResource("edTraining", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("edTraining", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("awardedDegree",DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("awardedDegree",DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("newOrg",DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("newOrg",DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("intervalNode",DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("intervalNode",DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("startNode",DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("startNode",DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("endNode",DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("endNode",DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
//uris in scope: none
|
//uris in scope: none
|
||||||
//literals in scope: none
|
//literals in scope: none
|
||||||
|
|
||||||
conf.setUrisOnform( Arrays.asList( "existingOrg", "orgType", "degreeType", "trainingType"));
|
conf.setUrisOnform( Arrays.asList( "existingOrg", "orgType", "degreeType", "trainingType"));
|
||||||
conf.setLiteralsOnForm( Arrays.asList("orgLabel", "orgLabelDisplay", "awardedDegreeLabel",
|
conf.setLiteralsOnForm( Arrays.asList("orgLabel", "orgLabelDisplay", "awardedDegreeLabel",
|
||||||
"majorField", "dept", "info"));
|
"majorField", "dept", "info"));
|
||||||
|
@ -92,7 +92,7 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
||||||
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
|
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
|
||||||
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
|
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
|
||||||
|
|
||||||
|
|
||||||
conf.addSparqlForExistingUris("awardedDegree", existingAwardedDegreeQuery);
|
conf.addSparqlForExistingUris("awardedDegree", existingAwardedDegreeQuery);
|
||||||
conf.addSparqlForExistingUris("existingOrg", existingOrgQuery);
|
conf.addSparqlForExistingUris("existingOrg", existingOrgQuery);
|
||||||
conf.addSparqlForExistingUris("orgType", orgTypeQuery);
|
conf.addSparqlForExistingUris("orgType", orgTypeQuery);
|
||||||
|
@ -105,8 +105,8 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
||||||
conf.addSparqlForExistingUris("endField-precision", existingEndPrecisionQuery);
|
conf.addSparqlForExistingUris("endField-precision", existingEndPrecisionQuery);
|
||||||
//Add sparql to include inverse property as well
|
//Add sparql to include inverse property as well
|
||||||
conf.addSparqlForAdditionalUrisInScope("inverseTrainingAtOrg", inverseTrainingAtOrgQuery);
|
conf.addSparqlForAdditionalUrisInScope("inverseTrainingAtOrg", inverseTrainingAtOrgQuery);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("degreeType").
|
setName("degreeType").
|
||||||
setOptions( new IndividualsViaVClassOptions(
|
setOptions( new IndividualsViaVClassOptions(
|
||||||
degreeTypeClass)));
|
degreeTypeClass)));
|
||||||
|
@ -115,16 +115,16 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
||||||
setName("majorField").
|
setName("majorField").
|
||||||
setRangeDatatypeUri( XSD.xstring.toString() ).
|
setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators(list("datatype:" + XSD.xstring.toString())));
|
setValidators(list("datatype:" + XSD.xstring.toString())));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("existingOrg")
|
setName("existingOrg")
|
||||||
//options will be added in browser by auto complete JS
|
//options will be added in browser by auto complete JS
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("awardedDegree")
|
setName("awardedDegree")
|
||||||
//options will be added in browser by auto complete JS
|
//options will be added in browser by auto complete JS
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("orgLabel").
|
setName("orgLabel").
|
||||||
|
@ -140,28 +140,28 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
||||||
setName("existingAwardedDegreeLabel").
|
setName("existingAwardedDegreeLabel").
|
||||||
setRangeDatatypeUri(XSD.xstring.toString() ).
|
setRangeDatatypeUri(XSD.xstring.toString() ).
|
||||||
setValidators( list("datatype:" + XSD.xstring.toString())));
|
setValidators( list("datatype:" + XSD.xstring.toString())));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("orgLabelDisplay").
|
setName("orgLabelDisplay").
|
||||||
setRangeDatatypeUri(XSD.xstring.toString() ));
|
setRangeDatatypeUri(XSD.xstring.toString() ));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("orgType").
|
setName("orgType").
|
||||||
setValidators( list("nonempty")).
|
setValidators( list("nonempty")).
|
||||||
setOptions( new ChildVClassesOptions(
|
setOptions( new ChildVClassesOptions(
|
||||||
orgClass)));
|
orgClass)));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("trainingType").
|
setName("trainingType").
|
||||||
setValidators( list("nonempty") ).
|
setValidators( list("nonempty") ).
|
||||||
setOptions(
|
setOptions(
|
||||||
new ChildVClassesWithParent(edProcessClass)));
|
new ChildVClassesWithParent(edProcessClass)));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("dept").
|
setName("dept").
|
||||||
setRangeDatatypeUri( XSD.xstring.toString() ).
|
setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators(list("datatype:" + XSD.xstring.toString())));
|
setValidators(list("datatype:" + XSD.xstring.toString())));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("info").
|
setName("info").
|
||||||
setRangeDatatypeUri( XSD.xstring.toString() ).
|
setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
|
@ -169,32 +169,32 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
||||||
|
|
||||||
FieldVTwo startField = new FieldVTwo().
|
FieldVTwo startField = new FieldVTwo().
|
||||||
setName("startField");
|
setName("startField");
|
||||||
conf.addField(startField.
|
conf.addField(startField.
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(startField,
|
new DateTimeWithPrecisionVTwo(startField,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())));
|
VitroVocabulary.Precision.NONE.uri())));
|
||||||
|
|
||||||
FieldVTwo endField = new FieldVTwo().
|
FieldVTwo endField = new FieldVTwo().
|
||||||
setName("endField");
|
setName("endField");
|
||||||
conf.addField( endField.
|
conf.addField( endField.
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(endField,
|
new DateTimeWithPrecisionVTwo(endField,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())));
|
VitroVocabulary.Precision.NONE.uri())));
|
||||||
//Add validator
|
//Add validator
|
||||||
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
|
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
|
|
||||||
//Adding additional data, specifically edit mode
|
//Adding additional data, specifically edit mode
|
||||||
addFormSpecificData(conf, vreq);
|
addFormSpecificData(conf, vreq);
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* N3 assertions for working with educational training */
|
/* N3 assertions for working with educational training */
|
||||||
|
|
||||||
final static String n3ForNewEdTraining =
|
final static String n3ForNewEdTraining =
|
||||||
"@prefix core: <"+ vivoCore +"> .\n"+
|
"@prefix core: <"+ vivoCore +"> .\n"+
|
||||||
"?person <http://purl.obolibrary.org/obo/RO_0000056> ?edTraining .\n" +
|
"?person <http://purl.obolibrary.org/obo/RO_0000056> ?edTraining .\n" +
|
||||||
"?edTraining a core:EducationalProcess .\n" +
|
"?edTraining a core:EducationalProcess .\n" +
|
||||||
|
@ -203,7 +203,7 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
||||||
final static String trainingTypeAssertion =
|
final static String trainingTypeAssertion =
|
||||||
"?edTraining a ?trainingType .";
|
"?edTraining a ?trainingType .";
|
||||||
|
|
||||||
final static String n3ForAwardedDegree =
|
final static String n3ForAwardedDegree =
|
||||||
"@prefix core: <"+ vivoCore +"> .\n"+
|
"@prefix core: <"+ vivoCore +"> .\n"+
|
||||||
"?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?awardedDegree . \n" +
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?awardedDegree . \n" +
|
||||||
"?awardedDegree <http://purl.obolibrary.org/obo/RO_0002353> ?edTraining . \n" +
|
"?awardedDegree <http://purl.obolibrary.org/obo/RO_0002353> ?edTraining . \n" +
|
||||||
|
@ -214,31 +214,31 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
||||||
"?degreeType <http://vivoweb.org/ontology/core#relatedBy> ?awardedDegree . \n"+
|
"?degreeType <http://vivoweb.org/ontology/core#relatedBy> ?awardedDegree . \n"+
|
||||||
"?awardedDegree a core:AwardedDegree .";
|
"?awardedDegree a core:AwardedDegree .";
|
||||||
|
|
||||||
final static String n3ForNewOrganization =
|
final static String n3ForNewOrganization =
|
||||||
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?newOrg . \n" +
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?newOrg . \n" +
|
||||||
"?newOrg <http://purl.obolibrary.org/obo/RO_0000056> ?edTraining . \n" +
|
"?newOrg <http://purl.obolibrary.org/obo/RO_0000056> ?edTraining . \n" +
|
||||||
"?newOrg a ?orgType . \n" +
|
"?newOrg a ?orgType . \n" +
|
||||||
"?newOrg <"+ label +"> ?orgLabel . ";
|
"?newOrg <"+ label +"> ?orgLabel . ";
|
||||||
|
|
||||||
final static String n3ForExistingOrganization =
|
final static String n3ForExistingOrganization =
|
||||||
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?existingOrg . \n" +
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?existingOrg . \n" +
|
||||||
"?existingOrg <http://purl.obolibrary.org/obo/RO_0000056> ?edTraining . \n" +
|
"?existingOrg <http://purl.obolibrary.org/obo/RO_0000056> ?edTraining . \n" +
|
||||||
"?existingOrg a ?orgType . ";
|
"?existingOrg a ?orgType . ";
|
||||||
|
|
||||||
final static String n3ForNewOrgAwardedDegree =
|
final static String n3ForNewOrgAwardedDegree =
|
||||||
"?awardedDegree <http://vivoweb.org/ontology/core#assignedBy> ?newOrg . \n" +
|
"?awardedDegree <http://vivoweb.org/ontology/core#assignedBy> ?newOrg . \n" +
|
||||||
"?newOrg <http://vivoweb.org/ontology/core#assigns> ?awardedDegree . \n" +
|
"?newOrg <http://vivoweb.org/ontology/core#assigns> ?awardedDegree . \n" +
|
||||||
"?newOrg a ?orgType . \n" +
|
"?newOrg a ?orgType . \n" +
|
||||||
"?awardedDegree <"+ label +"> ?awardedDegreeLabel . \n" +
|
"?awardedDegree <"+ label +"> ?awardedDegreeLabel . \n" +
|
||||||
"?newOrg <"+ label +"> ?orgLabel . ";
|
"?newOrg <"+ label +"> ?orgLabel . ";
|
||||||
|
|
||||||
final static String n3ForExistingOrgAwardedDegree =
|
final static String n3ForExistingOrgAwardedDegree =
|
||||||
"?awardedDegree <http://vivoweb.org/ontology/core#assignedBy> ?existingOrg . \n" +
|
"?awardedDegree <http://vivoweb.org/ontology/core#assignedBy> ?existingOrg . \n" +
|
||||||
"?existingOrg <http://vivoweb.org/ontology/core#assigns> ?awardedDegree . \n" +
|
"?existingOrg <http://vivoweb.org/ontology/core#assigns> ?awardedDegree . \n" +
|
||||||
"?awardedDegree <"+ label +"> ?awardedDegreeLabel . \n" +
|
"?awardedDegree <"+ label +"> ?awardedDegreeLabel . \n" +
|
||||||
"?existingOrg a ?orgType . ";
|
"?existingOrg a ?orgType . ";
|
||||||
|
|
||||||
final static String majorFieldAssertion =
|
final static String majorFieldAssertion =
|
||||||
"?edTraining <"+ majorFieldPred +"> ?majorField .";
|
"?edTraining <"+ majorFieldPred +"> ?majorField .";
|
||||||
|
|
||||||
final static String n3ForStart =
|
final static String n3ForStart =
|
||||||
|
@ -257,24 +257,24 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
||||||
"?endNode <"+ dateTimeValue +"> ?endField-value .\n"+
|
"?endNode <"+ dateTimeValue +"> ?endField-value .\n"+
|
||||||
"?endNode <"+ dateTimePrecision +"> ?endField-precision .";
|
"?endNode <"+ dateTimePrecision +"> ?endField-precision .";
|
||||||
|
|
||||||
final static String deptAssertion =
|
final static String deptAssertion =
|
||||||
"?edTraining <"+ deptPred +"> ?dept .";
|
"?edTraining <"+ deptPred +"> ?dept .";
|
||||||
|
|
||||||
final static String infoAssertion =
|
final static String infoAssertion =
|
||||||
"?edTraining <"+ infoPred +"> ?info .";
|
"?edTraining <"+ infoPred +"> ?info .";
|
||||||
|
|
||||||
/* Queries for editing an existing educational training entry */
|
/* Queries for editing an existing educational training entry */
|
||||||
|
|
||||||
final static String existingAwardedDegreeQuery =
|
final static String existingAwardedDegreeQuery =
|
||||||
"SELECT ?existingAwardedDegree WHERE {\n"+
|
"SELECT ?existingAwardedDegree WHERE {\n"+
|
||||||
"?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?existingAwardedDegree . }\n";
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?existingAwardedDegree . }\n";
|
||||||
|
|
||||||
final static String existingAwardedDegreeLabelQuery =
|
final static String existingAwardedDegreeLabelQuery =
|
||||||
"SELECT ?existingAwardedDegreeLabel WHERE {\n"+
|
"SELECT ?existingAwardedDegreeLabel WHERE {\n"+
|
||||||
"?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?existingAwardedDegree . \n" +
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?existingAwardedDegree . \n" +
|
||||||
"?existingAwardedDegree <"+ label +"> ?existingAwardedDegreeLabel }\n";
|
"?existingAwardedDegree <"+ label +"> ?existingAwardedDegreeLabel }\n";
|
||||||
|
|
||||||
final static String existingOrgQuery =
|
final static String existingOrgQuery =
|
||||||
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
||||||
"SELECT ?existingOrg WHERE {\n"+
|
"SELECT ?existingOrg WHERE {\n"+
|
||||||
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?existingOrg . \n" +
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?existingOrg . \n" +
|
||||||
|
@ -282,7 +282,7 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
||||||
"?existingOrg a ?existingOrgType . \n " +
|
"?existingOrg a ?existingOrgType . \n " +
|
||||||
"?existingOrgType rdfs:subClassOf <"+ orgClass +"> . }";
|
"?existingOrgType rdfs:subClassOf <"+ orgClass +"> . }";
|
||||||
|
|
||||||
final static String orgLabelQuery =
|
final static String orgLabelQuery =
|
||||||
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
||||||
"SELECT ?existingOrgLabel WHERE {\n"+
|
"SELECT ?existingOrgLabel WHERE {\n"+
|
||||||
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?existingOrg . \n" +
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?existingOrg . \n" +
|
||||||
|
@ -293,7 +293,7 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
||||||
|
|
||||||
/* Limit type to subclasses of foaf:Organization. Otherwise, sometimes owl:Thing or another
|
/* Limit type to subclasses of foaf:Organization. Otherwise, sometimes owl:Thing or another
|
||||||
type is returned and we don't get a match to the select element options. */
|
type is returned and we don't get a match to the select element options. */
|
||||||
final static String orgTypeQuery =
|
final static String orgTypeQuery =
|
||||||
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
||||||
"SELECT ?existingOrgType WHERE {\n"+
|
"SELECT ?existingOrgType WHERE {\n"+
|
||||||
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?existingOrg . \n" +
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?existingOrg . \n" +
|
||||||
|
@ -302,12 +302,12 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
||||||
"?existingOrgType rdfs:subClassOf <"+ orgClass +"> .\n"+
|
"?existingOrgType rdfs:subClassOf <"+ orgClass +"> .\n"+
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String trainingTypeQuery =
|
final static String trainingTypeQuery =
|
||||||
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
||||||
"SELECT ?existingTrainingType WHERE { \n" +
|
"SELECT ?existingTrainingType WHERE { \n" +
|
||||||
" ?edTraining vitro:mostSpecificType ?existingTrainingType . }";
|
" ?edTraining vitro:mostSpecificType ?existingTrainingType . }";
|
||||||
|
|
||||||
final static String degreeTypeQuery =
|
final static String degreeTypeQuery =
|
||||||
"PREFIX core: <"+ vivoCore +"> \n"+
|
"PREFIX core: <"+ vivoCore +"> \n"+
|
||||||
"SELECT ?existingDegreeType WHERE {\n"+
|
"SELECT ?existingDegreeType WHERE {\n"+
|
||||||
"?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?existingAwardedDegree . \n"+
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?existingAwardedDegree . \n"+
|
||||||
|
@ -315,31 +315,31 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
||||||
"?existingAwardedDegree core:relates ?existingDegreeType . \n" +
|
"?existingAwardedDegree core:relates ?existingDegreeType . \n" +
|
||||||
"?existingDegreeType a core:AcademicDegree }";
|
"?existingDegreeType a core:AcademicDegree }";
|
||||||
|
|
||||||
final static String majorFieldQuery =
|
final static String majorFieldQuery =
|
||||||
"SELECT ?existingMajorField WHERE {\n"+
|
"SELECT ?existingMajorField WHERE {\n"+
|
||||||
"?edTraining <"+ majorFieldPred +"> ?existingMajorField . }";
|
"?edTraining <"+ majorFieldPred +"> ?existingMajorField . }";
|
||||||
|
|
||||||
final static String deptQuery =
|
final static String deptQuery =
|
||||||
"SELECT ?existingDept WHERE {\n"+
|
"SELECT ?existingDept WHERE {\n"+
|
||||||
"?edTraining <"+ deptPred +"> ?existingDept . }";
|
"?edTraining <"+ deptPred +"> ?existingDept . }";
|
||||||
|
|
||||||
final static String infoQuery =
|
final static String infoQuery =
|
||||||
"SELECT ?existingInfo WHERE {\n"+
|
"SELECT ?existingInfo WHERE {\n"+
|
||||||
"?edTraining <"+ infoPred +"> ?existingInfo . }";
|
"?edTraining <"+ infoPred +"> ?existingInfo . }";
|
||||||
|
|
||||||
final static String existingIntervalNodeQuery =
|
final static String existingIntervalNodeQuery =
|
||||||
"SELECT ?existingIntervalNode WHERE {\n"+
|
"SELECT ?existingIntervalNode WHERE {\n"+
|
||||||
"?edTraining <"+ toInterval +"> ?existingIntervalNode .\n"+
|
"?edTraining <"+ toInterval +"> ?existingIntervalNode .\n"+
|
||||||
"?existingIntervalNode <"+ type +"> <"+ intervalType +"> . }";
|
"?existingIntervalNode <"+ type +"> <"+ intervalType +"> . }";
|
||||||
|
|
||||||
final static String existingStartNodeQuery =
|
final static String existingStartNodeQuery =
|
||||||
"SELECT ?existingStartNode WHERE {\n"+
|
"SELECT ?existingStartNode WHERE {\n"+
|
||||||
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
||||||
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
||||||
"?intervalNode <"+ intervalToStart +"> ?existingStartNode . \n"+
|
"?intervalNode <"+ intervalToStart +"> ?existingStartNode . \n"+
|
||||||
"?existingStartNode <"+ type +"> <"+ dateTimeValueType +"> .}";
|
"?existingStartNode <"+ type +"> <"+ dateTimeValueType +"> .}";
|
||||||
|
|
||||||
final static String existingStartDateQuery =
|
final static String existingStartDateQuery =
|
||||||
"SELECT ?existingDateStart WHERE {\n"+
|
"SELECT ?existingDateStart WHERE {\n"+
|
||||||
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
||||||
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
||||||
|
@ -347,7 +347,7 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
||||||
"?startNode <"+ type +"> <"+ dateTimeValueType +"> .\n"+
|
"?startNode <"+ type +"> <"+ dateTimeValueType +"> .\n"+
|
||||||
"?startNode <"+ dateTimeValue +"> ?existingDateStart . }";
|
"?startNode <"+ dateTimeValue +"> ?existingDateStart . }";
|
||||||
|
|
||||||
final static String existingStartPrecisionQuery =
|
final static String existingStartPrecisionQuery =
|
||||||
"SELECT ?existingStartPrecision WHERE {\n"+
|
"SELECT ?existingStartPrecision WHERE {\n"+
|
||||||
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
||||||
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
||||||
|
@ -355,14 +355,14 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
||||||
"?startNode <"+ type +"> <"+ dateTimeValueType +"> . \n"+
|
"?startNode <"+ type +"> <"+ dateTimeValueType +"> . \n"+
|
||||||
"?startNode <"+ dateTimePrecision +"> ?existingStartPrecision . }";
|
"?startNode <"+ dateTimePrecision +"> ?existingStartPrecision . }";
|
||||||
|
|
||||||
final static String existingEndNodeQuery =
|
final static String existingEndNodeQuery =
|
||||||
"SELECT ?existingEndNode WHERE { \n"+
|
"SELECT ?existingEndNode WHERE { \n"+
|
||||||
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
||||||
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
||||||
"?intervalNode <"+ intervalToEnd +"> ?existingEndNode . \n"+
|
"?intervalNode <"+ intervalToEnd +"> ?existingEndNode . \n"+
|
||||||
"?existingEndNode <"+ type +"> <"+ dateTimeValueType +"> .}";
|
"?existingEndNode <"+ type +"> <"+ dateTimeValueType +"> .}";
|
||||||
|
|
||||||
final static String existingEndDateQuery =
|
final static String existingEndDateQuery =
|
||||||
"SELECT ?existingEndDate WHERE {\n"+
|
"SELECT ?existingEndDate WHERE {\n"+
|
||||||
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
||||||
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
||||||
|
@ -370,28 +370,28 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
||||||
"?endNode <"+ type +"> <"+ dateTimeValueType +"> .\n"+
|
"?endNode <"+ type +"> <"+ dateTimeValueType +"> .\n"+
|
||||||
"?endNode <"+ dateTimeValue +"> ?existingEndDate . }";
|
"?endNode <"+ dateTimeValue +"> ?existingEndDate . }";
|
||||||
|
|
||||||
final static String existingEndPrecisionQuery =
|
final static String existingEndPrecisionQuery =
|
||||||
"SELECT ?existingEndPrecision WHERE {\n"+
|
"SELECT ?existingEndPrecision WHERE {\n"+
|
||||||
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
"?edTraining <"+ toInterval +"> ?intervalNode .\n"+
|
||||||
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
"?intervalNode <"+ type +"> <"+ intervalType +"> .\n"+
|
||||||
"?intervalNode <"+ intervalToEnd +"> ?endNode .\n"+
|
"?intervalNode <"+ intervalToEnd +"> ?endNode .\n"+
|
||||||
"?endNode <"+ type +"> <"+ dateTimeValueType +"> .\n"+
|
"?endNode <"+ type +"> <"+ dateTimeValueType +"> .\n"+
|
||||||
"?endNode <"+ dateTimePrecision +"> ?existingEndPrecision . }";
|
"?endNode <"+ dateTimePrecision +"> ?existingEndPrecision . }";
|
||||||
|
|
||||||
//Query for inverse property
|
//Query for inverse property
|
||||||
final static String inverseTrainingAtOrgQuery =
|
final static String inverseTrainingAtOrgQuery =
|
||||||
"PREFIX owl: <http://www.w3.org/2002/07/owl#>"
|
"PREFIX owl: <http://www.w3.org/2002/07/owl#>"
|
||||||
+ " SELECT ?inverseTrainingAtOrg "
|
+ " SELECT ?inverseTrainingAtOrg "
|
||||||
+ " WHERE { ?inverseTrainingAtOrg owl:inverseOf <http://vivoweb.org/ontology/core#relates> . } ";
|
+ " WHERE { ?inverseTrainingAtOrg owl:inverseOf <http://vivoweb.org/ontology/core#relates> . } ";
|
||||||
|
|
||||||
|
|
||||||
//Adding form specific data such as edit mode
|
//Adding form specific data such as edit mode
|
||||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||||
formSpecificData.put("editMode", getEditMode(vreq).name().toLowerCase());
|
formSpecificData.put("editMode", getEditMode(vreq).name().toLowerCase());
|
||||||
editConfiguration.setFormSpecificData(formSpecificData);
|
editConfiguration.setFormSpecificData(formSpecificData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EditMode getEditMode(VitroRequest vreq) {
|
public EditMode getEditMode(VitroRequest vreq) {
|
||||||
List<String> predicates = new ArrayList<String>();
|
List<String> predicates = new ArrayList<String>();
|
||||||
predicates.add("http://vivoweb.org/ontology/core#relates");
|
predicates.add("http://vivoweb.org/ontology/core#relates");
|
||||||
|
|
|
@ -21,25 +21,25 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
|
||||||
public class PersonHasEmailGenerator extends VivoBaseGenerator implements
|
public class PersonHasEmailGenerator extends VivoBaseGenerator implements
|
||||||
EditConfigurationGenerator {
|
EditConfigurationGenerator {
|
||||||
private Log log = LogFactory.getLog(PersonHasEmailGenerator.class);
|
private Log log = LogFactory.getLog(PersonHasEmailGenerator.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
HttpSession session) throws Exception {
|
HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
String emailUri = getEmailUri(vreq);
|
String emailUri = getEmailUri(vreq);
|
||||||
String rangeUri = getRangeUri(vreq);
|
String rangeUri = getRangeUri(vreq);
|
||||||
|
|
||||||
conf.setTemplate("personHasEmailAddress.ftl");
|
conf.setTemplate("personHasEmailAddress.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("person");
|
conf.setVarNameForSubject("person");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("individualVcard");
|
conf.setVarNameForObject("individualVcard");
|
||||||
|
|
||||||
if ( rangeUri.equals("http://www.w3.org/2006/vcard/ns#Work") ) {
|
if ( rangeUri.equals("http://www.w3.org/2006/vcard/ns#Work") ) {
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewPrimaryEmail ) );
|
conf.setN3Required( Arrays.asList( n3ForNewPrimaryEmail ) );
|
||||||
}
|
}
|
||||||
|
@ -48,12 +48,12 @@ public class PersonHasEmailGenerator extends VivoBaseGenerator implements
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.setN3Optional( Arrays.asList( emailAddressAssertion ) );
|
conf.setN3Optional( Arrays.asList( emailAddressAssertion ) );
|
||||||
|
|
||||||
conf.addNewResource("email", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("email", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("individualVcard", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("individualVcard", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
conf.setLiteralsOnForm(Arrays.asList("emailAddress" ));
|
conf.setLiteralsOnForm(Arrays.asList("emailAddress" ));
|
||||||
|
|
||||||
conf.addSparqlForExistingLiteral("emailAddress", emailAddressQuery);
|
conf.addSparqlForExistingLiteral("emailAddress", emailAddressQuery);
|
||||||
conf.addSparqlForAdditionalUrisInScope("individualVcard", individualVcardQuery);
|
conf.addSparqlForAdditionalUrisInScope("individualVcard", individualVcardQuery);
|
||||||
|
|
||||||
|
@ -63,37 +63,37 @@ public class PersonHasEmailGenerator extends VivoBaseGenerator implements
|
||||||
conf.addUrisInScope(urisInScope);
|
conf.addUrisInScope(urisInScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("emailAddress")
|
setName("emailAddress")
|
||||||
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators( list("nonempty") ));
|
setValidators( list("nonempty") ));
|
||||||
|
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
|
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* N3 assertions */
|
/* N3 assertions */
|
||||||
|
|
||||||
final static String n3ForNewEmail =
|
final static String n3ForNewEmail =
|
||||||
"?person <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
"?person <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
||||||
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?person . \n" +
|
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?person . \n" +
|
||||||
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasEmail> ?email . \n" +
|
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasEmail> ?email . \n" +
|
||||||
"?email a <http://www.w3.org/2006/vcard/ns#Email> . " ;
|
"?email a <http://www.w3.org/2006/vcard/ns#Email> . " ;
|
||||||
|
|
||||||
final static String n3ForNewPrimaryEmail =
|
final static String n3ForNewPrimaryEmail =
|
||||||
"?person <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
"?person <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
||||||
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?person . \n" +
|
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?person . \n" +
|
||||||
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasEmail> ?email . \n" +
|
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasEmail> ?email . \n" +
|
||||||
"?email a <http://www.w3.org/2006/vcard/ns#Email> . \n" +
|
"?email a <http://www.w3.org/2006/vcard/ns#Email> . \n" +
|
||||||
"?email a <http://www.w3.org/2006/vcard/ns#Work> ." ;
|
"?email a <http://www.w3.org/2006/vcard/ns#Work> ." ;
|
||||||
|
|
||||||
final static String emailAddressAssertion =
|
final static String emailAddressAssertion =
|
||||||
"?email <http://www.w3.org/2006/vcard/ns#email> ?emailAddress .";
|
"?email <http://www.w3.org/2006/vcard/ns#email> ?emailAddress .";
|
||||||
|
|
||||||
/* Queries for editing an existing entry */
|
/* Queries for editing an existing entry */
|
||||||
|
|
||||||
final static String individualVcardQuery =
|
final static String individualVcardQuery =
|
||||||
|
@ -101,18 +101,18 @@ public class PersonHasEmailGenerator extends VivoBaseGenerator implements
|
||||||
"?person <http://purl.obolibrary.org/obo/ARG_2000028> ?existingIndividualVcard . \n" +
|
"?person <http://purl.obolibrary.org/obo/ARG_2000028> ?existingIndividualVcard . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String emailAddressQuery =
|
final static String emailAddressQuery =
|
||||||
"SELECT ?existingEmailAddress WHERE {\n"+
|
"SELECT ?existingEmailAddress WHERE {\n"+
|
||||||
"?email <http://www.w3.org/2006/vcard/ns#email> ?existingEmailAddress . }";
|
"?email <http://www.w3.org/2006/vcard/ns#email> ?existingEmailAddress . }";
|
||||||
|
|
||||||
private String getRangeUri(VitroRequest vreq) {
|
private String getRangeUri(VitroRequest vreq) {
|
||||||
String rangeUri = vreq.getParameter("rangeUri");
|
String rangeUri = vreq.getParameter("rangeUri");
|
||||||
|
|
||||||
return rangeUri;
|
return rangeUri;
|
||||||
}
|
}
|
||||||
private String getEmailUri(VitroRequest vreq) {
|
private String getEmailUri(VitroRequest vreq) {
|
||||||
String emailUri = vreq.getParameter("emailUri");
|
String emailUri = vreq.getParameter("emailUri");
|
||||||
|
|
||||||
return emailUri;
|
return emailUri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,50 +33,50 @@ public class PersonHasIssuedCredentialGenerator extends VivoBaseGenerator implem
|
||||||
final static String dateTimeValueType = vivoCore + "DateTimeValue";
|
final static String dateTimeValueType = vivoCore + "DateTimeValue";
|
||||||
final static String dateTimeValue = vivoCore + "dateTime";
|
final static String dateTimeValue = vivoCore + "dateTime";
|
||||||
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
|
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
|
||||||
|
|
||||||
public PersonHasIssuedCredentialGenerator() {}
|
public PersonHasIssuedCredentialGenerator() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
HttpSession session) throws Exception {
|
HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
|
|
||||||
conf.setTemplate("personHasIssuedCredential.ftl");
|
conf.setTemplate("personHasIssuedCredential.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("person");
|
conf.setVarNameForSubject("person");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("issuedCredential");
|
conf.setVarNameForObject("issuedCredential");
|
||||||
|
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewIssuedCredential, n3ForICTypeAssertion) );
|
conf.setN3Required( Arrays.asList( n3ForNewIssuedCredential, n3ForICTypeAssertion) );
|
||||||
conf.setN3Optional( Arrays.asList( n3ForNewCredentialAssertion,
|
conf.setN3Optional( Arrays.asList( n3ForNewCredentialAssertion,
|
||||||
n3ForExistingCredentialAssertion,
|
n3ForExistingCredentialAssertion,
|
||||||
n3ForYearCredentialed,
|
n3ForYearCredentialed,
|
||||||
n3ForStart,
|
n3ForStart,
|
||||||
n3ForEnd ) );
|
n3ForEnd ) );
|
||||||
|
|
||||||
conf.addNewResource("credential", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("credential", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("issuedCredential", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("issuedCredential", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("yearCredentialedNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("yearCredentialedNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
//uris in scope: none
|
//uris in scope: none
|
||||||
//literals in scope: none
|
//literals in scope: none
|
||||||
|
|
||||||
conf.setUrisOnform(Arrays.asList("existingCredential", "issuedCredentialType", "credentialType"));
|
conf.setUrisOnform(Arrays.asList("existingCredential", "issuedCredentialType", "credentialType"));
|
||||||
conf.setLiteralsOnForm(Arrays.asList("yearCredentialedDisplay","credentialLabel", "credentialLabelDisplay" ));
|
conf.setLiteralsOnForm(Arrays.asList("yearCredentialedDisplay","credentialLabel", "credentialLabelDisplay" ));
|
||||||
|
|
||||||
conf.addSparqlForExistingLiteral("credentialLabel", credentialLabelQuery);
|
conf.addSparqlForExistingLiteral("credentialLabel", credentialLabelQuery);
|
||||||
conf.addSparqlForExistingLiteral("yearCredentialed-value", existingYearCredentialedQuery);
|
conf.addSparqlForExistingLiteral("yearCredentialed-value", existingYearCredentialedQuery);
|
||||||
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
|
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
|
||||||
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
|
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
|
||||||
|
|
||||||
conf.addSparqlForExistingUris("existingCredential", existingCredentialQuery);
|
conf.addSparqlForExistingUris("existingCredential", existingCredentialQuery);
|
||||||
conf.addSparqlForExistingUris("credentialType", existingCredentialTypeQuery);
|
conf.addSparqlForExistingUris("credentialType", existingCredentialTypeQuery);
|
||||||
conf.addSparqlForExistingUris("issuedCredentialType", issuedCredentialTypeQuery);
|
conf.addSparqlForExistingUris("issuedCredentialType", issuedCredentialTypeQuery);
|
||||||
|
@ -87,20 +87,20 @@ public class PersonHasIssuedCredentialGenerator extends VivoBaseGenerator implem
|
||||||
conf.addSparqlForExistingUris("yearCredentialed-precision", existingYearCredentialedPrecisionQuery);
|
conf.addSparqlForExistingUris("yearCredentialed-precision", existingYearCredentialedPrecisionQuery);
|
||||||
conf.addSparqlForExistingUris("startField-precision", existingStartPrecisionQuery);
|
conf.addSparqlForExistingUris("startField-precision", existingStartPrecisionQuery);
|
||||||
conf.addSparqlForExistingUris("endField-precision", existingEndPrecisionQuery);
|
conf.addSparqlForExistingUris("endField-precision", existingEndPrecisionQuery);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("issuedCredentialType").
|
setName("issuedCredentialType").
|
||||||
setRangeDatatypeUri(XSD.xstring.toString() ).
|
setRangeDatatypeUri(XSD.xstring.toString() ).
|
||||||
setValidators( list("datatype:" + XSD.xstring.toString()))
|
setValidators( list("datatype:" + XSD.xstring.toString()))
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("credentialType").
|
setName("credentialType").
|
||||||
setOptions(getCredentialTypeFieldOptions(vreq)));
|
setOptions(getCredentialTypeFieldOptions(vreq)));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo(). // options will be added in browser by auto complete JS
|
conf.addField( new FieldVTwo(). // options will be added in browser by auto complete JS
|
||||||
setName("existingCredential")
|
setName("existingCredential")
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("credentialLabel").
|
setName("credentialLabel").
|
||||||
|
@ -121,24 +121,24 @@ public class PersonHasIssuedCredentialGenerator extends VivoBaseGenerator implem
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().setName("yearCredentialed").
|
conf.addField( new FieldVTwo().setName("yearCredentialed").
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(null,
|
new DateTimeWithPrecisionVTwo(null,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())
|
VitroVocabulary.Precision.NONE.uri())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().setName("startField").
|
conf.addField( new FieldVTwo().setName("startField").
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(null,
|
new DateTimeWithPrecisionVTwo(null,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())
|
VitroVocabulary.Precision.NONE.uri())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().setName("endField").
|
conf.addField( new FieldVTwo().setName("endField").
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(null,
|
new DateTimeWithPrecisionVTwo(null,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())
|
VitroVocabulary.Precision.NONE.uri())
|
||||||
)
|
)
|
||||||
|
@ -147,7 +147,7 @@ public class PersonHasIssuedCredentialGenerator extends VivoBaseGenerator implem
|
||||||
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
|
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
conf.addValidator(new AutocompleteRequiredInputValidator("existingCredential", "credentialLabel"));
|
conf.addValidator(new AutocompleteRequiredInputValidator("existingCredential", "credentialLabel"));
|
||||||
|
|
||||||
addFormSpecificData(conf, vreq);
|
addFormSpecificData(conf, vreq);
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
|
@ -155,46 +155,46 @@ public class PersonHasIssuedCredentialGenerator extends VivoBaseGenerator implem
|
||||||
|
|
||||||
/* N3 assertions */
|
/* N3 assertions */
|
||||||
|
|
||||||
final static String n3ForNewIssuedCredential =
|
final static String n3ForNewIssuedCredential =
|
||||||
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
||||||
"?person vivo:relatedBy ?issuedCredential . \n" +
|
"?person vivo:relatedBy ?issuedCredential . \n" +
|
||||||
"?issuedCredential a <" + issuedCredentialTypeClass + "> . \n" +
|
"?issuedCredential a <" + issuedCredentialTypeClass + "> . \n" +
|
||||||
"?issuedCredential vivo:relates ?person . " ;
|
"?issuedCredential vivo:relates ?person . " ;
|
||||||
|
|
||||||
final static String n3ForICTypeAssertion =
|
final static String n3ForICTypeAssertion =
|
||||||
"?issuedCredential a ?issuedCredentialType .";
|
"?issuedCredential a ?issuedCredentialType .";
|
||||||
|
|
||||||
final static String n3ForNewCredentialAssertion =
|
final static String n3ForNewCredentialAssertion =
|
||||||
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
||||||
"?issuedCredential vivo:relates ?credential . \n" +
|
"?issuedCredential vivo:relates ?credential . \n" +
|
||||||
"?credential a <" + credentialTypeClass + "> . \n" +
|
"?credential a <" + credentialTypeClass + "> . \n" +
|
||||||
"?credential vivo:relatedBy ?issuedCredential . \n" +
|
"?credential vivo:relatedBy ?issuedCredential . \n" +
|
||||||
"?credential a ?credentialType . \n" +
|
"?credential a ?credentialType . \n" +
|
||||||
"?credential <"+ label + "> ?credentialLabel .";
|
"?credential <"+ label + "> ?credentialLabel .";
|
||||||
|
|
||||||
final static String n3ForExistingCredentialAssertion =
|
final static String n3ForExistingCredentialAssertion =
|
||||||
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
||||||
"?issuedCredential vivo:relates ?existingCredential . \n" +
|
"?issuedCredential vivo:relates ?existingCredential . \n" +
|
||||||
/* "?existingCredential a <" + credentialTypeClass + "> . \n" +
|
/* "?existingCredential a <" + credentialTypeClass + "> . \n" +
|
||||||
"?existingCredential a ?credentialType . \n" + */
|
"?existingCredential a ?credentialType . \n" + */
|
||||||
"?existingCredential vivo:relatedBy ?issuedCredential . " ;
|
"?existingCredential vivo:relatedBy ?issuedCredential . " ;
|
||||||
|
|
||||||
final static String n3ForYearCredentialed =
|
final static String n3ForYearCredentialed =
|
||||||
"?issuedCredential <" + yearCredentialedPred + "> ?yearCredentialedNode . \n" +
|
"?issuedCredential <" + yearCredentialedPred + "> ?yearCredentialedNode . \n" +
|
||||||
"?yearCredentialedNode a <" + dateTimeValueType + "> . \n" +
|
"?yearCredentialedNode a <" + dateTimeValueType + "> . \n" +
|
||||||
"?yearCredentialedNode <" + dateTimeValue + "> ?yearCredentialed-value . \n" +
|
"?yearCredentialedNode <" + dateTimeValue + "> ?yearCredentialed-value . \n" +
|
||||||
"?yearCredentialedNode <" + dateTimePrecision + "> ?yearCredentialed-precision .";
|
"?yearCredentialedNode <" + dateTimePrecision + "> ?yearCredentialed-precision .";
|
||||||
|
|
||||||
final static String n3ForStart =
|
final static String n3ForStart =
|
||||||
"?issuedCredential <" + issuedCredentialToInterval + "> ?intervalNode . \n" +
|
"?issuedCredential <" + issuedCredentialToInterval + "> ?intervalNode . \n" +
|
||||||
"?intervalNode a <" + intervalType + "> . \n" +
|
"?intervalNode a <" + intervalType + "> . \n" +
|
||||||
"?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
"?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
"?startNode a <" + dateTimeValueType + "> . \n" +
|
"?startNode a <" + dateTimeValueType + "> . \n" +
|
||||||
"?startNode <" + dateTimeValue + "> ?startField-value . \n" +
|
"?startNode <" + dateTimeValue + "> ?startField-value . \n" +
|
||||||
"?startNode <" + dateTimePrecision + "> ?startField-precision . \n";
|
"?startNode <" + dateTimePrecision + "> ?startField-precision . \n";
|
||||||
|
|
||||||
final static String n3ForEnd =
|
final static String n3ForEnd =
|
||||||
"?issuedCredential <" + issuedCredentialToInterval + "> ?intervalNode . \n" +
|
"?issuedCredential <" + issuedCredentialToInterval + "> ?intervalNode . \n" +
|
||||||
"?intervalNode a <" + intervalType + "> . \n" +
|
"?intervalNode a <" + intervalType + "> . \n" +
|
||||||
"?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
"?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
||||||
"?endNode a <" + dateTimeValueType + "> . \n" +
|
"?endNode a <" + dateTimeValueType + "> . \n" +
|
||||||
|
@ -233,13 +233,13 @@ public class PersonHasIssuedCredentialGenerator extends VivoBaseGenerator implem
|
||||||
" ?existingCredential <" + label + "> ?existingCredentialLabel . \n" +
|
" ?existingCredential <" + label + "> ?existingCredentialLabel . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String existingYearCredentialedQuery =
|
final static String existingYearCredentialedQuery =
|
||||||
"SELECT ?existingYearCredentialedValue WHERE { \n" +
|
"SELECT ?existingYearCredentialedValue WHERE { \n" +
|
||||||
" ?issuedCredential <" + yearCredentialedPred + "> ?yearCredentialedNode . \n" +
|
" ?issuedCredential <" + yearCredentialedPred + "> ?yearCredentialedNode . \n" +
|
||||||
" ?yearCredentialedNode a <" + dateTimeValueType + "> . \n" +
|
" ?yearCredentialedNode a <" + dateTimeValueType + "> . \n" +
|
||||||
" ?yearCredentialedNode <" + dateTimeValue + "> ?existingYearCredentialedValue }";
|
" ?yearCredentialedNode <" + dateTimeValue + "> ?existingYearCredentialedValue }";
|
||||||
|
|
||||||
final static String existingYearCredentialedNodeQuery =
|
final static String existingYearCredentialedNodeQuery =
|
||||||
"SELECT ?existingYearCredentialedNode WHERE { \n" +
|
"SELECT ?existingYearCredentialedNode WHERE { \n" +
|
||||||
" ?issuedCredential <" + yearCredentialedPred + "> ?existingYearCredentialedNode . }";
|
" ?issuedCredential <" + yearCredentialedPred + "> ?existingYearCredentialedNode . }";
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ public class PersonHasIssuedCredentialGenerator extends VivoBaseGenerator implem
|
||||||
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
" ?startNode a <" + dateTimeValueType +"> . \n" +
|
" ?startNode a <" + dateTimeValueType +"> . \n" +
|
||||||
" ?startNode <" + dateTimeValue + "> ?existingStartDate . }";
|
" ?startNode <" + dateTimeValue + "> ?existingStartDate . }";
|
||||||
|
|
||||||
final static String existingEndDateQuery =
|
final static String existingEndDateQuery =
|
||||||
"SELECT ?existingEndDate WHERE { \n" +
|
"SELECT ?existingEndDate WHERE { \n" +
|
||||||
" ?issuedCredential <" + issuedCredentialToInterval + "> ?intervalNode . \n" +
|
" ?issuedCredential <" + issuedCredentialToInterval + "> ?intervalNode . \n" +
|
||||||
|
@ -260,44 +260,44 @@ public class PersonHasIssuedCredentialGenerator extends VivoBaseGenerator implem
|
||||||
" ?endNode <" + dateTimeValue + "> ?existingEndDate . }";
|
" ?endNode <" + dateTimeValue + "> ?existingEndDate . }";
|
||||||
|
|
||||||
final static String existingIntervalNodeQuery =
|
final static String existingIntervalNodeQuery =
|
||||||
"SELECT ?existingIntervalNode WHERE { \n" +
|
"SELECT ?existingIntervalNode WHERE { \n" +
|
||||||
" ?issuedCredential <" + issuedCredentialToInterval + "> ?existingIntervalNode . \n" +
|
" ?issuedCredential <" + issuedCredentialToInterval + "> ?existingIntervalNode . \n" +
|
||||||
" ?existingIntervalNode a <" + intervalType + "> . }";
|
" ?existingIntervalNode a <" + intervalType + "> . }";
|
||||||
|
|
||||||
final static String existingStartNodeQuery =
|
final static String existingStartNodeQuery =
|
||||||
"SELECT ?existingStartNode WHERE { \n" +
|
"SELECT ?existingStartNode WHERE { \n" +
|
||||||
" ?issuedCredential <" + issuedCredentialToInterval + "> ?intervalNode . \n" +
|
" ?issuedCredential <" + issuedCredentialToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToStart + "> ?existingStartNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?existingStartNode . \n" +
|
||||||
" ?existingStartNode a <" + dateTimeValueType + "> . } ";
|
" ?existingStartNode a <" + dateTimeValueType + "> . } ";
|
||||||
|
|
||||||
final static String existingEndNodeQuery =
|
final static String existingEndNodeQuery =
|
||||||
"SELECT ?existingEndNode WHERE { \n" +
|
"SELECT ?existingEndNode WHERE { \n" +
|
||||||
" ?issuedCredential <" + issuedCredentialToInterval + "> ?intervalNode . \n" +
|
" ?issuedCredential <" + issuedCredentialToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToEnd + "> ?existingEndNode . \n" +
|
" ?intervalNode <" + intervalToEnd + "> ?existingEndNode . \n" +
|
||||||
" ?existingEndNode a <" + dateTimeValueType + "> } ";
|
" ?existingEndNode a <" + dateTimeValueType + "> } ";
|
||||||
|
|
||||||
final static String existingYearCredentialedPrecisionQuery =
|
final static String existingYearCredentialedPrecisionQuery =
|
||||||
"SELECT ?existingYearCredentialedPrecision WHERE { \n" +
|
"SELECT ?existingYearCredentialedPrecision WHERE { \n" +
|
||||||
" ?issuedCredential <" + yearCredentialedPred + "> ?yearCredentialed . \n" +
|
" ?issuedCredential <" + yearCredentialedPred + "> ?yearCredentialed . \n" +
|
||||||
" ?yearCredentialed a <" + dateTimeValueType + "> . \n" +
|
" ?yearCredentialed a <" + dateTimeValueType + "> . \n" +
|
||||||
" ?yearCredentialed <" + dateTimePrecision + "> ?existingYearCredentialedPrecision . }";
|
" ?yearCredentialed <" + dateTimePrecision + "> ?existingYearCredentialedPrecision . }";
|
||||||
|
|
||||||
final static String existingStartPrecisionQuery =
|
final static String existingStartPrecisionQuery =
|
||||||
"SELECT ?existingStartPrecision WHERE { \n" +
|
"SELECT ?existingStartPrecision WHERE { \n" +
|
||||||
" ?issuedCredential <" + issuedCredentialToInterval + "> ?intervalNode . \n" +
|
" ?issuedCredential <" + issuedCredentialToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
" ?startNode a <" + dateTimeValueType + "> . \n" +
|
" ?startNode a <" + dateTimeValueType + "> . \n" +
|
||||||
" ?startNode <" + dateTimePrecision + "> ?existingStartPrecision . }";
|
" ?startNode <" + dateTimePrecision + "> ?existingStartPrecision . }";
|
||||||
|
|
||||||
final static String existingEndPrecisionQuery =
|
final static String existingEndPrecisionQuery =
|
||||||
"SELECT ?existingEndPrecision WHERE { \n" +
|
"SELECT ?existingEndPrecision WHERE { \n" +
|
||||||
" ?issuedCredential <" + issuedCredentialToInterval + "> ?intervalNode . \n" +
|
" ?issuedCredential <" + issuedCredentialToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
" ?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
||||||
" ?endNode a <" + dateTimeValueType + "> . \n" +
|
" ?endNode a <" + dateTimeValueType + "> . \n" +
|
||||||
" ?endNode <" + dateTimePrecision + "> ?existingEndPrecision . }";
|
" ?endNode <" + dateTimePrecision + "> ?existingEndPrecision . }";
|
||||||
|
|
||||||
//Form specific data
|
//Form specific data
|
||||||
|
@ -306,7 +306,7 @@ public class PersonHasIssuedCredentialGenerator extends VivoBaseGenerator implem
|
||||||
formSpecificData.put("credentialTypeMap", getCredentialTypeMap());
|
formSpecificData.put("credentialTypeMap", getCredentialTypeMap());
|
||||||
editConfiguration.setFormSpecificData(formSpecificData);
|
editConfiguration.setFormSpecificData(formSpecificData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Issued Credentials relate a Credential to a person. The class type of a Credential and its subclasses
|
// Issued Credentials relate a Credential to a person. The class type of a Credential and its subclasses
|
||||||
// are different than -- but correspond to -- the class type of an Issued Credential and its subclasses.
|
// are different than -- but correspond to -- the class type of an Issued Credential and its subclasses.
|
||||||
// When a user picks a type of credential in the GUI, we need to set the corresponding type for the issued
|
// When a user picks a type of credential in the GUI, we need to set the corresponding type for the issued
|
||||||
|
|
|
@ -37,64 +37,64 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
||||||
final static String dateTimeValueType = vivoCore + "DateTimeValue";
|
final static String dateTimeValueType = vivoCore + "DateTimeValue";
|
||||||
final static String dateTimeValue = vivoCore + "dateTime";
|
final static String dateTimeValue = vivoCore + "dateTime";
|
||||||
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
|
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
|
||||||
|
|
||||||
public PersonHasPositionHistoryGenerator() {}
|
public PersonHasPositionHistoryGenerator() {}
|
||||||
|
|
||||||
// There are 4 modes that this form can be in:
|
// There are 4 modes that this form can be in:
|
||||||
// 1. Add. There is a subject and a predicate but no position and
|
// 1. Add. There is a subject and a predicate but no position and
|
||||||
// nothing else.
|
// nothing else.
|
||||||
//
|
//
|
||||||
// 2. Normal edit where everything should already be filled out.
|
// 2. Normal edit where everything should already be filled out.
|
||||||
// There is a subject, a object and an individual on
|
// There is a subject, a object and an individual on
|
||||||
// the other end of the object's core:personInOrganization stmt.
|
// the other end of the object's core:personInOrganization stmt.
|
||||||
//
|
//
|
||||||
// 3. Repair a bad role node. There is a subject, predicate and object
|
// 3. Repair a bad role node. There is a subject, predicate and object
|
||||||
// but there is no individual on the other end of the object's
|
// but there is no individual on the other end of the object's
|
||||||
// core:personInOrganization stmt. This should be similar to an add
|
// core:personInOrganization stmt. This should be similar to an add
|
||||||
// but the form should be expanded.
|
// but the form should be expanded.
|
||||||
//
|
//
|
||||||
// 4. Really bad node. multiple core:personInOrganization statements.
|
// 4. Really bad node. multiple core:personInOrganization statements.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
HttpSession session) throws Exception {
|
HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
|
|
||||||
conf.setTemplate("personHasPositionHistory.ftl");
|
conf.setTemplate("personHasPositionHistory.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("person");
|
conf.setVarNameForSubject("person");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("position");
|
conf.setVarNameForObject("position");
|
||||||
|
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewPosition,
|
conf.setN3Required( Arrays.asList( n3ForNewPosition,
|
||||||
positionTitleAssertion,
|
positionTitleAssertion,
|
||||||
positionTypeAssertion ) );
|
positionTypeAssertion ) );
|
||||||
conf.setN3Optional( Arrays.asList( n3ForNewOrg, n3ForExistingOrg, n3ForStart, n3ForEnd ) );
|
conf.setN3Optional( Arrays.asList( n3ForNewOrg, n3ForExistingOrg, n3ForStart, n3ForEnd ) );
|
||||||
|
|
||||||
conf.addNewResource("position", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("position", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("newOrg", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("newOrg", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
//uris in scope: none
|
//uris in scope: none
|
||||||
//literals in scope: none
|
//literals in scope: none
|
||||||
|
|
||||||
conf.setUrisOnform(Arrays.asList("existingOrg", "orgType", "positionType"));
|
conf.setUrisOnform(Arrays.asList("existingOrg", "orgType", "positionType"));
|
||||||
conf.setLiteralsOnForm(Arrays.asList("positionTitle", "orgLabel", "orgLabelDisplay"));
|
conf.setLiteralsOnForm(Arrays.asList("positionTitle", "orgLabel", "orgLabelDisplay"));
|
||||||
|
|
||||||
conf.addSparqlForExistingLiteral("orgLabel", orgLabelQuery);
|
conf.addSparqlForExistingLiteral("orgLabel", orgLabelQuery);
|
||||||
conf.addSparqlForExistingLiteral("positionTitle", positionTitleQuery);
|
conf.addSparqlForExistingLiteral("positionTitle", positionTitleQuery);
|
||||||
conf.addSparqlForExistingLiteral(
|
conf.addSparqlForExistingLiteral(
|
||||||
"startField-value", existingStartDateQuery);
|
"startField-value", existingStartDateQuery);
|
||||||
conf.addSparqlForExistingLiteral(
|
conf.addSparqlForExistingLiteral(
|
||||||
"endField-value", existingEndDateQuery);
|
"endField-value", existingEndDateQuery);
|
||||||
|
|
||||||
conf.addSparqlForExistingUris("existingOrg", existingOrgQuery);
|
conf.addSparqlForExistingUris("existingOrg", existingOrgQuery);
|
||||||
conf.addSparqlForExistingUris("orgType", orgTypeQuery);
|
conf.addSparqlForExistingUris("orgType", orgTypeQuery);
|
||||||
conf.addSparqlForExistingUris("positionType", positionTypeQuery);
|
conf.addSparqlForExistingUris("positionType", positionTypeQuery);
|
||||||
|
@ -102,26 +102,26 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
||||||
"intervalNode", existingIntervalNodeQuery);
|
"intervalNode", existingIntervalNodeQuery);
|
||||||
conf.addSparqlForExistingUris("startNode", existingStartNodeQuery);
|
conf.addSparqlForExistingUris("startNode", existingStartNodeQuery);
|
||||||
conf.addSparqlForExistingUris("endNode", existingEndNodeQuery);
|
conf.addSparqlForExistingUris("endNode", existingEndNodeQuery);
|
||||||
conf.addSparqlForExistingUris("startField-precision",
|
conf.addSparqlForExistingUris("startField-precision",
|
||||||
existingStartPrecisionQuery);
|
existingStartPrecisionQuery);
|
||||||
conf.addSparqlForExistingUris("endField-precision",
|
conf.addSparqlForExistingUris("endField-precision",
|
||||||
existingEndPrecisionQuery);
|
existingEndPrecisionQuery);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("positionTitle")
|
setName("positionTitle")
|
||||||
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators( list("nonempty") ) );
|
setValidators( list("nonempty") ) );
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("positionType").
|
setName("positionType").
|
||||||
setValidators( list("nonempty") ).
|
setValidators( list("nonempty") ).
|
||||||
setOptions(
|
setOptions(
|
||||||
new ChildVClassesWithParent(positionClass)));
|
new ChildVClassesWithParent(positionClass)));
|
||||||
|
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("existingOrg")); //options set in browser by auto complete JS
|
setName("existingOrg")); //options set in browser by auto complete JS
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("orgLabel").
|
setName("orgLabel").
|
||||||
setRangeDatatypeUri(XSD.xstring.toString() ).
|
setRangeDatatypeUri(XSD.xstring.toString() ).
|
||||||
|
@ -130,89 +130,89 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("orgLabelDisplay").
|
setName("orgLabelDisplay").
|
||||||
setRangeDatatypeUri(XSD.xstring.toString() ) );
|
setRangeDatatypeUri(XSD.xstring.toString() ) );
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("orgType").
|
setName("orgType").
|
||||||
setOptions(
|
setOptions(
|
||||||
new ChildVClassesWithParent(orgClass)));
|
new ChildVClassesWithParent(orgClass)));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().setName("startField").
|
conf.addField( new FieldVTwo().setName("startField").
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(null,
|
new DateTimeWithPrecisionVTwo(null,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())
|
VitroVocabulary.Precision.NONE.uri())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().setName("endField").
|
conf.addField( new FieldVTwo().setName("endField").
|
||||||
setEditElement(
|
setEditElement(
|
||||||
new DateTimeWithPrecisionVTwo(null,
|
new DateTimeWithPrecisionVTwo(null,
|
||||||
VitroVocabulary.Precision.YEAR.uri(),
|
VitroVocabulary.Precision.YEAR.uri(),
|
||||||
VitroVocabulary.Precision.NONE.uri())
|
VitroVocabulary.Precision.NONE.uri())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
|
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
conf.addValidator(new AutocompleteRequiredInputValidator("existingOrg", "orgLabel"));
|
conf.addValidator(new AutocompleteRequiredInputValidator("existingOrg", "orgLabel"));
|
||||||
|
|
||||||
//Adding additional data, specifically edit mode
|
//Adding additional data, specifically edit mode
|
||||||
addFormSpecificData(conf, vreq);
|
addFormSpecificData(conf, vreq);
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
final static String n3ForNewPosition =
|
final static String n3ForNewPosition =
|
||||||
"@prefix core: <" + vivoCore + "> . \n" +
|
"@prefix core: <" + vivoCore + "> . \n" +
|
||||||
"?person core:relatedBy ?position . \n" +
|
"?person core:relatedBy ?position . \n" +
|
||||||
"?position a ?positionType . \n" +
|
"?position a ?positionType . \n" +
|
||||||
"?position core:relates ?person ; ";
|
"?position core:relates ?person ; ";
|
||||||
|
|
||||||
final static String positionTitleAssertion =
|
final static String positionTitleAssertion =
|
||||||
"?position <" + label + "> ?positionTitle .";
|
"?position <" + label + "> ?positionTitle .";
|
||||||
|
|
||||||
final static String positionTypeAssertion =
|
|
||||||
"?position a ?positionType .";
|
|
||||||
|
|
||||||
final static String n3ForNewOrg =
|
final static String positionTypeAssertion =
|
||||||
|
"?position a ?positionType .";
|
||||||
|
|
||||||
|
final static String n3ForNewOrg =
|
||||||
"?position <" + positionInOrgPred + "> ?newOrg . \n" +
|
"?position <" + positionInOrgPred + "> ?newOrg . \n" +
|
||||||
"?newOrg <" + orgForPositionPred + "> ?position . \n" +
|
"?newOrg <" + orgForPositionPred + "> ?position . \n" +
|
||||||
"?newOrg <" + label + "> ?orgLabel . \n" +
|
"?newOrg <" + label + "> ?orgLabel . \n" +
|
||||||
"?newOrg a ?orgType .";
|
"?newOrg a ?orgType .";
|
||||||
|
|
||||||
final static String n3ForExistingOrg =
|
final static String n3ForExistingOrg =
|
||||||
"?position <" + positionInOrgPred + "> ?existingOrg . \n" +
|
"?position <" + positionInOrgPred + "> ?existingOrg . \n" +
|
||||||
"?existingOrg <" + orgForPositionPred + "> ?position . \n" +
|
"?existingOrg <" + orgForPositionPred + "> ?position . \n" +
|
||||||
"?existingOrg a ?orgType .";
|
"?existingOrg a ?orgType .";
|
||||||
|
|
||||||
final static String n3ForStart =
|
final static String n3ForStart =
|
||||||
"?position <" + positionToInterval + "> ?intervalNode . \n" +
|
"?position <" + positionToInterval + "> ?intervalNode . \n" +
|
||||||
"?intervalNode a <" + intervalType + "> . \n" +
|
"?intervalNode a <" + intervalType + "> . \n" +
|
||||||
"?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
"?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
"?startNode a <" + dateTimeValueType + "> . \n" +
|
"?startNode a <" + dateTimeValueType + "> . \n" +
|
||||||
"?startNode <" + dateTimeValue + "> ?startField-value . \n" +
|
"?startNode <" + dateTimeValue + "> ?startField-value . \n" +
|
||||||
"?startNode <" + dateTimePrecision + "> ?startField-precision . \n";
|
"?startNode <" + dateTimePrecision + "> ?startField-precision . \n";
|
||||||
|
|
||||||
final static String n3ForEnd =
|
final static String n3ForEnd =
|
||||||
"?position <" + positionToInterval + "> ?intervalNode . \n" +
|
"?position <" + positionToInterval + "> ?intervalNode . \n" +
|
||||||
"?intervalNode a <" + intervalType + "> . \n" +
|
"?intervalNode a <" + intervalType + "> . \n" +
|
||||||
"?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
"?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
||||||
"?endNode a <" + dateTimeValueType + "> . \n" +
|
"?endNode a <" + dateTimeValueType + "> . \n" +
|
||||||
"?endNode <" + dateTimeValue + "> ?endField-value . \n" +
|
"?endNode <" + dateTimeValue + "> ?endField-value . \n" +
|
||||||
"?endNode <" + dateTimePrecision + "> ?endField-precision . \n";
|
"?endNode <" + dateTimePrecision + "> ?endField-precision . \n";
|
||||||
|
|
||||||
// Queries for existing values
|
// Queries for existing values
|
||||||
final static String orgLabelQuery =
|
final static String orgLabelQuery =
|
||||||
"SELECT ?existingOrgLabel WHERE { \n" +
|
"SELECT ?existingOrgLabel WHERE { \n" +
|
||||||
" ?position <" + positionInOrgPred + "> ?existingOrg . \n" +
|
" ?position <" + positionInOrgPred + "> ?existingOrg . \n" +
|
||||||
" ?existingOrg a <" + orgClass + "> . \n" +
|
" ?existingOrg a <" + orgClass + "> . \n" +
|
||||||
" ?existingOrg <" + label + "> ?existingOrgLabel . \n" +
|
" ?existingOrg <" + label + "> ?existingOrgLabel . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String positionTitleQuery =
|
final static String positionTitleQuery =
|
||||||
"SELECT ?existingPositionTitle WHERE { \n" +
|
"SELECT ?existingPositionTitle WHERE { \n" +
|
||||||
"?position <" + label + "> ?existingPositionTitle . }";
|
"?position <" + label + "> ?existingPositionTitle . }";
|
||||||
|
|
||||||
final static String existingStartDateQuery =
|
final static String existingStartDateQuery =
|
||||||
"SELECT ?existingDateStart WHERE { \n" +
|
"SELECT ?existingDateStart WHERE { \n" +
|
||||||
" ?position <" + positionToInterval + "> ?intervalNode . \n" +
|
" ?position <" + positionToInterval + "> ?intervalNode . \n" +
|
||||||
|
@ -220,7 +220,7 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
||||||
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
" ?startNode a <" + dateTimeValueType +"> . \n" +
|
" ?startNode a <" + dateTimeValueType +"> . \n" +
|
||||||
" ?startNode <" + dateTimeValue + "> ?existingDateStart . }";
|
" ?startNode <" + dateTimeValue + "> ?existingDateStart . }";
|
||||||
|
|
||||||
final static String existingEndDateQuery =
|
final static String existingEndDateQuery =
|
||||||
"SELECT ?existingEndDate WHERE { \n" +
|
"SELECT ?existingEndDate WHERE { \n" +
|
||||||
" ?position <" + positionToInterval + "> ?intervalNode . \n" +
|
" ?position <" + positionToInterval + "> ?intervalNode . \n" +
|
||||||
|
@ -229,60 +229,60 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
||||||
" ?endNode a <" + dateTimeValueType + "> . \n" +
|
" ?endNode a <" + dateTimeValueType + "> . \n" +
|
||||||
" ?endNode <" + dateTimeValue + "> ?existingEndDate . }";
|
" ?endNode <" + dateTimeValue + "> ?existingEndDate . }";
|
||||||
|
|
||||||
final static String existingOrgQuery =
|
final static String existingOrgQuery =
|
||||||
"SELECT ?existingOrg WHERE { \n" +
|
"SELECT ?existingOrg WHERE { \n" +
|
||||||
" ?position <" + positionInOrgPred + "> ?existingOrg . \n" +
|
" ?position <" + positionInOrgPred + "> ?existingOrg . \n" +
|
||||||
" ?existingOrg a <" + orgClass + "> }";
|
" ?existingOrg a <" + orgClass + "> }";
|
||||||
|
|
||||||
final static String orgTypeQuery =
|
final static String orgTypeQuery =
|
||||||
"PREFIX rdfs: <" + rdfs + "> \n" +
|
"PREFIX rdfs: <" + rdfs + "> \n" +
|
||||||
"SELECT ?existingOrgType WHERE { \n" +
|
"SELECT ?existingOrgType WHERE { \n" +
|
||||||
" ?position <" + positionInOrgPred + "> ?existingOrg . \n" +
|
" ?position <" + positionInOrgPred + "> ?existingOrg . \n" +
|
||||||
" ?existingOrg a ?existingOrgType . \n" +
|
" ?existingOrg a ?existingOrgType . \n" +
|
||||||
" ?existingOrgType rdfs:subClassOf <" + orgClass + "> " +
|
" ?existingOrgType rdfs:subClassOf <" + orgClass + "> " +
|
||||||
"} ";
|
"} ";
|
||||||
|
|
||||||
//Huda: changed this from rdf:type to vitro:mostSpecificType since returning thing
|
//Huda: changed this from rdf:type to vitro:mostSpecificType since returning thing
|
||||||
final static String positionTypeQuery =
|
final static String positionTypeQuery =
|
||||||
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
||||||
"SELECT ?existingPositionType WHERE { \n" +
|
"SELECT ?existingPositionType WHERE { \n" +
|
||||||
" ?position vitro:mostSpecificType ?existingPositionType . }";
|
" ?position vitro:mostSpecificType ?existingPositionType . }";
|
||||||
|
|
||||||
final static String existingIntervalNodeQuery =
|
final static String existingIntervalNodeQuery =
|
||||||
"SELECT ?existingIntervalNode WHERE { \n" +
|
"SELECT ?existingIntervalNode WHERE { \n" +
|
||||||
" ?position <" + positionToInterval + "> ?existingIntervalNode . \n" +
|
" ?position <" + positionToInterval + "> ?existingIntervalNode . \n" +
|
||||||
" ?existingIntervalNode a <" + intervalType + "> . }";
|
" ?existingIntervalNode a <" + intervalType + "> . }";
|
||||||
|
|
||||||
final static String existingStartNodeQuery =
|
final static String existingStartNodeQuery =
|
||||||
"SELECT ?existingStartNode WHERE { \n" +
|
"SELECT ?existingStartNode WHERE { \n" +
|
||||||
" ?position <" + positionToInterval + "> ?intervalNode . \n" +
|
" ?position <" + positionToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToStart + "> ?existingStartNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?existingStartNode . \n" +
|
||||||
" ?existingStartNode a <" + dateTimeValueType + "> .} ";
|
" ?existingStartNode a <" + dateTimeValueType + "> .} ";
|
||||||
|
|
||||||
final static String existingEndNodeQuery =
|
final static String existingEndNodeQuery =
|
||||||
"SELECT ?existingEndNode WHERE { \n" +
|
"SELECT ?existingEndNode WHERE { \n" +
|
||||||
" ?position <" + positionToInterval + "> ?intervalNode . \n" +
|
" ?position <" + positionToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToEnd + "> ?existingEndNode . \n" +
|
" ?intervalNode <" + intervalToEnd + "> ?existingEndNode . \n" +
|
||||||
" ?existingEndNode a <" + dateTimeValueType + "> } ";
|
" ?existingEndNode a <" + dateTimeValueType + "> } ";
|
||||||
|
|
||||||
final static String existingStartPrecisionQuery =
|
final static String existingStartPrecisionQuery =
|
||||||
"SELECT ?existingStartPrecision WHERE { \n" +
|
"SELECT ?existingStartPrecision WHERE { \n" +
|
||||||
" ?position <" + positionToInterval + "> ?intervalNode . \n" +
|
" ?position <" + positionToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||||
" ?startNode a <" + dateTimeValueType + "> . \n" +
|
" ?startNode a <" + dateTimeValueType + "> . \n" +
|
||||||
" ?startNode <" + dateTimePrecision + "> ?existingStartPrecision . }";
|
" ?startNode <" + dateTimePrecision + "> ?existingStartPrecision . }";
|
||||||
|
|
||||||
final static String existingEndPrecisionQuery =
|
final static String existingEndPrecisionQuery =
|
||||||
"SELECT ?existingEndPrecision WHERE { \n" +
|
"SELECT ?existingEndPrecision WHERE { \n" +
|
||||||
" ?position <" + positionToInterval + "> ?intervalNode . \n" +
|
" ?position <" + positionToInterval + "> ?intervalNode . \n" +
|
||||||
" ?intervalNode a <" + intervalType + "> . \n" +
|
" ?intervalNode a <" + intervalType + "> . \n" +
|
||||||
" ?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
" ?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
||||||
" ?endNode a <" + dateTimeValueType + "> . \n" +
|
" ?endNode a <" + dateTimeValueType + "> . \n" +
|
||||||
" ?endNode <" + dateTimePrecision + "> ?existingEndPrecision . }";
|
" ?endNode <" + dateTimePrecision + "> ?existingEndPrecision . }";
|
||||||
|
|
||||||
//Adding form specific data such as edit mode
|
//Adding form specific data such as edit mode
|
||||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||||
|
|
|
@ -21,64 +21,64 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
|
||||||
public class PersonHasPreferredTitleGenerator extends VivoBaseGenerator implements
|
public class PersonHasPreferredTitleGenerator extends VivoBaseGenerator implements
|
||||||
EditConfigurationGenerator {
|
EditConfigurationGenerator {
|
||||||
private Log log = LogFactory.getLog(PersonHasPreferredTitleGenerator.class);
|
private Log log = LogFactory.getLog(PersonHasPreferredTitleGenerator.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
HttpSession session) throws Exception {
|
HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
String titleUri = getTitleUri(vreq);
|
String titleUri = getTitleUri(vreq);
|
||||||
|
|
||||||
conf.setTemplate("personHasPreferredTitle.ftl");
|
conf.setTemplate("personHasPreferredTitle.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("person");
|
conf.setVarNameForSubject("person");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("individualVcard");
|
conf.setVarNameForObject("individualVcard");
|
||||||
|
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewPhone ) );
|
conf.setN3Required( Arrays.asList( n3ForNewPhone ) );
|
||||||
conf.setN3Optional( Arrays.asList( preferredTitleAssertion ) );
|
conf.setN3Optional( Arrays.asList( preferredTitleAssertion ) );
|
||||||
|
|
||||||
conf.addNewResource("title", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("title", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("individualVcard", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("individualVcard", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
conf.setLiteralsOnForm(Arrays.asList("preferredTitle" ));
|
conf.setLiteralsOnForm(Arrays.asList("preferredTitle" ));
|
||||||
|
|
||||||
conf.addSparqlForExistingLiteral("preferredTitle", preferredTitleQuery);
|
conf.addSparqlForExistingLiteral("preferredTitle", preferredTitleQuery);
|
||||||
conf.addSparqlForAdditionalUrisInScope("individualVcard", individualVcardQuery);
|
conf.addSparqlForAdditionalUrisInScope("individualVcard", individualVcardQuery);
|
||||||
|
|
||||||
if ( conf.isUpdate() ) {
|
if ( conf.isUpdate() ) {
|
||||||
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
||||||
urisInScope.put("title", Arrays.asList(new String[]{titleUri}));
|
urisInScope.put("title", Arrays.asList(new String[]{titleUri}));
|
||||||
conf.addUrisInScope(urisInScope);
|
conf.addUrisInScope(urisInScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("preferredTitle")
|
setName("preferredTitle")
|
||||||
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators( list("nonempty") ));
|
setValidators( list("nonempty") ));
|
||||||
|
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
|
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* N3 assertions */
|
/* N3 assertions */
|
||||||
|
|
||||||
final static String n3ForNewPhone =
|
final static String n3ForNewPhone =
|
||||||
"?person <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
"?person <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
||||||
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?person . \n" +
|
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?person . \n" +
|
||||||
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasTitle> ?title . \n" +
|
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasTitle> ?title . \n" +
|
||||||
"?title a <http://www.w3.org/2006/vcard/ns#Title> . " ;
|
"?title a <http://www.w3.org/2006/vcard/ns#Title> . " ;
|
||||||
|
|
||||||
final static String preferredTitleAssertion =
|
final static String preferredTitleAssertion =
|
||||||
"?title <http://www.w3.org/2006/vcard/ns#title> ?preferredTitle .";
|
"?title <http://www.w3.org/2006/vcard/ns#title> ?preferredTitle .";
|
||||||
|
|
||||||
/* Queries for editing an existing entry */
|
/* Queries for editing an existing entry */
|
||||||
|
|
||||||
final static String individualVcardQuery =
|
final static String individualVcardQuery =
|
||||||
|
@ -86,13 +86,13 @@ public class PersonHasPreferredTitleGenerator extends VivoBaseGenerator implemen
|
||||||
"?person <http://purl.obolibrary.org/obo/ARG_2000028> ?existingIndividualVcard . \n" +
|
"?person <http://purl.obolibrary.org/obo/ARG_2000028> ?existingIndividualVcard . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String preferredTitleQuery =
|
final static String preferredTitleQuery =
|
||||||
"SELECT ?existingPreferredTitle WHERE {\n"+
|
"SELECT ?existingPreferredTitle WHERE {\n"+
|
||||||
"?title <http://www.w3.org/2006/vcard/ns#title> ?existingPreferredTitle . }";
|
"?title <http://www.w3.org/2006/vcard/ns#title> ?existingPreferredTitle . }";
|
||||||
|
|
||||||
private String getTitleUri(VitroRequest vreq) {
|
private String getTitleUri(VitroRequest vreq) {
|
||||||
String titleUri = vreq.getParameter("titleUri");
|
String titleUri = vreq.getParameter("titleUri");
|
||||||
|
|
||||||
return titleUri;
|
return titleUri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,48 +18,48 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
|
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
|
||||||
|
|
||||||
public class ProjectHasParticipantGenerator extends VivoBaseGenerator implements EditConfigurationGenerator{
|
public class ProjectHasParticipantGenerator extends VivoBaseGenerator implements EditConfigurationGenerator{
|
||||||
|
|
||||||
//TODO: can we get rid of the session and get it form the vreq?
|
//TODO: can we get rid of the session and get it form the vreq?
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) throws Exception {
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
|
|
||||||
conf.setTemplate("projectHasParticipant.ftl");
|
conf.setTemplate("projectHasParticipant.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("project");
|
conf.setVarNameForSubject("project");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("projectRole");
|
conf.setVarNameForObject("projectRole");
|
||||||
|
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewProjectRole ) );
|
conf.setN3Required( Arrays.asList( n3ForNewProjectRole ) );
|
||||||
conf.setN3Optional(Arrays.asList( n3ForNewPerson, n3ForExistingPerson, firstNameAssertion, lastNameAssertion ) );
|
conf.setN3Optional(Arrays.asList( n3ForNewPerson, n3ForExistingPerson, firstNameAssertion, lastNameAssertion ) );
|
||||||
|
|
||||||
conf.addNewResource("projectRole", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("projectRole", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("newPerson",DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("newPerson",DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("vcardPerson", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("vcardPerson", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("vcardName", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("vcardName", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
//uris in scope: none
|
//uris in scope: none
|
||||||
//literals in scope: none
|
//literals in scope: none
|
||||||
|
|
||||||
conf.setUrisOnform( Arrays.asList( "existingPerson"));
|
conf.setUrisOnform( Arrays.asList( "existingPerson"));
|
||||||
conf.setLiteralsOnForm( Arrays.asList("personLabel", "personLabelDisplay", "roleLabel",
|
conf.setLiteralsOnForm( Arrays.asList("personLabel", "personLabelDisplay", "roleLabel",
|
||||||
"roleLabeldisplay", "firstName", "lastName"));
|
"roleLabeldisplay", "firstName", "lastName"));
|
||||||
|
|
||||||
conf.addSparqlForExistingLiteral("personLabel", personLabelQuery);
|
conf.addSparqlForExistingLiteral("personLabel", personLabelQuery);
|
||||||
conf.addSparqlForExistingLiteral("roleLabel", roleLabelQuery);
|
conf.addSparqlForExistingLiteral("roleLabel", roleLabelQuery);
|
||||||
|
|
||||||
conf.addSparqlForExistingUris("existingPerson", existingPersonQuery);
|
conf.addSparqlForExistingUris("existingPerson", existingPersonQuery);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("existingPerson")
|
setName("existingPerson")
|
||||||
//options will be added in browser by auto complete JS
|
//options will be added in browser by auto complete JS
|
||||||
);
|
);
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("personLabel").
|
setName("personLabel").
|
||||||
setRangeDatatypeUri(XSD.xstring.toString() ).
|
setRangeDatatypeUri(XSD.xstring.toString() ).
|
||||||
|
@ -69,7 +69,7 @@ public class ProjectHasParticipantGenerator extends VivoBaseGenerator implement
|
||||||
setName("roleLabel").
|
setName("roleLabel").
|
||||||
setRangeDatatypeUri(XSD.xstring.toString() ).
|
setRangeDatatypeUri(XSD.xstring.toString() ).
|
||||||
setValidators( list("datatype:" + XSD.xstring.toString(),"nonempty")));
|
setValidators( list("datatype:" + XSD.xstring.toString(),"nonempty")));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("personLabelDisplay").
|
setName("personLabelDisplay").
|
||||||
setRangeDatatypeUri(XSD.xstring.toString() ));
|
setRangeDatatypeUri(XSD.xstring.toString() ));
|
||||||
|
@ -77,7 +77,7 @@ public class ProjectHasParticipantGenerator extends VivoBaseGenerator implement
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("roleLabelDisplay").
|
setName("roleLabelDisplay").
|
||||||
setRangeDatatypeUri(XSD.xstring.toString() ));
|
setRangeDatatypeUri(XSD.xstring.toString() ));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("firstName").
|
setName("firstName").
|
||||||
setRangeDatatypeUri(XSD.xstring.toString() ).
|
setRangeDatatypeUri(XSD.xstring.toString() ).
|
||||||
|
@ -93,16 +93,16 @@ public class ProjectHasParticipantGenerator extends VivoBaseGenerator implement
|
||||||
//Add validator
|
//Add validator
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
conf.addValidator(new FirstAndLastNameValidator("existingPerson"));
|
conf.addValidator(new FirstAndLastNameValidator("existingPerson"));
|
||||||
|
|
||||||
//Adding additional data, specifically edit mode
|
//Adding additional data, specifically edit mode
|
||||||
addFormSpecificData(conf, vreq);
|
addFormSpecificData(conf, vreq);
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* N3 assertions for working with educational training */
|
/* N3 assertions for working with educational training */
|
||||||
|
|
||||||
final static String n3ForNewProjectRole =
|
final static String n3ForNewProjectRole =
|
||||||
"@prefix core: <"+ vivoCore +"> .\n" +
|
"@prefix core: <"+ vivoCore +"> .\n" +
|
||||||
"@prefix rdfs: <"+ rdfs +"> . \n"+
|
"@prefix rdfs: <"+ rdfs +"> . \n"+
|
||||||
"?project <http://purl.obolibrary.org/obo/BFO_0000055> ?projectRole .\n" +
|
"?project <http://purl.obolibrary.org/obo/BFO_0000055> ?projectRole .\n" +
|
||||||
|
@ -110,42 +110,42 @@ public class ProjectHasParticipantGenerator extends VivoBaseGenerator implement
|
||||||
"?projectRole <http://purl.obolibrary.org/obo/BFO_0000054> ?project . \n" +
|
"?projectRole <http://purl.obolibrary.org/obo/BFO_0000054> ?project . \n" +
|
||||||
"?projectRole <"+ label +"> ?roleLabel . \n" ;
|
"?projectRole <"+ label +"> ?roleLabel . \n" ;
|
||||||
|
|
||||||
final static String n3ForNewPerson =
|
final static String n3ForNewPerson =
|
||||||
"?projectRole <http://purl.obolibrary.org/obo/RO_0000052> ?newPerson . \n" +
|
"?projectRole <http://purl.obolibrary.org/obo/RO_0000052> ?newPerson . \n" +
|
||||||
"?newPerson <http://purl.obolibrary.org/obo/RO_0000053> ?projectRole . \n" +
|
"?newPerson <http://purl.obolibrary.org/obo/RO_0000053> ?projectRole . \n" +
|
||||||
"?newPerson a <http://xmlns.com/foaf/0.1/Person> . \n" +
|
"?newPerson a <http://xmlns.com/foaf/0.1/Person> . \n" +
|
||||||
"?newPerson <"+ label +"> ?personLabel . ";
|
"?newPerson <"+ label +"> ?personLabel . ";
|
||||||
|
|
||||||
final static String n3ForExistingPerson =
|
final static String n3ForExistingPerson =
|
||||||
"?projectRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingPerson . \n" +
|
"?projectRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingPerson . \n" +
|
||||||
"?existingPerson <http://purl.obolibrary.org/obo/RO_0000053> ?projectRole . \n" +
|
"?existingPerson <http://purl.obolibrary.org/obo/RO_0000053> ?projectRole . \n" +
|
||||||
" ";
|
" ";
|
||||||
|
|
||||||
final static String firstNameAssertion =
|
final static String firstNameAssertion =
|
||||||
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
||||||
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
||||||
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
||||||
"?vcardName vcard:givenName ?firstName .";
|
"?vcardName vcard:givenName ?firstName .";
|
||||||
|
|
||||||
final static String lastNameAssertion =
|
final static String lastNameAssertion =
|
||||||
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
|
||||||
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
"?newPerson <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardPerson . \n" +
|
||||||
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
"?vcardPerson <http://purl.obolibrary.org/obo/ARG_2000029> ?newPerson . \n" +
|
||||||
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?vcardPerson a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
"?vcardPerson vcard:hasName ?vcardName . \n" +
|
||||||
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
|
||||||
"?vcardName vcard:familyName ?lastName .";
|
"?vcardName vcard:familyName ?lastName .";
|
||||||
|
|
||||||
/* Queries for editing an existing educational training entry */
|
/* Queries for editing an existing educational training entry */
|
||||||
|
|
||||||
final static String roleLabelQuery =
|
final static String roleLabelQuery =
|
||||||
"SELECT ?roleLabel WHERE {\n"+
|
"SELECT ?roleLabel WHERE {\n"+
|
||||||
"?projectRole <"+ label +"> ?roleLabel }\n";
|
"?projectRole <"+ label +"> ?roleLabel }\n";
|
||||||
|
|
||||||
final static String existingPersonQuery =
|
final static String existingPersonQuery =
|
||||||
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
||||||
"SELECT ?existingPerson WHERE {\n"+
|
"SELECT ?existingPerson WHERE {\n"+
|
||||||
"?projectRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingPerson . \n" +
|
"?projectRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingPerson . \n" +
|
||||||
|
@ -153,7 +153,7 @@ public class ProjectHasParticipantGenerator extends VivoBaseGenerator implement
|
||||||
"?existingPerson a <http://xmlns.com/foaf/0.1/Person> . \n " +
|
"?existingPerson a <http://xmlns.com/foaf/0.1/Person> . \n " +
|
||||||
" }";
|
" }";
|
||||||
|
|
||||||
final static String personLabelQuery =
|
final static String personLabelQuery =
|
||||||
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
"PREFIX rdfs: <"+ rdfs +"> \n"+
|
||||||
"SELECT ?existingPersonLabel WHERE {\n"+
|
"SELECT ?existingPersonLabel WHERE {\n"+
|
||||||
"?projectRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingPerson . \n" +
|
"?projectRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingPerson . \n" +
|
||||||
|
@ -162,14 +162,14 @@ public class ProjectHasParticipantGenerator extends VivoBaseGenerator implement
|
||||||
"?existingPerson a <http://xmlns.com/foaf/0.1/Person> . \n " +
|
"?existingPerson a <http://xmlns.com/foaf/0.1/Person> . \n " +
|
||||||
" }";
|
" }";
|
||||||
|
|
||||||
|
|
||||||
//Adding form specific data such as edit mode
|
//Adding form specific data such as edit mode
|
||||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||||
formSpecificData.put("editMode", getEditMode(vreq).name().toLowerCase());
|
formSpecificData.put("editMode", getEditMode(vreq).name().toLowerCase());
|
||||||
editConfiguration.setFormSpecificData(formSpecificData);
|
editConfiguration.setFormSpecificData(formSpecificData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EditMode getEditMode(VitroRequest vreq) {
|
public EditMode getEditMode(VitroRequest vreq) {
|
||||||
List<String> predicates = new ArrayList<String>();
|
List<String> predicates = new ArrayList<String>();
|
||||||
predicates.add("http://purl.obolibrary.org/obo/RO_0000053");
|
predicates.add("http://purl.obolibrary.org/obo/RO_0000053");
|
||||||
|
|
|
@ -21,42 +21,42 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
|
||||||
public class SubjectHasMailingAddressGenerator extends VivoBaseGenerator implements
|
public class SubjectHasMailingAddressGenerator extends VivoBaseGenerator implements
|
||||||
EditConfigurationGenerator {
|
EditConfigurationGenerator {
|
||||||
private Log log = LogFactory.getLog(SubjectHasMailingAddressGenerator.class);
|
private Log log = LogFactory.getLog(SubjectHasMailingAddressGenerator.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
HttpSession session) throws Exception {
|
HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
String addressUri = vreq.getParameter("addressUri");
|
String addressUri = vreq.getParameter("addressUri");
|
||||||
|
|
||||||
conf.setTemplate("subjectHasMailingAddress.ftl");
|
conf.setTemplate("subjectHasMailingAddress.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("subject");
|
conf.setVarNameForSubject("subject");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("individualVcard");
|
conf.setVarNameForObject("individualVcard");
|
||||||
|
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewAddress ) );
|
conf.setN3Required( Arrays.asList( n3ForNewAddress ) );
|
||||||
conf.setN3Optional( Arrays.asList( streetAddressAssertion,
|
conf.setN3Optional( Arrays.asList( streetAddressAssertion,
|
||||||
localityAssertion,
|
localityAssertion,
|
||||||
regionAssertion,
|
regionAssertion,
|
||||||
countryAssertion,
|
countryAssertion,
|
||||||
postalCodeAssertion ) );
|
postalCodeAssertion ) );
|
||||||
|
|
||||||
conf.addNewResource("address", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("address", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("individualVcard", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("individualVcard", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
conf.setLiteralsOnForm(Arrays.asList("streetAddress", "locality", "postalCode", "country", "region" ));
|
conf.setLiteralsOnForm(Arrays.asList("streetAddress", "locality", "postalCode", "country", "region" ));
|
||||||
|
|
||||||
conf.addSparqlForExistingLiteral("streetAddress", streetAddressQuery);
|
conf.addSparqlForExistingLiteral("streetAddress", streetAddressQuery);
|
||||||
conf.addSparqlForExistingLiteral("locality", localityQuery);
|
conf.addSparqlForExistingLiteral("locality", localityQuery);
|
||||||
conf.addSparqlForExistingLiteral("postalCode", postalCodeQuery);
|
conf.addSparqlForExistingLiteral("postalCode", postalCodeQuery);
|
||||||
conf.addSparqlForExistingLiteral("region", regionQuery);
|
conf.addSparqlForExistingLiteral("region", regionQuery);
|
||||||
conf.addSparqlForExistingLiteral("country", countryQuery);
|
conf.addSparqlForExistingLiteral("country", countryQuery);
|
||||||
|
|
||||||
if ( conf.isUpdate() ) {
|
if ( conf.isUpdate() ) {
|
||||||
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
||||||
urisInScope.put("address", Arrays.asList(new String[]{addressUri}));
|
urisInScope.put("address", Arrays.asList(new String[]{addressUri}));
|
||||||
|
@ -66,58 +66,58 @@ public class SubjectHasMailingAddressGenerator extends VivoBaseGenerator impleme
|
||||||
conf.addSparqlForAdditionalUrisInScope("individualVcard", individualVcardQuery);
|
conf.addSparqlForAdditionalUrisInScope("individualVcard", individualVcardQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("streetAddress")
|
setName("streetAddress")
|
||||||
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators( list("nonempty") ));
|
setValidators( list("nonempty") ));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("country")
|
setName("country")
|
||||||
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators( list("nonempty") ));
|
setValidators( list("nonempty") ));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("postalCode")
|
setName("postalCode")
|
||||||
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators( list("nonempty") ));
|
setValidators( list("nonempty") ));
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("locality")
|
setName("locality")
|
||||||
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators( list("nonempty") ) );
|
setValidators( list("nonempty") ) );
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("region")
|
setName("region")
|
||||||
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators( list("datatype:" + XSD.xstring.toString()) ) );
|
setValidators( list("datatype:" + XSD.xstring.toString()) ) );
|
||||||
|
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
|
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* N3 assertions */
|
/* N3 assertions */
|
||||||
|
|
||||||
final static String n3ForNewAddress =
|
final static String n3ForNewAddress =
|
||||||
"?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
"?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
||||||
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?subject . \n" +
|
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?subject . \n" +
|
||||||
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasAddress> ?address . \n" +
|
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasAddress> ?address . \n" +
|
||||||
"?address a <http://www.w3.org/2006/vcard/ns#Address> . " ;
|
"?address a <http://www.w3.org/2006/vcard/ns#Address> . " ;
|
||||||
|
|
||||||
final static String streetAddressAssertion =
|
final static String streetAddressAssertion =
|
||||||
"?address <http://www.w3.org/2006/vcard/ns#streetAddress> ?streetAddress .";
|
"?address <http://www.w3.org/2006/vcard/ns#streetAddress> ?streetAddress .";
|
||||||
|
|
||||||
final static String localityAssertion =
|
final static String localityAssertion =
|
||||||
"?address <http://www.w3.org/2006/vcard/ns#locality> ?locality .";
|
"?address <http://www.w3.org/2006/vcard/ns#locality> ?locality .";
|
||||||
|
|
||||||
final static String postalCodeAssertion =
|
final static String postalCodeAssertion =
|
||||||
"?address <http://www.w3.org/2006/vcard/ns#postalCode> ?postalCode .";
|
"?address <http://www.w3.org/2006/vcard/ns#postalCode> ?postalCode .";
|
||||||
|
|
||||||
final static String regionAssertion =
|
final static String regionAssertion =
|
||||||
"?address <http://www.w3.org/2006/vcard/ns#region> ?region .";
|
"?address <http://www.w3.org/2006/vcard/ns#region> ?region .";
|
||||||
|
|
||||||
final static String countryAssertion =
|
final static String countryAssertion =
|
||||||
"?address <http://www.w3.org/2006/vcard/ns#country> ?country .";
|
"?address <http://www.w3.org/2006/vcard/ns#country> ?country .";
|
||||||
|
|
||||||
|
@ -129,23 +129,23 @@ public class SubjectHasMailingAddressGenerator extends VivoBaseGenerator impleme
|
||||||
"?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
"?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String streetAddressQuery =
|
final static String streetAddressQuery =
|
||||||
"SELECT ?existingStreetAddress WHERE {\n"+
|
"SELECT ?existingStreetAddress WHERE {\n"+
|
||||||
"?address <http://www.w3.org/2006/vcard/ns#streetAddress> ?existingStreetAddress . }";
|
"?address <http://www.w3.org/2006/vcard/ns#streetAddress> ?existingStreetAddress . }";
|
||||||
|
|
||||||
final static String localityQuery =
|
final static String localityQuery =
|
||||||
"SELECT ?existingLocality WHERE {\n"+
|
"SELECT ?existingLocality WHERE {\n"+
|
||||||
"?address <http://www.w3.org/2006/vcard/ns#locality> ?existingLocality . }";
|
"?address <http://www.w3.org/2006/vcard/ns#locality> ?existingLocality . }";
|
||||||
|
|
||||||
final static String regionQuery =
|
final static String regionQuery =
|
||||||
"SELECT ?existingRegion WHERE {\n"+
|
"SELECT ?existingRegion WHERE {\n"+
|
||||||
"?address <http://www.w3.org/2006/vcard/ns#region> ?existingRegion . }";
|
"?address <http://www.w3.org/2006/vcard/ns#region> ?existingRegion . }";
|
||||||
|
|
||||||
final static String postalCodeQuery =
|
final static String postalCodeQuery =
|
||||||
"SELECT ?existingPostalCode WHERE {\n"+
|
"SELECT ?existingPostalCode WHERE {\n"+
|
||||||
"?address <http://www.w3.org/2006/vcard/ns#postalCode> ?existingPostalCode . }";
|
"?address <http://www.w3.org/2006/vcard/ns#postalCode> ?existingPostalCode . }";
|
||||||
|
|
||||||
final static String countryQuery =
|
final static String countryQuery =
|
||||||
"SELECT ?existingCountry WHERE {\n"+
|
"SELECT ?existingCountry WHERE {\n"+
|
||||||
"?address <http://www.w3.org/2006/vcard/ns#country> ?existingCountry . }";
|
"?address <http://www.w3.org/2006/vcard/ns#country> ?existingCountry . }";
|
||||||
|
|
||||||
|
|
|
@ -25,27 +25,27 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
|
||||||
public class SubjectHasPhoneFaxNumberGenerator extends VivoBaseGenerator implements
|
public class SubjectHasPhoneFaxNumberGenerator extends VivoBaseGenerator implements
|
||||||
EditConfigurationGenerator {
|
EditConfigurationGenerator {
|
||||||
private Log log = LogFactory.getLog(SubjectHasPhoneFaxNumberGenerator.class);
|
private Log log = LogFactory.getLog(SubjectHasPhoneFaxNumberGenerator.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
HttpSession session) throws Exception {
|
HttpSession session) throws Exception {
|
||||||
|
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
Model model = ModelFactory.createDefaultModel();
|
Model model = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
initBasics(conf, vreq);
|
initBasics(conf, vreq);
|
||||||
initPropertyParameters(vreq, session, conf);
|
initPropertyParameters(vreq, session, conf);
|
||||||
initObjectPropForm(conf, vreq);
|
initObjectPropForm(conf, vreq);
|
||||||
String phoneUri = getPhoneUri(vreq);
|
String phoneUri = getPhoneUri(vreq);
|
||||||
String rangeUri = getRangeUri(vreq);
|
String rangeUri = getRangeUri(vreq);
|
||||||
Literal numberType = null;
|
Literal numberType = null;
|
||||||
|
|
||||||
conf.setTemplate("subjectHasPhoneFaxNumber.ftl");
|
conf.setTemplate("subjectHasPhoneFaxNumber.ftl");
|
||||||
|
|
||||||
conf.setVarNameForSubject("subject");
|
conf.setVarNameForSubject("subject");
|
||||||
conf.setVarNameForPredicate("predicate");
|
conf.setVarNameForPredicate("predicate");
|
||||||
conf.setVarNameForObject("individualVcard");
|
conf.setVarNameForObject("individualVcard");
|
||||||
|
|
||||||
if ( rangeUri.equals("http://www.w3.org/2006/vcard/ns#Fax") ) {
|
if ( rangeUri.equals("http://www.w3.org/2006/vcard/ns#Fax") ) {
|
||||||
conf.setN3Required( Arrays.asList( n3ForNewFaxNumber ) );
|
conf.setN3Required( Arrays.asList( n3ForNewFaxNumber ) );
|
||||||
numberType = model.createLiteral("fax");
|
numberType = model.createLiteral("fax");
|
||||||
|
@ -56,15 +56,15 @@ public class SubjectHasPhoneFaxNumberGenerator extends VivoBaseGenerator impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.setN3Optional( Arrays.asList( telephoneNumberAssertion ) );
|
conf.setN3Optional( Arrays.asList( telephoneNumberAssertion ) );
|
||||||
|
|
||||||
conf.addNewResource("phone", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("phone", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
conf.addNewResource("individualVcard", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("individualVcard", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||||
|
|
||||||
conf.setLiteralsOnForm(Arrays.asList("telephoneNumber" ));
|
conf.setLiteralsOnForm(Arrays.asList("telephoneNumber" ));
|
||||||
|
|
||||||
conf.addSparqlForExistingLiteral("telephoneNumber", telephoneNumberQuery);
|
conf.addSparqlForExistingLiteral("telephoneNumber", telephoneNumberQuery);
|
||||||
conf.addSparqlForAdditionalUrisInScope("individualVcard", individualVcardQuery);
|
conf.addSparqlForAdditionalUrisInScope("individualVcard", individualVcardQuery);
|
||||||
|
|
||||||
conf.addLiteralInScope("numberType", numberType);
|
conf.addLiteralInScope("numberType", numberType);
|
||||||
|
|
||||||
if ( conf.isUpdate() ) {
|
if ( conf.isUpdate() ) {
|
||||||
|
@ -73,37 +73,37 @@ public class SubjectHasPhoneFaxNumberGenerator extends VivoBaseGenerator impleme
|
||||||
conf.addUrisInScope(urisInScope);
|
conf.addUrisInScope(urisInScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.addField( new FieldVTwo().
|
conf.addField( new FieldVTwo().
|
||||||
setName("telephoneNumber")
|
setName("telephoneNumber")
|
||||||
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||||
setValidators( list("nonempty") ));
|
setValidators( list("nonempty") ));
|
||||||
|
|
||||||
conf.addValidator(new AntiXssValidation());
|
conf.addValidator(new AntiXssValidation());
|
||||||
|
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* N3 assertions */
|
/* N3 assertions */
|
||||||
|
|
||||||
final static String n3ForNewPhoneNumber =
|
final static String n3ForNewPhoneNumber =
|
||||||
"?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
"?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
||||||
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?subject . \n" +
|
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?subject . \n" +
|
||||||
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasTelephone> ?phone . \n" +
|
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasTelephone> ?phone . \n" +
|
||||||
"?phone a <http://www.w3.org/2006/vcard/ns#Telephone> . " ;
|
"?phone a <http://www.w3.org/2006/vcard/ns#Telephone> . " ;
|
||||||
|
|
||||||
final static String n3ForNewFaxNumber =
|
|
||||||
"?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
|
||||||
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
|
||||||
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?subject . \n" +
|
|
||||||
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasTelephone> ?phone . \n" +
|
|
||||||
"?phone a <http://www.w3.org/2006/vcard/ns#Telephone> . \n " +
|
|
||||||
"?phone a <http://www.w3.org/2006/vcard/ns#Fax> . " ;
|
|
||||||
|
|
||||||
final static String telephoneNumberAssertion =
|
final static String n3ForNewFaxNumber =
|
||||||
|
"?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
|
||||||
|
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
|
||||||
|
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?subject . \n" +
|
||||||
|
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasTelephone> ?phone . \n" +
|
||||||
|
"?phone a <http://www.w3.org/2006/vcard/ns#Telephone> . \n " +
|
||||||
|
"?phone a <http://www.w3.org/2006/vcard/ns#Fax> . " ;
|
||||||
|
|
||||||
|
final static String telephoneNumberAssertion =
|
||||||
"?phone <http://www.w3.org/2006/vcard/ns#telephone> ?telephoneNumber .";
|
"?phone <http://www.w3.org/2006/vcard/ns#telephone> ?telephoneNumber .";
|
||||||
|
|
||||||
/* Queries for editing an existing entry */
|
/* Queries for editing an existing entry */
|
||||||
|
|
||||||
final static String individualVcardQuery =
|
final static String individualVcardQuery =
|
||||||
|
@ -111,19 +111,19 @@ public class SubjectHasPhoneFaxNumberGenerator extends VivoBaseGenerator impleme
|
||||||
"?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?existingIndividualVcard . \n" +
|
"?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?existingIndividualVcard . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
final static String telephoneNumberQuery =
|
final static String telephoneNumberQuery =
|
||||||
"SELECT ?existingTelephoneNumber WHERE {\n"+
|
"SELECT ?existingTelephoneNumber WHERE {\n"+
|
||||||
"?phone <http://www.w3.org/2006/vcard/ns#telephone> ?existingTelephoneNumber . }";
|
"?phone <http://www.w3.org/2006/vcard/ns#telephone> ?existingTelephoneNumber . }";
|
||||||
|
|
||||||
private String getPhoneUri(VitroRequest vreq) {
|
private String getPhoneUri(VitroRequest vreq) {
|
||||||
String phoneUri = vreq.getParameter("phoneUri");
|
String phoneUri = vreq.getParameter("phoneUri");
|
||||||
|
|
||||||
return phoneUri;
|
return phoneUri;
|
||||||
}
|
}
|
||||||
private String getRangeUri(VitroRequest vreq) {
|
private String getRangeUri(VitroRequest vreq) {
|
||||||
String rangeUri = vreq.getParameter("rangeUri");
|
String rangeUri = vreq.getParameter("rangeUri");
|
||||||
|
|
||||||
return rangeUri;
|
return rangeUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class VIVODefaultAddMissingIndividualFormGenerator extends DefaultAddMissingIndividualFormGenerator {
|
public class VIVODefaultAddMissingIndividualFormGenerator extends DefaultAddMissingIndividualFormGenerator {
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(VIVODefaultAddMissingIndividualFormGenerator.class);
|
private Log log = LogFactory.getLog(VIVODefaultAddMissingIndividualFormGenerator.class);
|
||||||
|
|
||||||
protected Map<String, String> generateNewResources(VitroRequest vreq) {
|
protected Map<String, String> generateNewResources(VitroRequest vreq) {
|
||||||
|
@ -37,11 +37,11 @@ public class VIVODefaultAddMissingIndividualFormGenerator extends DefaultAddMiss
|
||||||
prefixStrings.add("@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .");
|
prefixStrings.add("@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .");
|
||||||
return prefixStrings;
|
return prefixStrings;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getN3ForName() {
|
protected String getN3ForName() {
|
||||||
return "?" + objectVarName + " rdfs:label ?label .";
|
return "?" + objectVarName + " rdfs:label ?label .";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<String> generateN3Optional(VitroRequest vreq) {
|
protected List<String> generateN3Optional(VitroRequest vreq) {
|
||||||
List<String> n3Optional = super.generateN3Optional(vreq);
|
List<String> n3Optional = super.generateN3Optional(vreq);
|
||||||
n3Optional.add(getN3PrefixesAsString()
|
n3Optional.add(getN3PrefixesAsString()
|
||||||
|
@ -52,7 +52,7 @@ public class VIVODefaultAddMissingIndividualFormGenerator extends DefaultAddMiss
|
||||||
+ " ?newVcardName a vcard:Name . \n"
|
+ " ?newVcardName a vcard:Name . \n"
|
||||||
+ " ?newVcardName vcard:givenName ?firstName . \n"
|
+ " ?newVcardName vcard:givenName ?firstName . \n"
|
||||||
+ " ?newVcardName vcard:familyName ?lastName . \n");
|
+ " ?newVcardName vcard:familyName ?lastName . \n");
|
||||||
n3Optional.add(getN3PrefixesAsString()
|
n3Optional.add(getN3PrefixesAsString()
|
||||||
+ "?" + objectVarName + "<http://purl.obolibrary.org/obo/ARG_2000028> ?newVcardInd . \n"
|
+ "?" + objectVarName + "<http://purl.obolibrary.org/obo/ARG_2000028> ?newVcardInd . \n"
|
||||||
+ " ?newVcardInd a vcard:Individual . \n"
|
+ " ?newVcardInd a vcard:Individual . \n"
|
||||||
+ " ?newVcardInd vcard:hasName ?newVcardName . \n"
|
+ " ?newVcardInd vcard:hasName ?newVcardName . \n"
|
||||||
|
@ -75,39 +75,39 @@ public class VIVODefaultAddMissingIndividualFormGenerator extends DefaultAddMiss
|
||||||
protected void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
|
protected void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
|
||||||
Map<String, FieldVTwo> fields = new HashMap<String, FieldVTwo>();
|
Map<String, FieldVTwo> fields = new HashMap<String, FieldVTwo>();
|
||||||
if(EditConfigurationUtils.isObjectProperty(EditConfigurationUtils.getPredicateUri(vreq), vreq)) {
|
if(EditConfigurationUtils.isObjectProperty(EditConfigurationUtils.getPredicateUri(vreq), vreq)) {
|
||||||
|
|
||||||
//make name field
|
//make name field
|
||||||
FieldVTwo labelField = new FieldVTwo();
|
FieldVTwo labelField = new FieldVTwo();
|
||||||
labelField.setName("label");
|
labelField.setName("label");
|
||||||
|
|
||||||
FieldVTwo firstNameField = new FieldVTwo();
|
FieldVTwo firstNameField = new FieldVTwo();
|
||||||
firstNameField.setName("firstName");
|
firstNameField.setName("firstName");
|
||||||
|
|
||||||
FieldVTwo middleNameField = new FieldVTwo();
|
FieldVTwo middleNameField = new FieldVTwo();
|
||||||
middleNameField.setName("middleName");
|
middleNameField.setName("middleName");
|
||||||
|
|
||||||
FieldVTwo lastNameField = new FieldVTwo();
|
FieldVTwo lastNameField = new FieldVTwo();
|
||||||
lastNameField.setName("lastName");
|
lastNameField.setName("lastName");
|
||||||
|
|
||||||
List<String> validators = new ArrayList<String>();
|
List<String> validators = new ArrayList<String>();
|
||||||
validators.add("nonempty");
|
validators.add("nonempty");
|
||||||
if(!isPersonType(vreq)) {
|
if(!isPersonType(vreq)) {
|
||||||
labelField.setValidators(validators);
|
labelField.setValidators(validators);
|
||||||
}
|
}
|
||||||
if(isPersonType(vreq)) {
|
if(isPersonType(vreq)) {
|
||||||
firstNameField.setValidators(validators);
|
firstNameField.setValidators(validators);
|
||||||
lastNameField.setValidators(validators);
|
lastNameField.setValidators(validators);
|
||||||
}
|
}
|
||||||
|
|
||||||
fields.put(labelField.getName(), labelField);
|
fields.put(labelField.getName(), labelField);
|
||||||
fields.put(firstNameField.getName(), firstNameField);
|
fields.put(firstNameField.getName(), firstNameField);
|
||||||
fields.put(middleNameField.getName(), middleNameField);
|
fields.put(middleNameField.getName(), middleNameField);
|
||||||
fields.put(lastNameField.getName(), lastNameField);
|
fields.put(lastNameField.getName(), lastNameField);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log.error("Is not object property so fields not set");
|
log.error("Is not object property so fields not set");
|
||||||
}
|
}
|
||||||
|
|
||||||
editConfiguration.setFields(fields);
|
editConfiguration.setFields(fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,11 +131,11 @@ public class VIVODefaultAddMissingIndividualFormGenerator extends DefaultAddMiss
|
||||||
VClass type = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(typeOfNew);
|
VClass type = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(typeOfNew);
|
||||||
return type.getName();
|
return type.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFOAFPersonClassURI() {
|
public String getFOAFPersonClassURI() {
|
||||||
return "http://xmlns.com/foaf/0.1/Person";
|
return "http://xmlns.com/foaf/0.1/Person";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPersonType(VitroRequest vreq) {
|
public boolean isPersonType(VitroRequest vreq) {
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||||
Boolean isPersonType = Boolean.FALSE;
|
Boolean isPersonType = Boolean.FALSE;
|
||||||
|
@ -150,7 +150,7 @@ public class VIVODefaultAddMissingIndividualFormGenerator extends DefaultAddMiss
|
||||||
isPersonType = Boolean.TRUE;
|
isPersonType = Boolean.TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isPersonType;
|
return isPersonType;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUti
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*This generator selects the actual generator to be employed based on whether the individual is a Person
|
*This generator selects the actual generator to be employed based on whether the individual is a Person
|
||||||
*or another individual. Adding a label for a person relies on first/name last name information i.e. object properties.
|
*or another individual. Adding a label for a person relies on first/name last name information i.e. object properties.
|
||||||
*/
|
*/
|
||||||
public class VIVOManageLabelsGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
public class VIVOManageLabelsGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
||||||
|
@ -30,14 +30,14 @@ public class VIVOManageLabelsGenerator extends BaseEditConfigurationGenerator im
|
||||||
} else {
|
} else {
|
||||||
//Non-Person individuals
|
//Non-Person individuals
|
||||||
e = new ManageLabelsForIndividualGenerator().getEditConfiguration(vreq, session);
|
e = new ManageLabelsForIndividualGenerator().getEditConfiguration(vreq, session);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isPersonType(String subjectUri, VitroRequest vreq) {
|
public boolean isPersonType(String subjectUri, VitroRequest vreq) {
|
||||||
Boolean isPersonType = Boolean.FALSE;
|
Boolean isPersonType = Boolean.FALSE;
|
||||||
String foafPersonType = getFOAFPersonClassURI();
|
String foafPersonType = getFOAFPersonClassURI();
|
||||||
|
@ -49,17 +49,17 @@ public class VIVOManageLabelsGenerator extends BaseEditConfigurationGenerator im
|
||||||
isPersonType = Boolean.TRUE;
|
isPersonType = Boolean.TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isPersonType;
|
return isPersonType;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Copied from NewIndividualFormGenerator
|
//Copied from NewIndividualFormGenerator
|
||||||
//TODO: Refactor so common code can be used by both generators
|
//TODO: Refactor so common code can be used by both generators
|
||||||
public String getFOAFPersonClassURI() {
|
public String getFOAFPersonClassURI() {
|
||||||
return "http://xmlns.com/foaf/0.1/Person";
|
return "http://xmlns.com/foaf/0.1/Person";
|
||||||
}
|
}
|
||||||
|
|
||||||
//how to get the type of the individual in question
|
//how to get the type of the individual in question
|
||||||
public List<VClass> getVClasses(String subjectUri, VitroRequest vreq) {
|
public List<VClass> getVClasses(String subjectUri, VitroRequest vreq) {
|
||||||
Individual subject = EditConfigurationUtils.getIndividual(vreq, subjectUri);
|
Individual subject = EditConfigurationUtils.getIndividual(vreq, subjectUri);
|
||||||
|
|
|
@ -24,22 +24,22 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the edit configuration for a default property form.
|
* Generates the edit configuration for a default property form.
|
||||||
* ModelChangePreprocessor creates the rdfs:label statement.
|
* ModelChangePreprocessor creates the rdfs:label statement.
|
||||||
*/
|
*/
|
||||||
public class VIVONewIndividualFormGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
public class VIVONewIndividualFormGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
|
||||||
|
|
||||||
EditConfigurationVTwo config = new EditConfigurationVTwo();
|
EditConfigurationVTwo config = new EditConfigurationVTwo();
|
||||||
|
|
||||||
config.setTemplate( "newIndividualForm.ftl" );
|
config.setTemplate( "newIndividualForm.ftl" );
|
||||||
|
|
||||||
config.setN3Required( list(
|
config.setN3Required( list(
|
||||||
"?newInd <" + VitroVocabulary.RDF_TYPE + "> <" + getTypeOfNew(vreq) + "> ."
|
"?newInd <" + VitroVocabulary.RDF_TYPE + "> <" + getTypeOfNew(vreq) + "> ."
|
||||||
));
|
));
|
||||||
//Optional because user may have selected either person or individual of another kind
|
//Optional because user may have selected either person or individual of another kind
|
||||||
//Person uses first name and last name whereas individual of other class would use label
|
//Person uses first name and last name whereas individual of other class would use label
|
||||||
//middle name is also optional
|
//middle name is also optional
|
||||||
config.setN3Optional(list(
|
config.setN3Optional(list(
|
||||||
N3_PREFIX + "@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .\n"
|
N3_PREFIX + "@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .\n"
|
||||||
|
@ -58,55 +58,55 @@ public class VIVONewIndividualFormGenerator extends BaseEditConfigurationGenerat
|
||||||
+ " ?newVcardName a vcard:Name . \n"
|
+ " ?newVcardName a vcard:Name . \n"
|
||||||
+ " ?newVcardName <http://vivoweb.org/ontology/core#middleName> ?middleName ."
|
+ " ?newVcardName <http://vivoweb.org/ontology/core#middleName> ?middleName ."
|
||||||
));
|
));
|
||||||
|
|
||||||
config.addNewResource("newInd", vreq.getWebappDaoFactory().getDefaultNamespace());
|
config.addNewResource("newInd", vreq.getWebappDaoFactory().getDefaultNamespace());
|
||||||
config.addNewResource("newVcardInd", vreq.getWebappDaoFactory().getDefaultNamespace());
|
config.addNewResource("newVcardInd", vreq.getWebappDaoFactory().getDefaultNamespace());
|
||||||
config.addNewResource("newVcardName", vreq.getWebappDaoFactory().getDefaultNamespace());
|
config.addNewResource("newVcardName", vreq.getWebappDaoFactory().getDefaultNamespace());
|
||||||
|
|
||||||
config.setUrisOnform(list ());
|
config.setUrisOnform(list ());
|
||||||
config.setLiteralsOnForm( list( "label", "firstName", "lastName", "middleName" ));
|
config.setLiteralsOnForm( list( "label", "firstName", "lastName", "middleName" ));
|
||||||
setUrisAndLiteralsInScope(config);
|
setUrisAndLiteralsInScope(config);
|
||||||
//No SPARQL queries for existing since this is only used to create new, never for edit
|
//No SPARQL queries for existing since this is only used to create new, never for edit
|
||||||
|
|
||||||
config.addField(new FieldVTwo().
|
config.addField(new FieldVTwo().
|
||||||
setName("firstName").
|
setName("firstName").
|
||||||
setRangeDatatypeUri(XSD.xstring.getURI()).
|
setRangeDatatypeUri(XSD.xstring.getURI()).
|
||||||
setValidators(getFirstNameValidators(vreq)));
|
setValidators(getFirstNameValidators(vreq)));
|
||||||
|
|
||||||
config.addField(new FieldVTwo().
|
config.addField(new FieldVTwo().
|
||||||
setName("middleName").
|
setName("middleName").
|
||||||
setRangeDatatypeUri(XSD.xstring.getURI()).
|
setRangeDatatypeUri(XSD.xstring.getURI()).
|
||||||
setValidators(getMiddleNameValidators(vreq)));
|
setValidators(getMiddleNameValidators(vreq)));
|
||||||
|
|
||||||
config.addField(new FieldVTwo().
|
config.addField(new FieldVTwo().
|
||||||
setName("lastName").
|
setName("lastName").
|
||||||
setRangeDatatypeUri(XSD.xstring.getURI()).
|
setRangeDatatypeUri(XSD.xstring.getURI()).
|
||||||
setValidators(getLastNameValidators(vreq)));
|
setValidators(getLastNameValidators(vreq)));
|
||||||
|
|
||||||
config.addField(new FieldVTwo().
|
config.addField(new FieldVTwo().
|
||||||
setName("label").
|
setName("label").
|
||||||
setRangeDatatypeUri(XSD.xstring.getURI()).
|
setRangeDatatypeUri(XSD.xstring.getURI()).
|
||||||
setValidators(getLabelValidators(vreq)));
|
setValidators(getLabelValidators(vreq)));
|
||||||
|
|
||||||
addFormSpecificData(config, vreq);
|
addFormSpecificData(config, vreq);
|
||||||
|
|
||||||
config.addValidator(new AntiXssValidation());
|
config.addValidator(new AntiXssValidation());
|
||||||
|
|
||||||
//This combines the first and last name into the rdfs:label
|
//This combines the first and last name into the rdfs:label
|
||||||
// currently being done via javascript in the template. May use this again
|
// currently being done via javascript in the template. May use this again
|
||||||
// when/if updated to ISF ontology. tlw72
|
// when/if updated to ISF ontology. tlw72
|
||||||
// config.addModelChangePreprocessor(new FoafNameToRdfsLabelPreprocessor());
|
// config.addModelChangePreprocessor(new FoafNameToRdfsLabelPreprocessor());
|
||||||
|
|
||||||
String formUrl = EditConfigurationUtils.getFormUrlWithoutContext(vreq);
|
String formUrl = EditConfigurationUtils.getFormUrlWithoutContext(vreq);
|
||||||
config.setFormUrl(formUrl);
|
config.setFormUrl(formUrl);
|
||||||
|
|
||||||
//Note, the spaces are important - they were added by ProcessRdfFormController earlier
|
//Note, the spaces are important - they were added by ProcessRdfFormController earlier
|
||||||
//as a means of ensuring the substitution worked correctly - as the regex expects spaces
|
//as a means of ensuring the substitution worked correctly - as the regex expects spaces
|
||||||
config.setEntityToReturnTo(" ?newInd ");
|
config.setEntityToReturnTo(" ?newInd ");
|
||||||
prepare(vreq, config);
|
prepare(vreq, config);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getMiddleNameValidators(VitroRequest vreq) {
|
private List<String> getMiddleNameValidators(VitroRequest vreq) {
|
||||||
List<String> validators = new ArrayList<String>();
|
List<String> validators = new ArrayList<String>();
|
||||||
return validators;
|
return validators;
|
||||||
|
@ -144,9 +144,9 @@ public class VIVONewIndividualFormGenerator extends BaseEditConfigurationGenerat
|
||||||
if( typeUri == null || typeUri.trim().isEmpty() )
|
if( typeUri == null || typeUri.trim().isEmpty() )
|
||||||
return getFOAFPersonClassURI();
|
return getFOAFPersonClassURI();
|
||||||
else
|
else
|
||||||
return typeUri;
|
return typeUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Form specific data
|
//Form specific data
|
||||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||||
|
@ -167,11 +167,11 @@ public class VIVONewIndividualFormGenerator extends BaseEditConfigurationGenerat
|
||||||
VClass type = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(typeOfNew);
|
VClass type = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(typeOfNew);
|
||||||
return type.getName();
|
return type.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFOAFPersonClassURI() {
|
public String getFOAFPersonClassURI() {
|
||||||
return "http://xmlns.com/foaf/0.1/Person";
|
return "http://xmlns.com/foaf/0.1/Person";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPersonType(VitroRequest vreq) {
|
public boolean isPersonType(VitroRequest vreq) {
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||||
Boolean isPersonType = Boolean.FALSE;
|
Boolean isPersonType = Boolean.FALSE;
|
||||||
|
@ -186,22 +186,22 @@ public class VIVONewIndividualFormGenerator extends BaseEditConfigurationGenerat
|
||||||
isPersonType = Boolean.TRUE;
|
isPersonType = Boolean.TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isPersonType;
|
return isPersonType;
|
||||||
}
|
}
|
||||||
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration) {
|
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration) {
|
||||||
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
||||||
//note that at this point the subject, predicate, and object var parameters have already been processed
|
//note that at this point the subject, predicate, and object var parameters have already been processed
|
||||||
urisInScope.put(editConfiguration.getVarNameForSubject(),
|
urisInScope.put(editConfiguration.getVarNameForSubject(),
|
||||||
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
|
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
|
||||||
urisInScope.put(editConfiguration.getVarNameForPredicate(),
|
urisInScope.put(editConfiguration.getVarNameForPredicate(),
|
||||||
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
|
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
|
||||||
editConfiguration.setUrisInScope(urisInScope);
|
editConfiguration.setUrisInScope(urisInScope);
|
||||||
//Uris in scope include subject, predicate, and object var
|
//Uris in scope include subject, predicate, and object var
|
||||||
|
|
||||||
editConfiguration.setLiteralsInScope(new HashMap<String, List<Literal>>());
|
editConfiguration.setLiteralsInScope(new HashMap<String, List<Literal>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String N3_PREFIX = "@prefix foaf: <http://xmlns.com/foaf/0.1/> .\n";
|
private String N3_PREFIX = "@prefix foaf: <http://xmlns.com/foaf/0.1/> .\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds static Strings that may be useful for forms that are part of VIVO.
|
* Adds static Strings that may be useful for forms that are part of VIVO.
|
||||||
*
|
*
|
||||||
* @author bdc34
|
* @author bdc34
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -14,18 +14,18 @@ public abstract class VivoBaseGenerator extends BaseEditConfigurationGenerator i
|
||||||
final static String vivoCore ="http://vivoweb.org/ontology/core#" ;
|
final static String vivoCore ="http://vivoweb.org/ontology/core#" ;
|
||||||
final static String rdfs =VitroVocabulary.RDFS ;
|
final static String rdfs =VitroVocabulary.RDFS ;
|
||||||
final static String foaf = "http://xmlns.com/foaf/0.1/";
|
final static String foaf = "http://xmlns.com/foaf/0.1/";
|
||||||
final static String type =VitroVocabulary.RDF_TYPE ;
|
final static String type =VitroVocabulary.RDF_TYPE ;
|
||||||
final static String label =rdfs+"label" ;
|
final static String label =rdfs+"label" ;
|
||||||
final static String bibo = "http://purl.org/ontology/bibo/";
|
final static String bibo = "http://purl.org/ontology/bibo/";
|
||||||
|
|
||||||
final static String edProcessClass = vivoCore+"EducationalProcess" ;
|
final static String edProcessClass = vivoCore+"EducationalProcess" ;
|
||||||
final static String degreeTypeClass =vivoCore+"AcademicDegree" ;
|
final static String degreeTypeClass =vivoCore+"AcademicDegree" ;
|
||||||
final static String majorFieldPred =vivoCore+"majorField" ;
|
final static String majorFieldPred =vivoCore+"majorField" ;
|
||||||
final static String deptPred =vivoCore+"departmentOrSchool" ;
|
final static String deptPred =vivoCore+"departmentOrSchool" ;
|
||||||
final static String infoPred =vivoCore+"supplementalInformation" ;
|
final static String infoPred =vivoCore+"supplementalInformation" ;
|
||||||
final static String authorRankPredicate = vivoCore + "authorRank";
|
final static String authorRankPredicate = vivoCore + "authorRank";
|
||||||
final static String linkedAuthorPredicate = vivoCore + "relates";
|
final static String linkedAuthorPredicate = vivoCore + "relates";
|
||||||
|
|
||||||
final static String dateTimeValue =vivoCore+"dateTime";
|
final static String dateTimeValue =vivoCore+"dateTime";
|
||||||
final static String dateTimeValueType =vivoCore+"DateTimeValue";
|
final static String dateTimeValueType =vivoCore+"DateTimeValue";
|
||||||
final static String dateTimePrecision =vivoCore+"dateTimePrecision";
|
final static String dateTimePrecision =vivoCore+"dateTimePrecision";
|
||||||
|
@ -37,5 +37,5 @@ public abstract class VivoBaseGenerator extends BaseEditConfigurationGenerator i
|
||||||
|
|
||||||
final static String orgClass ="http://xmlns.com/foaf/0.1/Organization" ;
|
final static String orgClass ="http://xmlns.com/foaf/0.1/Organization" ;
|
||||||
final static String personClass = foaf + "Person";
|
final static String personClass = foaf + "Person";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -28,39 +28,39 @@ import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
public class ConceptSemanticTypesPreprocessor implements ModelChangePreprocessor {
|
public class ConceptSemanticTypesPreprocessor implements ModelChangePreprocessor {
|
||||||
|
|
||||||
private static String VIVOCore = "http://vivoweb.org/ontology/core#";
|
private static String VIVOCore = "http://vivoweb.org/ontology/core#";
|
||||||
private static String SKOSConceptType = "http://www.w3.org/2004/02/skos/core#Concept";
|
private static String SKOSConceptType = "http://www.w3.org/2004/02/skos/core#Concept";
|
||||||
private Log log = LogFactory.getLog(ConceptSemanticTypesPreprocessor.class);
|
private Log log = LogFactory.getLog(ConceptSemanticTypesPreprocessor.class);
|
||||||
|
|
||||||
|
|
||||||
//Custom constructor
|
//Custom constructor
|
||||||
public ConceptSemanticTypesPreprocessor() {
|
public ConceptSemanticTypesPreprocessor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preprocess(Model retractionsModel, Model additionsModel,
|
public void preprocess(Model retractionsModel, Model additionsModel,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
VitroRequest vreq = new VitroRequest(request);
|
||||||
//Run a construct query against the additions model
|
//Run a construct query against the additions model
|
||||||
String prefixes = "PREFIX rdfs:<" + RDFS.getURI() + "> " +
|
String prefixes = "PREFIX rdfs:<" + RDFS.getURI() + "> " +
|
||||||
"PREFIX owl:<http://www.w3.org/2002/07/owl#> " +
|
"PREFIX owl:<http://www.w3.org/2002/07/owl#> " +
|
||||||
"PREFIX rdf:<" + RDF.getURI() + ">" +
|
"PREFIX rdf:<" + RDF.getURI() + ">" +
|
||||||
"PREFIX skos:<http://www.w3.org/2004/02/skos/core#>";
|
"PREFIX skos:<http://www.w3.org/2004/02/skos/core#>";
|
||||||
String constructQuery = prefixes + " CONSTRUCT { " +
|
String constructQuery = prefixes + " CONSTRUCT { " +
|
||||||
"?semanticType rdf:type owl:Class. " +
|
"?semanticType rdf:type owl:Class. " +
|
||||||
"?semanticType rdfs:subClassOf skos:Concept . " +
|
"?semanticType rdfs:subClassOf skos:Concept . " +
|
||||||
"?semanticType rdfs:label ?label. " +
|
"?semanticType rdfs:label ?label. " +
|
||||||
"} WHERE { " +
|
"} WHERE { " +
|
||||||
"?concept rdf:type ?semanticType. " +
|
"?concept rdf:type ?semanticType. " +
|
||||||
"?semanticType rdfs:label ?label . " +
|
"?semanticType rdfs:label ?label . " +
|
||||||
"?semanticType rdfs:subClassOf skos:Concept . " +
|
"?semanticType rdfs:subClassOf skos:Concept . " +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
//Execute construct query
|
//Execute construct query
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
Model constructedModel = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
|
|
||||||
log.debug("CONSTRUCT query string " + constructQuery);
|
log.debug("CONSTRUCT query string " + constructQuery);
|
||||||
|
|
||||||
Query query = null;
|
Query query = null;
|
||||||
try {
|
try {
|
||||||
query = QueryFactory.create(constructQuery, Syntax.syntaxARQ);
|
query = QueryFactory.create(constructQuery, Syntax.syntaxARQ);
|
||||||
|
@ -69,13 +69,13 @@ public class ConceptSemanticTypesPreprocessor implements ModelChangePreprocessor
|
||||||
"string. " + th.getMessage());
|
"string. " + th.getMessage());
|
||||||
log.error(constructQuery);
|
log.error(constructQuery);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
additionsModel.getLock().enterCriticalSection(Lock.READ);
|
additionsModel.getLock().enterCriticalSection(Lock.READ);
|
||||||
QueryExecution qe = null;
|
QueryExecution qe = null;
|
||||||
try {
|
try {
|
||||||
qe = QueryExecutionFactory.create(
|
qe = QueryExecutionFactory.create(
|
||||||
query, additionsModel);
|
query, additionsModel);
|
||||||
qe.execConstruct(constructedModel);
|
qe.execConstruct(constructedModel);
|
||||||
|
@ -87,7 +87,7 @@ public class ConceptSemanticTypesPreprocessor implements ModelChangePreprocessor
|
||||||
}
|
}
|
||||||
additionsModel.getLock().leaveCriticalSection();
|
additionsModel.getLock().leaveCriticalSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add constructed model to the designated update model
|
//Add constructed model to the designated update model
|
||||||
OntModel toUpdateModel = ModelAccess.on(vreq).getOntModelSelector().getTBoxModel();
|
OntModel toUpdateModel = ModelAccess.on(vreq).getOntModelSelector().getTBoxModel();
|
||||||
toUpdateModel.enterCriticalSection(Lock.WRITE);
|
toUpdateModel.enterCriticalSection(Lock.WRITE);
|
||||||
|
@ -98,7 +98,7 @@ public class ConceptSemanticTypesPreprocessor implements ModelChangePreprocessor
|
||||||
} finally {
|
} finally {
|
||||||
toUpdateModel.leaveCriticalSection();
|
toUpdateModel.leaveCriticalSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Take this constructed model and remove from the additions model
|
//Take this constructed model and remove from the additions model
|
||||||
additionsModel.enterCriticalSection(Lock.WRITE);
|
additionsModel.enterCriticalSection(Lock.WRITE);
|
||||||
try {
|
try {
|
||||||
|
@ -108,9 +108,9 @@ public class ConceptSemanticTypesPreprocessor implements ModelChangePreprocessor
|
||||||
} finally {
|
} finally {
|
||||||
additionsModel.leaveCriticalSection();
|
additionsModel.leaveCriticalSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,14 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmis
|
||||||
|
|
||||||
public class ManageLabelsForPersonPreprocessor extends ManageLabelsForIndividualPreprocessor {
|
public class ManageLabelsForPersonPreprocessor extends ManageLabelsForIndividualPreprocessor {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ManageLabelsForPersonPreprocessor(EditConfigurationVTwo editConfig) {
|
public ManageLabelsForPersonPreprocessor(EditConfigurationVTwo editConfig) {
|
||||||
super(editConfig);
|
super(editConfig);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preprocess(MultiValueEditSubmission inputSubmission, VitroRequest vreq) {
|
public void preprocess(MultiValueEditSubmission inputSubmission, VitroRequest vreq) {
|
||||||
//Use the ManageLabelsForIndividualPreprocessor in addition to this code specific for person
|
//Use the ManageLabelsForIndividualPreprocessor in addition to this code specific for person
|
||||||
|
@ -42,27 +42,27 @@ public class ManageLabelsForPersonPreprocessor extends ManageLabelsForIndividual
|
||||||
if(inputSubmission.hasLiteralValue("middleName")) {
|
if(inputSubmission.hasLiteralValue("middleName")) {
|
||||||
middleNames = literalsFromForm.get("middleName");
|
middleNames = literalsFromForm.get("middleName");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Expecting only one language
|
//Expecting only one language
|
||||||
if(firstNames.size() > 0 && lastNames.size() > 0 && newLabelLanguages.size() > 0) {
|
if(firstNames.size() > 0 && lastNames.size() > 0 && newLabelLanguages.size() > 0) {
|
||||||
Literal newLabelLanguage = newLabelLanguages.get(0);
|
Literal newLabelLanguage = newLabelLanguages.get(0);
|
||||||
Literal firstNameLiteral = firstNames.get(0);
|
Literal firstNameLiteral = firstNames.get(0);
|
||||||
Literal lastNameLiteral = lastNames.get(0);
|
Literal lastNameLiteral = lastNames.get(0);
|
||||||
|
|
||||||
//Get the string
|
//Get the string
|
||||||
String lang = this.getLanguage(newLabelLanguage.getString());
|
String lang = this.getLanguage(newLabelLanguage.getString());
|
||||||
String firstNameValue = firstNameLiteral.getString();
|
String firstNameValue = firstNameLiteral.getString();
|
||||||
String lastNameValue = lastNameLiteral.getString();
|
String lastNameValue = lastNameLiteral.getString();
|
||||||
|
|
||||||
//Now add the language category to the literal
|
//Now add the language category to the literal
|
||||||
Literal firstNameWithLanguage = inputSubmission.createLiteral(firstNameValue,
|
Literal firstNameWithLanguage = inputSubmission.createLiteral(firstNameValue,
|
||||||
null,
|
null,
|
||||||
lang);
|
lang);
|
||||||
Literal lastNameWithLanguage = inputSubmission.createLiteral(lastNameValue,
|
Literal lastNameWithLanguage = inputSubmission.createLiteral(lastNameValue,
|
||||||
null,
|
null,
|
||||||
lang);
|
lang);
|
||||||
|
|
||||||
firstNames = new ArrayList<Literal>();
|
firstNames = new ArrayList<Literal>();
|
||||||
lastNames = new ArrayList<Literal>();
|
lastNames = new ArrayList<Literal>();
|
||||||
firstNames.add(firstNameWithLanguage);
|
firstNames.add(firstNameWithLanguage);
|
||||||
|
@ -70,25 +70,25 @@ public class ManageLabelsForPersonPreprocessor extends ManageLabelsForIndividual
|
||||||
//replace the label with one with language, again assuming only one label being returned
|
//replace the label with one with language, again assuming only one label being returned
|
||||||
literalsFromForm.put("firstName", firstNames);
|
literalsFromForm.put("firstName", firstNames);
|
||||||
literalsFromForm.put("lastName", lastNames);
|
literalsFromForm.put("lastName", lastNames);
|
||||||
|
|
||||||
//Middle name handling
|
//Middle name handling
|
||||||
if(middleNames.size() > 0) {
|
if(middleNames.size() > 0) {
|
||||||
Literal middleNameLiteral = middleNames.get(0);
|
Literal middleNameLiteral = middleNames.get(0);
|
||||||
String middleNameValue = middleNameLiteral.getString();
|
String middleNameValue = middleNameLiteral.getString();
|
||||||
Literal middleNameWithLanguage = inputSubmission.createLiteral(middleNameValue,
|
Literal middleNameWithLanguage = inputSubmission.createLiteral(middleNameValue,
|
||||||
null,
|
null,
|
||||||
lang);
|
lang);
|
||||||
middleNames = new ArrayList<Literal>();
|
middleNames = new ArrayList<Literal>();
|
||||||
middleNames.add(middleNameWithLanguage);
|
middleNames.add(middleNameWithLanguage);
|
||||||
literalsFromForm.put("middleName", middleNames);
|
literalsFromForm.put("middleName", middleNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set literals
|
//Set literals
|
||||||
inputSubmission.setLiteralsFromForm(literalsFromForm);
|
inputSubmission.setLiteralsFromForm(literalsFromForm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +1,34 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
|
||||||
|
|
||||||
public class RoleToActivityPredicatePreprocessor extends RoleToPredicatePreprocessor {
|
public class RoleToActivityPredicatePreprocessor extends RoleToPredicatePreprocessor {
|
||||||
public RoleToActivityPredicatePreprocessor(EditConfigurationVTwo editConfig, WebappDaoFactory wadf) {
|
public RoleToActivityPredicatePreprocessor(EditConfigurationVTwo editConfig, WebappDaoFactory wadf) {
|
||||||
super(editConfig, wadf);
|
super(editConfig, wadf);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupVariableNames() {
|
protected void setupVariableNames() {
|
||||||
this.itemType = "roleActivityType";
|
this.itemType = "roleActivityType";
|
||||||
this.roleToItemPredicate = "roleToActivityPredicate";
|
this.roleToItemPredicate = "roleToActivityPredicate";
|
||||||
this.itemToRolePredicate = "activityToRolePredicate";
|
this.itemToRolePredicate = "activityToRolePredicate";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getItemType(MultiValueEditSubmission submission) {
|
protected String getItemType(MultiValueEditSubmission submission) {
|
||||||
String type = null;
|
String type = null;
|
||||||
Map<String, List<String>> urisFromForm = submission.getUrisFromForm();
|
Map<String, List<String>> urisFromForm = submission.getUrisFromForm();
|
||||||
//Get the type of the activity selected
|
//Get the type of the activity selected
|
||||||
List<String> itemTypes = urisFromForm.get(itemType);
|
List<String> itemTypes = urisFromForm.get(itemType);
|
||||||
//Really should just be one here
|
//Really should just be one here
|
||||||
if(itemTypes != null && itemTypes.size() > 0) {
|
if(itemTypes != null && itemTypes.size() > 0) {
|
||||||
type = itemTypes.get(0);
|
type = itemTypes.get(0);
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,83 +1,83 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
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 edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.BaseEditSubmissionPreprocessorVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.BaseEditSubmissionPreprocessorVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
|
||||||
|
|
||||||
import org.vivoweb.webapp.util.ModelUtils;
|
import org.vivoweb.webapp.util.ModelUtils;
|
||||||
|
|
||||||
public abstract class RoleToPredicatePreprocessor extends BaseEditSubmissionPreprocessorVTwo {
|
public abstract class RoleToPredicatePreprocessor extends BaseEditSubmissionPreprocessorVTwo {
|
||||||
|
|
||||||
protected static final Log log = LogFactory.getLog(RoleToPredicatePreprocessor.class.getName());
|
protected static final Log log = LogFactory.getLog(RoleToPredicatePreprocessor.class.getName());
|
||||||
protected WebappDaoFactory wadf = null;
|
protected WebappDaoFactory wadf = null;
|
||||||
protected static String itemType;
|
protected static String itemType;
|
||||||
protected static String roleToItemPredicate;
|
protected static String roleToItemPredicate;
|
||||||
protected static String itemToRolePredicate;
|
protected static String itemToRolePredicate;
|
||||||
//Need the webapp dao factory to try to figure out what the predicate should be
|
//Need the webapp dao factory to try to figure out what the predicate should be
|
||||||
public RoleToPredicatePreprocessor(EditConfigurationVTwo editConfig, WebappDaoFactory wadf) {
|
public RoleToPredicatePreprocessor(EditConfigurationVTwo editConfig, WebappDaoFactory wadf) {
|
||||||
super(editConfig);
|
super(editConfig);
|
||||||
this.wadf = wadf;
|
this.wadf = wadf;
|
||||||
setupVariableNames();
|
setupVariableNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Instantiate itemType etc. based on which version of preprocessor required
|
//Instantiate itemType etc. based on which version of preprocessor required
|
||||||
abstract protected void setupVariableNames();
|
abstract protected void setupVariableNames();
|
||||||
|
|
||||||
public void preprocess(MultiValueEditSubmission submission, VitroRequest vreq) {
|
public void preprocess(MultiValueEditSubmission submission, VitroRequest vreq) {
|
||||||
//Query for all statements using the original roleIn predicate replace
|
//Query for all statements using the original roleIn predicate replace
|
||||||
//with the appropriate roleRealizedIn or roleContributesTo
|
//with the appropriate roleRealizedIn or roleContributesTo
|
||||||
//In addition, need to ensure the inverse predicate is also set correctly
|
//In addition, need to ensure the inverse predicate is also set correctly
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//Get the uris from form
|
//Get the uris from form
|
||||||
String type = getItemType(submission);
|
String type = getItemType(submission);
|
||||||
Map<String, List<String>> urisFromForm = submission.getUrisFromForm();
|
Map<String, List<String>> urisFromForm = submission.getUrisFromForm();
|
||||||
if(type != null) {
|
if(type != null) {
|
||||||
ObjectProperty roleToItemProperty = getCorrectProperty(type, wadf);
|
ObjectProperty roleToItemProperty = getCorrectProperty(type, wadf);
|
||||||
String roleToItemPredicateURI = roleToItemProperty.getURI();
|
String roleToItemPredicateURI = roleToItemProperty.getURI();
|
||||||
String itemToRolePredicateURI = roleToItemProperty.getURIInverse();
|
String itemToRolePredicateURI = roleToItemProperty.getURIInverse();
|
||||||
List<String> predicates = new ArrayList<String>();
|
List<String> predicates = new ArrayList<String>();
|
||||||
predicates.add(roleToItemPredicateURI);
|
predicates.add(roleToItemPredicateURI);
|
||||||
|
|
||||||
List<String> inversePredicates = new ArrayList<String>();
|
List<String> inversePredicates = new ArrayList<String>();
|
||||||
inversePredicates.add(itemToRolePredicateURI);
|
inversePredicates.add(itemToRolePredicateURI);
|
||||||
//Populate the two fields in edit submission
|
//Populate the two fields in edit submission
|
||||||
if(urisFromForm.containsKey(roleToItemPredicate)) {
|
if(urisFromForm.containsKey(roleToItemPredicate)) {
|
||||||
urisFromForm.remove(roleToItemPredicate);
|
urisFromForm.remove(roleToItemPredicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
urisFromForm.put(roleToItemPredicate, predicates);
|
urisFromForm.put(roleToItemPredicate, predicates);
|
||||||
|
|
||||||
if(urisFromForm.containsKey(itemToRolePredicate)) {
|
if(urisFromForm.containsKey(itemToRolePredicate)) {
|
||||||
urisFromForm.remove(itemToRolePredicate);
|
urisFromForm.remove(itemToRolePredicate);
|
||||||
}
|
}
|
||||||
urisFromForm.put(itemToRolePredicate, inversePredicates);
|
urisFromForm.put(itemToRolePredicate, inversePredicates);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error retrieving name values from edit submission.");
|
log.error("Error retrieving name values from edit submission.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected String getItemType(MultiValueEditSubmission submission);
|
abstract protected String getItemType(MultiValueEditSubmission submission);
|
||||||
|
|
||||||
private ObjectProperty getCorrectProperty(String uri, WebappDaoFactory wadf) {
|
private ObjectProperty getCorrectProperty(String uri, WebappDaoFactory wadf) {
|
||||||
ObjectProperty correctProperty = ModelUtils.getPropertyForRoleInClass(uri, wadf);
|
ObjectProperty correctProperty = ModelUtils.getPropertyForRoleInClass(uri, wadf);
|
||||||
return correctProperty;
|
return correctProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,225 +1,225 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
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.ontology.OntModel;
|
import org.apache.jena.ontology.OntModel;
|
||||||
import org.apache.jena.query.Query;
|
import org.apache.jena.query.Query;
|
||||||
import org.apache.jena.query.QueryExecution;
|
import org.apache.jena.query.QueryExecution;
|
||||||
import org.apache.jena.query.QueryExecutionFactory;
|
import org.apache.jena.query.QueryExecutionFactory;
|
||||||
import org.apache.jena.query.QueryFactory;
|
import org.apache.jena.query.QueryFactory;
|
||||||
import org.apache.jena.query.QuerySolution;
|
import org.apache.jena.query.QuerySolution;
|
||||||
import org.apache.jena.query.ResultSet;
|
import org.apache.jena.query.ResultSet;
|
||||||
import org.apache.jena.rdf.model.Literal;
|
import org.apache.jena.rdf.model.Literal;
|
||||||
import org.apache.jena.rdf.model.Resource;
|
import org.apache.jena.rdf.model.Resource;
|
||||||
import org.apache.jena.rdf.model.ResourceFactory;
|
import org.apache.jena.rdf.model.ResourceFactory;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||||
|
|
||||||
//Returns the appropriate n3 for selection of classes from within class group
|
//Returns the appropriate n3 for selection of classes from within class group
|
||||||
public class ProcessInternalClassDataGetterN3 extends ProcessIndividualsForClassesDataGetterN3 {
|
public class ProcessInternalClassDataGetterN3 extends ProcessIndividualsForClassesDataGetterN3 {
|
||||||
private static String classType = "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.InternalClassesDataGetter";
|
private static String classType = "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.InternalClassesDataGetter";
|
||||||
|
|
||||||
private static String internalClassVarNameBase = "isInternal";
|
private static String internalClassVarNameBase = "isInternal";
|
||||||
private Log log = LogFactory.getLog(ProcessInternalClassDataGetterN3.class);
|
private Log log = LogFactory.getLog(ProcessInternalClassDataGetterN3.class);
|
||||||
|
|
||||||
public ProcessInternalClassDataGetterN3(){
|
public ProcessInternalClassDataGetterN3(){
|
||||||
super();
|
super();
|
||||||
|
|
||||||
}
|
}
|
||||||
//Pass in variable that represents the counter
|
//Pass in variable that represents the counter
|
||||||
//Saving both type and class group here
|
//Saving both type and class group here
|
||||||
//That can be included here if need be, but for now just adding the type alone
|
//That can be included here if need be, but for now just adding the type alone
|
||||||
public List<String> retrieveN3Required(int counter) {
|
public List<String> retrieveN3Required(int counter) {
|
||||||
return super.retrieveN3Required(counter);
|
return super.retrieveN3Required(counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//returns n3 defining internal class
|
//returns n3 defining internal class
|
||||||
private List<String> addInternalClassN3(int counter) {
|
private List<String> addInternalClassN3(int counter) {
|
||||||
List<String> internalClassN3 = new ArrayList<String>();
|
List<String> internalClassN3 = new ArrayList<String>();
|
||||||
String dataGetterVar = getDataGetterVar(counter);
|
String dataGetterVar = getDataGetterVar(counter);
|
||||||
internalClassN3.add(dataGetterVar + " <" + DisplayVocabulary.RESTRICT_RESULTS_BY_INTERNAL + "> " +
|
internalClassN3.add(dataGetterVar + " <" + DisplayVocabulary.RESTRICT_RESULTS_BY_INTERNAL + "> " +
|
||||||
this.getN3VarName(internalClassVarNameBase, counter) + " .");
|
this.getN3VarName(internalClassVarNameBase, counter) + " .");
|
||||||
return internalClassN3;
|
return internalClassN3;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> retrieveN3Optional(int counter) {
|
public List<String> retrieveN3Optional(int counter) {
|
||||||
List<String> optionalN3 = new ArrayList<String>();
|
List<String> optionalN3 = new ArrayList<String>();
|
||||||
//If internal add that as well
|
//If internal add that as well
|
||||||
optionalN3.addAll(this.addInternalClassN3(counter));
|
optionalN3.addAll(this.addInternalClassN3(counter));
|
||||||
return optionalN3;
|
return optionalN3;
|
||||||
}
|
}
|
||||||
|
|
||||||
//These methods will return the literals and uris expected within the n3
|
//These methods will return the literals and uris expected within the n3
|
||||||
//and the counter is used to ensure they are numbered correctly
|
//and the counter is used to ensure they are numbered correctly
|
||||||
|
|
||||||
public List<String> retrieveLiteralsOnForm(int counter) {
|
public List<String> retrieveLiteralsOnForm(int counter) {
|
||||||
//no literals, just the class group URI
|
//no literals, just the class group URI
|
||||||
List<String> literalsOnForm = new ArrayList<String>();
|
List<String> literalsOnForm = new ArrayList<String>();
|
||||||
literalsOnForm.add(getVarName(internalClassVarNameBase, counter));
|
literalsOnForm.add(getVarName(internalClassVarNameBase, counter));
|
||||||
return literalsOnForm;
|
return literalsOnForm;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//URIs on form are same as individuals for class group so no need to reimplement
|
//URIs on form are same as individuals for class group so no need to reimplement
|
||||||
//i.e. class groups and individuals selected within class group
|
//i.e. class groups and individuals selected within class group
|
||||||
|
|
||||||
public List<FieldVTwo> retrieveFields(int counter) {
|
public List<FieldVTwo> retrieveFields(int counter) {
|
||||||
List<FieldVTwo> fields = super.retrieveFields(counter);
|
List<FieldVTwo> fields = super.retrieveFields(counter);
|
||||||
fields.add(new FieldVTwo().setName(getVarName(internalClassVarNameBase, counter)));
|
fields.add(new FieldVTwo().setName(getVarName(internalClassVarNameBase, counter)));
|
||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
//These var names match the names of the elements within the json object returned with the info required for the data getter
|
//These var names match the names of the elements within the json object returned with the info required for the data getter
|
||||||
|
|
||||||
public List<String> getLiteralVarNamesBase() {
|
public List<String> getLiteralVarNamesBase() {
|
||||||
return Arrays.asList(internalClassVarNameBase);
|
return Arrays.asList(internalClassVarNameBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
//get URI Var Names base is same as ProcessIndividualsForClassGroup: classGroup and individualClassVarNameBase
|
//get URI Var Names base is same as ProcessIndividualsForClassGroup: classGroup and individualClassVarNameBase
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getClassType() {
|
public String getClassType() {
|
||||||
return classType;
|
return classType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populateExistingValues(String dataGetterURI, int counter, OntModel queryModel) {
|
public void populateExistingValues(String dataGetterURI, int counter, OntModel queryModel) {
|
||||||
//First, put dataGetterURI within scope as well
|
//First, put dataGetterURI within scope as well
|
||||||
//((ProcessDataGetterAbstract)this).populateExistingDataGetterURI(dataGetterURI, counter);
|
//((ProcessDataGetterAbstract)this).populateExistingDataGetterURI(dataGetterURI, counter);
|
||||||
this.populateExistingDataGetterURI(dataGetterURI, counter);
|
this.populateExistingDataGetterURI(dataGetterURI, counter);
|
||||||
//Put in type
|
//Put in type
|
||||||
this.populateExistingClassType(this.getClassType(), counter);
|
this.populateExistingClassType(this.getClassType(), counter);
|
||||||
//Sparql queries for values to be executed
|
//Sparql queries for values to be executed
|
||||||
//And then placed in the correct place/literal or uri
|
//And then placed in the correct place/literal or uri
|
||||||
String querystr = getExistingValuesInternalClass(dataGetterURI);
|
String querystr = getExistingValuesInternalClass(dataGetterURI);
|
||||||
QueryExecution qe = null;
|
QueryExecution qe = null;
|
||||||
Literal internalClassLiteral = null;
|
Literal internalClassLiteral = null;
|
||||||
try{
|
try{
|
||||||
Query query = QueryFactory.create(querystr);
|
Query query = QueryFactory.create(querystr);
|
||||||
qe = QueryExecutionFactory.create(query, queryModel);
|
qe = QueryExecutionFactory.create(query, queryModel);
|
||||||
ResultSet results = qe.execSelect();
|
ResultSet results = qe.execSelect();
|
||||||
String classGroupURI = null;
|
String classGroupURI = null;
|
||||||
List<String> individualsForClasses = new ArrayList<String>();
|
List<String> individualsForClasses = new ArrayList<String>();
|
||||||
while( results.hasNext()){
|
while( results.hasNext()){
|
||||||
QuerySolution qs = results.nextSolution();
|
QuerySolution qs = results.nextSolution();
|
||||||
//Class group
|
//Class group
|
||||||
Resource classGroupResource = qs.getResource("classGroup");
|
Resource classGroupResource = qs.getResource("classGroup");
|
||||||
String classGroupVarName = this.getVarName(classGroupVarBase, counter);
|
String classGroupVarName = this.getVarName(classGroupVarBase, counter);
|
||||||
if(classGroupURI == null) {
|
if(classGroupURI == null) {
|
||||||
//Put both literals in existing literals
|
//Put both literals in existing literals
|
||||||
existingUriValues.put(this.getVarName(classGroupVarBase, counter),
|
existingUriValues.put(this.getVarName(classGroupVarBase, counter),
|
||||||
new ArrayList<String>(Arrays.asList(classGroupResource.getURI())));
|
new ArrayList<String>(Arrays.asList(classGroupResource.getURI())));
|
||||||
}
|
}
|
||||||
//Individuals For classes
|
//Individuals For classes
|
||||||
Resource individualForClassResource = qs.getResource("individualForClass");
|
Resource individualForClassResource = qs.getResource("individualForClass");
|
||||||
individualsForClasses.add(individualForClassResource.getURI());
|
individualsForClasses.add(individualForClassResource.getURI());
|
||||||
//If internal class value is present and we have not already saved it in a previous result iteration
|
//If internal class value is present and we have not already saved it in a previous result iteration
|
||||||
if(qs.get("internalClass") != null && internalClassLiteral == null) {
|
if(qs.get("internalClass") != null && internalClassLiteral == null) {
|
||||||
|
|
||||||
internalClassLiteral= qs.getLiteral("internalClass");
|
internalClassLiteral= qs.getLiteral("internalClass");
|
||||||
existingLiteralValues.put(this.getVarName(internalClassVarNameBase, counter),
|
existingLiteralValues.put(this.getVarName(internalClassVarNameBase, counter),
|
||||||
new ArrayList<Literal>(Arrays.asList(internalClassLiteral)));
|
new ArrayList<Literal>(Arrays.asList(internalClassLiteral)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Put array of individuals for classes within
|
//Put array of individuals for classes within
|
||||||
existingUriValues.put(this.getVarName(individualClassVarNameBase, counter),
|
existingUriValues.put(this.getVarName(individualClassVarNameBase, counter),
|
||||||
new ArrayList<String>(individualsForClasses));
|
new ArrayList<String>(individualsForClasses));
|
||||||
//Final check, in case no internal class flag was returned, set to false
|
//Final check, in case no internal class flag was returned, set to false
|
||||||
if(internalClassLiteral == null) {
|
if(internalClassLiteral == null) {
|
||||||
existingLiteralValues.put(this.getVarName(internalClassVarNameBase, counter),
|
existingLiteralValues.put(this.getVarName(internalClassVarNameBase, counter),
|
||||||
new ArrayList<Literal>(
|
new ArrayList<Literal>(
|
||||||
Arrays.asList(ResourceFactory.createPlainLiteral("false"))
|
Arrays.asList(ResourceFactory.createPlainLiteral("false"))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
|
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//?dataGetter a FixedHTMLDataGetter ; display:saveToVar ?saveToVar; display:htmlValue ?htmlValue .
|
//?dataGetter a FixedHTMLDataGetter ; display:saveToVar ?saveToVar; display:htmlValue ?htmlValue .
|
||||||
protected String getExistingValuesInternalClass(String dataGetterURI) {
|
protected String getExistingValuesInternalClass(String dataGetterURI) {
|
||||||
String query = this.getSparqlPrefix() + " SELECT ?classGroup ?individualForClass ?internalClass WHERE {" +
|
String query = this.getSparqlPrefix() + " SELECT ?classGroup ?individualForClass ?internalClass WHERE {" +
|
||||||
"<" + dataGetterURI + "> <" + DisplayVocabulary.FOR_CLASSGROUP + "> ?classGroup . \n" +
|
"<" + dataGetterURI + "> <" + DisplayVocabulary.FOR_CLASSGROUP + "> ?classGroup . \n" +
|
||||||
"OPTIONAL {<" + dataGetterURI + "> <" + DisplayVocabulary.GETINDIVIDUALS_FOR_CLASS + "> ?individualForClass . }\n" +
|
"OPTIONAL {<" + dataGetterURI + "> <" + DisplayVocabulary.GETINDIVIDUALS_FOR_CLASS + "> ?individualForClass . }\n" +
|
||||||
"OPTIONAL {<" + dataGetterURI + "> <" + DisplayVocabulary.RESTRICT_RESULTS_BY_INTERNAL + "> ?internalClass .} \n" +
|
"OPTIONAL {<" + dataGetterURI + "> <" + DisplayVocabulary.RESTRICT_RESULTS_BY_INTERNAL + "> ?internalClass .} \n" +
|
||||||
"}";
|
"}";
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ObjectNode getExistingValuesJSON(String dataGetterURI, OntModel queryModel, ServletContext context) {
|
public ObjectNode getExistingValuesJSON(String dataGetterURI, OntModel queryModel, ServletContext context) {
|
||||||
ObjectNode jObject = new ObjectMapper().createObjectNode();
|
ObjectNode jObject = new ObjectMapper().createObjectNode();
|
||||||
jObject.put("dataGetterClass", classType);
|
jObject.put("dataGetterClass", classType);
|
||||||
//Update to include class type as variable
|
//Update to include class type as variable
|
||||||
jObject.put(classTypeVarBase, classType);
|
jObject.put(classTypeVarBase, classType);
|
||||||
//Get selected class group, if internal class, and classes selected from class group
|
//Get selected class group, if internal class, and classes selected from class group
|
||||||
getExistingClassGroupAndInternalClass(dataGetterURI, jObject, queryModel);
|
getExistingClassGroupAndInternalClass(dataGetterURI, jObject, queryModel);
|
||||||
//Get all classes in the class group
|
//Get all classes in the class group
|
||||||
((ProcessClassGroupDataGetterN3) this).getExistingClassesInClassGroup(context, dataGetterURI, jObject);
|
((ProcessClassGroupDataGetterN3) this).getExistingClassesInClassGroup(context, dataGetterURI, jObject);
|
||||||
return jObject;
|
return jObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getExistingClassGroupAndInternalClass(String dataGetterURI, ObjectNode jObject, OntModel queryModel) {
|
private void getExistingClassGroupAndInternalClass(String dataGetterURI, ObjectNode jObject, OntModel queryModel) {
|
||||||
String querystr = getExistingValuesInternalClass(dataGetterURI);
|
String querystr = getExistingValuesInternalClass(dataGetterURI);
|
||||||
QueryExecution qe = null;
|
QueryExecution qe = null;
|
||||||
Literal internalClassLiteral = null;
|
Literal internalClassLiteral = null;
|
||||||
try{
|
try{
|
||||||
Query query = QueryFactory.create(querystr);
|
Query query = QueryFactory.create(querystr);
|
||||||
qe = QueryExecutionFactory.create(query, queryModel);
|
qe = QueryExecutionFactory.create(query, queryModel);
|
||||||
ResultSet results = qe.execSelect();
|
ResultSet results = qe.execSelect();
|
||||||
ArrayNode individualsForClasses = new ObjectMapper().createArrayNode();
|
ArrayNode individualsForClasses = new ObjectMapper().createArrayNode();
|
||||||
String classGroupURI = null;
|
String classGroupURI = null;
|
||||||
while( results.hasNext()){
|
while( results.hasNext()){
|
||||||
QuerySolution qs = results.nextSolution();
|
QuerySolution qs = results.nextSolution();
|
||||||
if(classGroupURI == null) {
|
if(classGroupURI == null) {
|
||||||
Resource classGroupResource = qs.getResource("classGroup");
|
Resource classGroupResource = qs.getResource("classGroup");
|
||||||
classGroupURI = classGroupResource.getURI();
|
classGroupURI = classGroupResource.getURI();
|
||||||
}
|
}
|
||||||
//individuals for classes - this may also be optional in case entire class group selected and internal class
|
//individuals for classes - this may also be optional in case entire class group selected and internal class
|
||||||
if(qs.get("individualForClass") != null ) {
|
if(qs.get("individualForClass") != null ) {
|
||||||
Resource individualForClassResource = qs.getResource("individualForClass");
|
Resource individualForClassResource = qs.getResource("individualForClass");
|
||||||
individualsForClasses.add(individualForClassResource.getURI());
|
individualsForClasses.add(individualForClassResource.getURI());
|
||||||
}
|
}
|
||||||
//Put both literals in existing literals
|
//Put both literals in existing literals
|
||||||
//If internal class value is present and we have not already saved it in a previous result iteration
|
//If internal class value is present and we have not already saved it in a previous result iteration
|
||||||
if(qs.get("internalClass") != null && internalClassLiteral == null) {
|
if(qs.get("internalClass") != null && internalClassLiteral == null) {
|
||||||
internalClassLiteral= qs.getLiteral("internalClass");
|
internalClassLiteral= qs.getLiteral("internalClass");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
jObject.put("classGroup", classGroupURI);
|
jObject.put("classGroup", classGroupURI);
|
||||||
//this is a json array
|
//this is a json array
|
||||||
jObject.set(individualClassVarNameBase, individualsForClasses);
|
jObject.set(individualClassVarNameBase, individualsForClasses);
|
||||||
//Internal class - if null then add false otherwise use the value
|
//Internal class - if null then add false otherwise use the value
|
||||||
if(internalClassLiteral != null) {
|
if(internalClassLiteral != null) {
|
||||||
jObject.put(internalClassVarNameBase, internalClassLiteral.getString());
|
jObject.put(internalClassVarNameBase, internalClassLiteral.getString());
|
||||||
} else {
|
} else {
|
||||||
jObject.put(internalClassVarNameBase, "false");
|
jObject.put(internalClassVarNameBase, "false");
|
||||||
}
|
}
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
|
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class CalculateParameters implements DocumentModifier, ContextModelsUser
|
||||||
private boolean shutdown = false;
|
private boolean shutdown = false;
|
||||||
private volatile Dataset dataset;
|
private volatile Dataset dataset;
|
||||||
// public static int totalInd=1;
|
// public static int totalInd=1;
|
||||||
|
|
||||||
private static final String prefix = "prefix owl: <http://www.w3.org/2002/07/owl#> "
|
private static final String prefix = "prefix owl: <http://www.w3.org/2002/07/owl#> "
|
||||||
+ " prefix vitroDisplay: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> "
|
+ " prefix vitroDisplay: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> "
|
||||||
+ " prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
|
+ " prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
|
||||||
|
@ -48,20 +48,20 @@ public class CalculateParameters implements DocumentModifier, ContextModelsUser
|
||||||
+ " prefix localNav: <http://vitro.mannlib.cornell.edu/ns/localnav#> "
|
+ " prefix localNav: <http://vitro.mannlib.cornell.edu/ns/localnav#> "
|
||||||
+ " prefix obo: <http://purl.obolibrary.org/obo/> "
|
+ " prefix obo: <http://purl.obolibrary.org/obo/> "
|
||||||
+ " prefix bibo: <http://purl.org/ontology/bibo/> ";
|
+ " prefix bibo: <http://purl.org/ontology/bibo/> ";
|
||||||
|
|
||||||
private static final String betaQuery = prefix + " SELECT count(distinct ?inLinks) " +
|
private static final String betaQuery = prefix + " SELECT count(distinct ?inLinks) " +
|
||||||
" WHERE { " +
|
" WHERE { " +
|
||||||
" ?uri rdf:type owl:Thing . " +
|
" ?uri rdf:type owl:Thing . " +
|
||||||
" ?inLinks ?prop ?uri . " +
|
" ?inLinks ?prop ?uri . " +
|
||||||
" } ";
|
" } ";
|
||||||
|
|
||||||
private static final String totalCountQuery = prefix + " SELECT count(distinct ?ind) " +
|
private static final String totalCountQuery = prefix + " SELECT count(distinct ?ind) " +
|
||||||
" WHERE { " +
|
" WHERE { " +
|
||||||
" ?ind rdf:type owl:Thing . " +
|
" ?ind rdf:type owl:Thing . " +
|
||||||
" } ";
|
" } ";
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(CalculateParameters.class);
|
private static Log log = LogFactory.getLog(CalculateParameters.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setContextModels(ContextModelAccess models) {
|
public void setContextModels(ContextModelAccess models) {
|
||||||
this.dataset = DatasetFactory.create(models.getOntModel());
|
this.dataset = DatasetFactory.create(models.getOntModel());
|
||||||
|
@ -69,13 +69,13 @@ public class CalculateParameters implements DocumentModifier, ContextModelsUser
|
||||||
|
|
||||||
public float calculateBeta(String uri){
|
public float calculateBeta(String uri){
|
||||||
float beta=0;
|
float beta=0;
|
||||||
int Conn=0;
|
int Conn=0;
|
||||||
Query query;
|
Query query;
|
||||||
QuerySolutionMap initialBinding = new QuerySolutionMap();
|
QuerySolutionMap initialBinding = new QuerySolutionMap();
|
||||||
QuerySolution soln = null;
|
QuerySolution soln = null;
|
||||||
Resource uriResource = ResourceFactory.createResource(uri);
|
Resource uriResource = ResourceFactory.createResource(uri);
|
||||||
initialBinding.add("uri", uriResource);
|
initialBinding.add("uri", uriResource);
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
QueryExecution qexec=null;
|
QueryExecution qexec=null;
|
||||||
try{
|
try{
|
||||||
query = QueryFactory.create(betaQuery,Syntax.syntaxARQ);
|
query = QueryFactory.create(betaQuery,Syntax.syntaxARQ);
|
||||||
|
@ -90,29 +90,29 @@ public class CalculateParameters implements DocumentModifier, ContextModelsUser
|
||||||
if( ! shutdown )
|
if( ! shutdown )
|
||||||
log.error(t,t);
|
log.error(t,t);
|
||||||
}finally{
|
}finally{
|
||||||
if( qexec != null )
|
if( qexec != null )
|
||||||
qexec.close();
|
qexec.close();
|
||||||
dataset.getLock().leaveCriticalSection();
|
dataset.getLock().leaveCriticalSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
beta = (float)Conn;
|
beta = (float)Conn;
|
||||||
//beta *= 100;
|
//beta *= 100;
|
||||||
beta += 1;
|
beta += 1;
|
||||||
|
|
||||||
// sigmoid function to keep beta between 0 to 1;
|
// sigmoid function to keep beta between 0 to 1;
|
||||||
|
|
||||||
beta = (float) (1 / ( 1 + Math.pow(Math.E,(-beta))));
|
beta = (float) (1 / ( 1 + Math.pow(Math.E,(-beta))));
|
||||||
|
|
||||||
if(beta > 1)
|
if(beta > 1)
|
||||||
log.info("Beta higher than 1 : " + beta);
|
log.info("Beta higher than 1 : " + beta);
|
||||||
else if(beta <= 0)
|
else if(beta <= 0)
|
||||||
log.info("Beta lower < = 0 : " + beta);
|
log.info("Beta lower < = 0 : " + beta);
|
||||||
return beta;
|
return beta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String[] getAdjacentNodes(String uri){
|
public String[] getAdjacentNodes(String uri){
|
||||||
|
|
||||||
List<String> queryList = new ArrayList<String>();
|
List<String> queryList = new ArrayList<String>();
|
||||||
Set<String> adjacentNodes = new HashSet<String>();
|
Set<String> adjacentNodes = new HashSet<String>();
|
||||||
Set<String> coauthorNames = new HashSet<String>();
|
Set<String> coauthorNames = new HashSet<String>();
|
||||||
|
@ -121,8 +121,8 @@ public class CalculateParameters implements DocumentModifier, ContextModelsUser
|
||||||
StringBuffer coauthorBuff = new StringBuffer();
|
StringBuffer coauthorBuff = new StringBuffer();
|
||||||
adjacentNodesConcat.append("");
|
adjacentNodesConcat.append("");
|
||||||
coauthorBuff.append("");
|
coauthorBuff.append("");
|
||||||
|
|
||||||
queryList.add(prefix +
|
queryList.add(prefix +
|
||||||
" SELECT ?adjobj (str(?adjobjLabel) as ?coauthor) " +
|
" SELECT ?adjobj (str(?adjobjLabel) as ?coauthor) " +
|
||||||
" WHERE { " +
|
" WHERE { " +
|
||||||
" ?uri rdf:type <http://xmlns.com/foaf/0.1/Person> . " +
|
" ?uri rdf:type <http://xmlns.com/foaf/0.1/Person> . " +
|
||||||
|
@ -167,24 +167,24 @@ public class CalculateParameters implements DocumentModifier, ContextModelsUser
|
||||||
" UNION " +
|
" UNION " +
|
||||||
" { ?adjobj rdf:type <http://vivoweb.org/ontology/core#Location> . } ." +
|
" { ?adjobj rdf:type <http://vivoweb.org/ontology/core#Location> . } ." +
|
||||||
"}");
|
"}");
|
||||||
|
|
||||||
Query query;
|
Query query;
|
||||||
|
|
||||||
QuerySolution soln;
|
QuerySolution soln;
|
||||||
QuerySolutionMap initialBinding = new QuerySolutionMap();
|
QuerySolutionMap initialBinding = new QuerySolutionMap();
|
||||||
Resource uriResource = ResourceFactory.createResource(uri);
|
Resource uriResource = ResourceFactory.createResource(uri);
|
||||||
|
|
||||||
initialBinding.add("uri", uriResource);
|
initialBinding.add("uri", uriResource);
|
||||||
|
|
||||||
Iterator<String> queryItr = queryList.iterator();
|
Iterator<String> queryItr = queryList.iterator();
|
||||||
|
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
Resource adjacentIndividual = null;
|
Resource adjacentIndividual = null;
|
||||||
RDFNode coauthor = null;
|
RDFNode coauthor = null;
|
||||||
try{
|
try{
|
||||||
while(queryItr.hasNext()){
|
while(queryItr.hasNext()){
|
||||||
/*if(!isPerson){
|
/*if(!isPerson){
|
||||||
queryItr.next(); // we don't want first query to execute if the ind is not a person.
|
queryItr.next(); // we don't want first query to execute if the ind is not a person.
|
||||||
}*/
|
}*/
|
||||||
query = QueryFactory.create(queryItr.next(),Syntax.syntaxARQ);
|
query = QueryFactory.create(queryItr.next(),Syntax.syntaxARQ);
|
||||||
QueryExecution qexec = QueryExecutionFactory.create(query,dataset,initialBinding);
|
QueryExecution qexec = QueryExecutionFactory.create(query,dataset,initialBinding);
|
||||||
|
@ -196,35 +196,35 @@ public class CalculateParameters implements DocumentModifier, ContextModelsUser
|
||||||
adjacentIndividual = (Resource)soln.get("adjobj");
|
adjacentIndividual = (Resource)soln.get("adjobj");
|
||||||
if(adjacentIndividual!=null){
|
if(adjacentIndividual!=null){
|
||||||
adjacentNodes.add(adjacentIndividual.getURI());
|
adjacentNodes.add(adjacentIndividual.getURI());
|
||||||
}
|
}
|
||||||
|
|
||||||
coauthor = soln.get("coauthor");
|
coauthor = soln.get("coauthor");
|
||||||
if(coauthor!=null){
|
if(coauthor!=null){
|
||||||
coauthorNames.add(" co-authors " + coauthor.toString() + " co-authors ");
|
coauthorNames.add(" co-authors " + coauthor.toString() + " co-authors ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
if( ! shutdown )
|
if( ! shutdown )
|
||||||
log.error("Error found in getAdjacentNodes method of SearchQueryHandler");
|
log.error("Error found in getAdjacentNodes method of SearchQueryHandler");
|
||||||
}finally{
|
}finally{
|
||||||
qexec.close();
|
qexec.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
queryList = null;
|
queryList = null;
|
||||||
Iterator<String> itr = adjacentNodes.iterator();
|
Iterator<String> itr = adjacentNodes.iterator();
|
||||||
while(itr.hasNext()){
|
while(itr.hasNext()){
|
||||||
adjacentNodesConcat.append(itr.next()).append(" ");
|
adjacentNodesConcat.append(itr.next()).append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
info[0] = adjacentNodesConcat.toString();
|
info[0] = adjacentNodesConcat.toString();
|
||||||
|
|
||||||
itr = coauthorNames.iterator();
|
itr = coauthorNames.iterator();
|
||||||
while(itr.hasNext()){
|
while(itr.hasNext()){
|
||||||
coauthorBuff.append(itr.next());
|
coauthorBuff.append(itr.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
info[1] = coauthorBuff.toString();
|
info[1] = coauthorBuff.toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(Throwable t){
|
catch(Throwable t){
|
||||||
if( ! shutdown )
|
if( ! shutdown )
|
||||||
|
@ -237,24 +237,24 @@ public class CalculateParameters implements DocumentModifier, ContextModelsUser
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyDocument(Individual individual, SearchInputDocument doc) {
|
public void modifyDocument(Individual individual, SearchInputDocument doc) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
// calculate beta value.
|
// calculate beta value.
|
||||||
log.debug("Parameter calculation starts..");
|
log.debug("Parameter calculation starts..");
|
||||||
float beta = calculateBeta(individual.getURI());
|
float beta = calculateBeta(individual.getURI());
|
||||||
doc.addField(VitroSearchTermNames.BETA, (Object) beta);
|
doc.addField(VitroSearchTermNames.BETA, (Object) beta);
|
||||||
doc.setDocumentBoost(beta + doc.getDocumentBoost() );
|
doc.setDocumentBoost(beta + doc.getDocumentBoost() );
|
||||||
log.debug("Parameter calculation is done");
|
log.debug("Parameter calculation is done");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shutdown(){
|
public void shutdown(){
|
||||||
shutdown=true;
|
shutdown=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -267,11 +267,11 @@ class TotalInd implements Runnable{
|
||||||
private Dataset dataset;
|
private Dataset dataset;
|
||||||
private String totalCountQuery;
|
private String totalCountQuery;
|
||||||
private static Log log = LogFactory.getLog(TotalInd.class);
|
private static Log log = LogFactory.getLog(TotalInd.class);
|
||||||
|
|
||||||
public TotalInd(Dataset dataset,String totalCountQuery){
|
public TotalInd(Dataset dataset,String totalCountQuery){
|
||||||
this.dataset = dataset;
|
this.dataset = dataset;
|
||||||
this.totalCountQuery = totalCountQuery;
|
this.totalCountQuery = totalCountQuery;
|
||||||
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void run(){
|
public void run(){
|
||||||
|
@ -280,13 +280,13 @@ class TotalInd implements Runnable{
|
||||||
QuerySolution soln = null;
|
QuerySolution soln = null;
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
QueryExecution qexec = null;
|
QueryExecution qexec = null;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
query = QueryFactory.create(totalCountQuery,Syntax.syntaxARQ);
|
query = QueryFactory.create(totalCountQuery,Syntax.syntaxARQ);
|
||||||
qexec = QueryExecutionFactory.create(query,dataset);
|
qexec = QueryExecutionFactory.create(query,dataset);
|
||||||
ResultSet results = qexec.execSelect();
|
ResultSet results = qexec.execSelect();
|
||||||
List<String> resultVars = results.getResultVars();
|
List<String> resultVars = results.getResultVars();
|
||||||
|
|
||||||
if(resultVars!=null && resultVars.size()!=0){
|
if(resultVars!=null && resultVars.size()!=0){
|
||||||
soln = results.next();
|
soln = results.next();
|
||||||
totalInd = Integer.parseInt(soln.getLiteral(resultVars.get(0)).getLexicalForm());
|
totalInd = Integer.parseInt(soln.getLiteral(resultVars.get(0)).getLexicalForm());
|
||||||
|
@ -296,10 +296,10 @@ class TotalInd implements Runnable{
|
||||||
}catch(Throwable t){
|
}catch(Throwable t){
|
||||||
log.error(t,t);
|
log.error(t,t);
|
||||||
}finally{
|
}finally{
|
||||||
if( qexec != null )
|
if( qexec != null )
|
||||||
qexec.close();
|
qexec.close();
|
||||||
dataset.getLock().leaveCriticalSection();
|
dataset.getLock().leaveCriticalSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,22 +35,22 @@ import edu.cornell.mannlib.vitro.webapp.utils.configuration.Validation;
|
||||||
* If an individual has context nodes then the search document for that
|
* If an individual has context nodes then the search document for that
|
||||||
* individual should include the labels of the partners across those nodes. The
|
* individual should include the labels of the partners across those nodes. The
|
||||||
* labels will be added to the ALLTEXT and ALLTEXTUNSTEMMED fields.
|
* labels will be added to the ALLTEXT and ALLTEXTUNSTEMMED fields.
|
||||||
*
|
*
|
||||||
* We must specify what property leads to a context node (incoming), and what
|
* We must specify what property leads to a context node (incoming), and what
|
||||||
* property leads from a context node (outgoing). We may add restrictions to say
|
* property leads from a context node (outgoing). We may add restrictions to say
|
||||||
* that this only applies to individuals of certain types. We may also restrict
|
* that this only applies to individuals of certain types. We may also restrict
|
||||||
* the type of the applicable context nodes.
|
* the type of the applicable context nodes.
|
||||||
*
|
*
|
||||||
* An instance of this class acts as both a DocumentModifier and an
|
* An instance of this class acts as both a DocumentModifier and an
|
||||||
* IndexingUriFinder:
|
* IndexingUriFinder:
|
||||||
*
|
*
|
||||||
* As a DocumentModifier, it looks across approved context nodes to fetch the
|
* As a DocumentModifier, it looks across approved context nodes to fetch the
|
||||||
* labels of the partners.
|
* labels of the partners.
|
||||||
*
|
*
|
||||||
* As an IndexingUriFinder, it recognizes that this relationship can be changed
|
* As an IndexingUriFinder, it recognizes that this relationship can be changed
|
||||||
* by a change to a "label" statement, or to a "relates" property, and finds all
|
* by a change to a "label" statement, or to a "relates" property, and finds all
|
||||||
* partners as candidates for reindexing.
|
* partners as candidates for reindexing.
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* Configuration:
|
* Configuration:
|
||||||
* rdfs:label -- Optional. Appears in the timings and debug statements.
|
* rdfs:label -- Optional. Appears in the timings and debug statements.
|
||||||
|
@ -85,7 +85,7 @@ public class LabelsAcrossContextNodes implements IndexingUriFinder,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URIs of the types of individuals to whom this instance applies.
|
* URIs of the types of individuals to whom this instance applies.
|
||||||
*
|
*
|
||||||
* If this is not empty and an individual does not have any of these types,
|
* If this is not empty and an individual does not have any of these types,
|
||||||
* then skip that individual.
|
* then skip that individual.
|
||||||
*/
|
*/
|
||||||
|
@ -93,7 +93,7 @@ public class LabelsAcrossContextNodes implements IndexingUriFinder,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URIs of the types of acceptable context nodes.
|
* URIs of the types of acceptable context nodes.
|
||||||
*
|
*
|
||||||
* If this is not empty and a context node does not have any of these types,
|
* If this is not empty and a context node does not have any of these types,
|
||||||
* then skip that context node's label.
|
* then skip that context node's label.
|
||||||
*/
|
*/
|
||||||
|
@ -296,7 +296,7 @@ public class LabelsAcrossContextNodes implements IndexingUriFinder,
|
||||||
/**
|
/**
|
||||||
* If this is a "label" statement, check to see if the subject has any
|
* If this is a "label" statement, check to see if the subject has any
|
||||||
* acceptable partners across acceptable context nodes.
|
* acceptable partners across acceptable context nodes.
|
||||||
*
|
*
|
||||||
* If this is a statement that involves the specified incoming property on
|
* If this is a statement that involves the specified incoming property on
|
||||||
* an acceptable context node, check to see if there are any acceptable
|
* an acceptable context node, check to see if there are any acceptable
|
||||||
* partners on this node.
|
* partners on this node.
|
||||||
|
|
|
@ -1,91 +1,91 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.servlet;
|
package edu.cornell.mannlib.vitro.webapp.servlet;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.annotation.WebServlet;
|
import javax.servlet.annotation.WebServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.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 com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import edu.cornell.mannlib.semservices.bo.Concept;
|
import edu.cornell.mannlib.semservices.bo.Concept;
|
||||||
import edu.cornell.mannlib.semservices.bo.ConceptInfo;
|
import edu.cornell.mannlib.semservices.bo.ConceptInfo;
|
||||||
import edu.cornell.mannlib.semservices.bo.SemanticServicesError;
|
import edu.cornell.mannlib.semservices.bo.SemanticServicesError;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.ConceptSearchService.ConceptSearchServiceUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.ConceptSearchService.ConceptSearchServiceUtils;
|
||||||
|
|
||||||
@WebServlet(name = "ConceptSearchService", urlPatterns = {"/conceptSearchService"} )
|
@WebServlet(name = "ConceptSearchService", urlPatterns = {"/conceptSearchService"} )
|
||||||
public class ConceptSearchServlet extends VitroHttpServlet {
|
public class ConceptSearchServlet extends VitroHttpServlet {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static final Log log = LogFactory.getLog(ConceptSearchServlet.class);
|
private static final Log log = LogFactory.getLog(ConceptSearchServlet.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
super.doGet(req, resp);
|
super.doGet(req, resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
super.doGet(req, resp);
|
super.doGet(req, resp);
|
||||||
VitroRequest vreq = new VitroRequest(req);
|
VitroRequest vreq = new VitroRequest(req);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
ServletContext ctx = vreq.getSession().getServletContext();
|
ServletContext ctx = vreq.getSession().getServletContext();
|
||||||
//Captures both concept list and any errors if they exist
|
//Captures both concept list and any errors if they exist
|
||||||
ConceptInfo conceptInfo = new ConceptInfo();
|
ConceptInfo conceptInfo = new ConceptInfo();
|
||||||
conceptInfo.setSemanticServicesError(null);
|
conceptInfo.setSemanticServicesError(null);
|
||||||
|
|
||||||
//Json output should be written out
|
//Json output should be written out
|
||||||
List<Concept> results = null;
|
List<Concept> results = null;
|
||||||
try {
|
try {
|
||||||
results = ConceptSearchServiceUtils.getSearchResults(ctx, vreq);
|
results = ConceptSearchServiceUtils.getSearchResults(ctx, vreq);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
SemanticServicesError semanticServicesError = new SemanticServicesError(
|
SemanticServicesError semanticServicesError = new SemanticServicesError(
|
||||||
"Exception encountered ", ex.getMessage(), "fatal");
|
"Exception encountered ", ex.getMessage(), "fatal");
|
||||||
log.error("An error occurred retrieving search results", ex);
|
log.error("An error occurred retrieving search results", ex);
|
||||||
conceptInfo.setSemanticServicesError(semanticServicesError);
|
conceptInfo.setSemanticServicesError(semanticServicesError);
|
||||||
}
|
}
|
||||||
conceptInfo.setConceptList(results);
|
conceptInfo.setConceptList(results);
|
||||||
|
|
||||||
String json = renderJson(conceptInfo);
|
String json = renderJson(conceptInfo);
|
||||||
|
|
||||||
json = StringUtils.replaceChars(json, "\r\t\n", "");
|
json = StringUtils.replaceChars(json, "\r\t\n", "");
|
||||||
PrintWriter writer = resp.getWriter();
|
PrintWriter writer = resp.getWriter();
|
||||||
resp.setContentType("application/json");
|
resp.setContentType("application/json");
|
||||||
writer.write(json);
|
writer.write(json);
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|
||||||
}catch(Exception ex){
|
}catch(Exception ex){
|
||||||
log.warn(ex,ex);
|
log.warn(ex,ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected String renderJson(ConceptInfo conceptInfo) {
|
protected String renderJson(ConceptInfo conceptInfo) {
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
try {
|
try {
|
||||||
return mapper.writeValueAsString(conceptInfo);
|
return mapper.writeValueAsString(conceptInfo);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
log.error("An error occurred in rendering conceptInfo as json ", e);
|
log.error("An error occurred in rendering conceptInfo as json ", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,101 +1,101 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.utils.ConceptSearchService;
|
package edu.cornell.mannlib.vitro.webapp.utils.ConceptSearchService;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
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 edu.cornell.mannlib.semservices.bo.Concept;
|
import edu.cornell.mannlib.semservices.bo.Concept;
|
||||||
import edu.cornell.mannlib.semservices.service.ExternalConceptService;
|
import edu.cornell.mannlib.semservices.service.ExternalConceptService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
/**
|
/**
|
||||||
* Utilities for search
|
* Utilities for search
|
||||||
*/
|
*/
|
||||||
public class ConceptSearchServiceUtils {
|
public class ConceptSearchServiceUtils {
|
||||||
private static final Log log = LogFactory.getLog(ConceptSearchServiceUtils.class);
|
private static final Log log = LogFactory.getLog(ConceptSearchServiceUtils.class);
|
||||||
//Get the appropriate search service class
|
//Get the appropriate search service class
|
||||||
//TODO: Change this so retrieved from the system instead using a query
|
//TODO: Change this so retrieved from the system instead using a query
|
||||||
private static final String UMLSVocabSource = "http://link.informatics.stonybrook.edu/umls";
|
private static final String UMLSVocabSource = "http://link.informatics.stonybrook.edu/umls";
|
||||||
private static final String AgrovocVocabSource = "http://aims.fao.org/aos/agrovoc/agrovocScheme";
|
private static final String AgrovocVocabSource = "http://aims.fao.org/aos/agrovoc/agrovocScheme";
|
||||||
private static final String GemetVocabSource = "http://www.eionet.europa.eu/gemet/gemetThesaurus";
|
private static final String GemetVocabSource = "http://www.eionet.europa.eu/gemet/gemetThesaurus";
|
||||||
private static final String LCSHVocabSource = "http://id.loc.gov/authorities/subjects";
|
private static final String LCSHVocabSource = "http://id.loc.gov/authorities/subjects";
|
||||||
|
|
||||||
//Get the class that corresponds to the appropriate search
|
//Get the class that corresponds to the appropriate search
|
||||||
public static String getConceptSearchServiceClassName(String searchServiceName) {
|
public static String getConceptSearchServiceClassName(String searchServiceName) {
|
||||||
HashMap<String, String> map = getMapping();
|
HashMap<String, String> map = getMapping();
|
||||||
if(map.containsKey(searchServiceName)) {
|
if(map.containsKey(searchServiceName)) {
|
||||||
return map.get(searchServiceName);
|
return map.get(searchServiceName);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get the URLS for the different services
|
//Get the URLS for the different services
|
||||||
//URL to label
|
//URL to label
|
||||||
public static HashMap<String, VocabSourceDescription> getVocabSources() {
|
public static HashMap<String, VocabSourceDescription> getVocabSources() {
|
||||||
HashMap<String, VocabSourceDescription> map = new HashMap<String, VocabSourceDescription>();
|
HashMap<String, VocabSourceDescription> map = new HashMap<String, VocabSourceDescription>();
|
||||||
map.put(UMLSVocabSource, new VocabSourceDescription("UMLS", UMLSVocabSource, "http://www.nlm.nih.gov/research/umls/", "Unified Medical Language System"));
|
map.put(UMLSVocabSource, new VocabSourceDescription("UMLS", UMLSVocabSource, "http://www.nlm.nih.gov/research/umls/", "Unified Medical Language System"));
|
||||||
//Commenting out agrovoc for now until implementation is updated
|
//Commenting out agrovoc for now until implementation is updated
|
||||||
map.put(AgrovocVocabSource, new VocabSourceDescription("AGROVOC", AgrovocVocabSource, "http://www.fao.org/agrovoc/", "Agricultural Vocabulary"));
|
map.put(AgrovocVocabSource, new VocabSourceDescription("AGROVOC", AgrovocVocabSource, "http://www.fao.org/agrovoc/", "Agricultural Vocabulary"));
|
||||||
map.put(GemetVocabSource, new VocabSourceDescription("GEMET", GemetVocabSource, "http://www.eionet.europa.eu/gemet", "GEneral Multilingual Environmental Thesaurus"));
|
map.put(GemetVocabSource, new VocabSourceDescription("GEMET", GemetVocabSource, "http://www.eionet.europa.eu/gemet", "GEneral Multilingual Environmental Thesaurus"));
|
||||||
map.put(LCSHVocabSource, new VocabSourceDescription("LCSH", LCSHVocabSource, "http://id.loc.gov/authorities/subjects/", "Library of Congress Subject Headings"));
|
map.put(LCSHVocabSource, new VocabSourceDescription("LCSH", LCSHVocabSource, "http://id.loc.gov/authorities/subjects/", "Library of Congress Subject Headings"));
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get additional vocab source info
|
//Get additional vocab source info
|
||||||
|
|
||||||
|
|
||||||
//Get the hashmap mapping service name to Service class
|
//Get the hashmap mapping service name to Service class
|
||||||
private static HashMap<String, String> getMapping() {
|
private static HashMap<String, String> getMapping() {
|
||||||
HashMap<String, String> map = new HashMap<String, String>();
|
HashMap<String, String> map = new HashMap<String, String>();
|
||||||
map.put(UMLSVocabSource, "edu.cornell.mannlib.semservices.service.impl.UMLSService");
|
map.put(UMLSVocabSource, "edu.cornell.mannlib.semservices.service.impl.UMLSService");
|
||||||
map.put(AgrovocVocabSource, "edu.cornell.mannlib.semservices.service.impl.AgrovocService");
|
map.put(AgrovocVocabSource, "edu.cornell.mannlib.semservices.service.impl.AgrovocService");
|
||||||
map.put(GemetVocabSource, "edu.cornell.mannlib.semservices.service.impl.GemetService");
|
map.put(GemetVocabSource, "edu.cornell.mannlib.semservices.service.impl.GemetService");
|
||||||
map.put(LCSHVocabSource, "edu.cornell.mannlib.semservices.service.impl.LCSHService");
|
map.put(LCSHVocabSource, "edu.cornell.mannlib.semservices.service.impl.LCSHService");
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Concept> getSearchResults(ServletContext context, VitroRequest vreq) throws Exception {
|
public static List<Concept> getSearchResults(ServletContext context, VitroRequest vreq) throws Exception {
|
||||||
String searchServiceName = getSearchServiceUri(vreq);
|
String searchServiceName = getSearchServiceUri(vreq);
|
||||||
String searchServiceClassName = getConceptSearchServiceClassName(searchServiceName);
|
String searchServiceClassName = getConceptSearchServiceClassName(searchServiceName);
|
||||||
|
|
||||||
ExternalConceptService conceptServiceClass = null;
|
ExternalConceptService conceptServiceClass = null;
|
||||||
|
|
||||||
Object object = null;
|
Object object = null;
|
||||||
try {
|
try {
|
||||||
Class classDefinition = Class.forName(searchServiceClassName);
|
Class classDefinition = Class.forName(searchServiceClassName);
|
||||||
object = classDefinition.newInstance();
|
object = classDefinition.newInstance();
|
||||||
conceptServiceClass = (ExternalConceptService) object;
|
conceptServiceClass = (ExternalConceptService) object;
|
||||||
} catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) {
|
} catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) {
|
||||||
System.out.println(e);
|
System.out.println(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(conceptServiceClass == null){
|
if(conceptServiceClass == null){
|
||||||
log.error("could not find Concept Search Class for " + searchServiceName);
|
log.error("could not find Concept Search Class for " + searchServiceName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get search
|
//Get search
|
||||||
String searchTerm = getSearchTerm(vreq);
|
String searchTerm = getSearchTerm(vreq);
|
||||||
List<Concept> conceptResults = conceptServiceClass.getConcepts(searchTerm);
|
List<Concept> conceptResults = conceptServiceClass.getConcepts(searchTerm);
|
||||||
return conceptResults;
|
return conceptResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String getSearchServiceUri(VitroRequest vreq) {
|
private static String getSearchServiceUri(VitroRequest vreq) {
|
||||||
return vreq.getParameter("source");
|
return vreq.getParameter("source");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getSearchTerm(VitroRequest vreq) {
|
private static String getSearchTerm(VitroRequest vreq) {
|
||||||
return vreq.getParameter("searchTerm");
|
return vreq.getParameter("searchTerm");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.utils.ConceptSearchService;
|
package edu.cornell.mannlib.vitro.webapp.utils.ConceptSearchService;
|
||||||
|
|
||||||
public class VocabSourceDescription {
|
public class VocabSourceDescription {
|
||||||
private String url;
|
private String url;
|
||||||
private String label;
|
private String label;
|
||||||
private String schema;
|
private String schema;
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
public VocabSourceDescription(String inputLabel, String inputSchema, String inputUrl, String inputDescription) {
|
public VocabSourceDescription(String inputLabel, String inputSchema, String inputUrl, String inputDescription) {
|
||||||
url = inputUrl;
|
url = inputUrl;
|
||||||
label = inputLabel;
|
label = inputLabel;
|
||||||
schema = inputSchema;
|
schema = inputSchema;
|
||||||
description = inputDescription;
|
description = inputDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSchema() {
|
public String getSchema() {
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,135 +1,135 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.utils.dataGetter;
|
package edu.cornell.mannlib.vitro.webapp.utils.dataGetter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
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.query.Query;
|
import org.apache.jena.query.Query;
|
||||||
import org.apache.jena.query.QueryExecution;
|
import org.apache.jena.query.QueryExecution;
|
||||||
import org.apache.jena.query.QueryExecutionFactory;
|
import org.apache.jena.query.QueryExecutionFactory;
|
||||||
import org.apache.jena.query.QueryFactory;
|
import org.apache.jena.query.QueryFactory;
|
||||||
import org.apache.jena.query.QuerySolution;
|
import org.apache.jena.query.QuerySolution;
|
||||||
import org.apache.jena.query.QuerySolutionMap;
|
import org.apache.jena.query.QuerySolutionMap;
|
||||||
import org.apache.jena.query.ResultSet;
|
import org.apache.jena.query.ResultSet;
|
||||||
import org.apache.jena.rdf.model.Model;
|
import org.apache.jena.rdf.model.Model;
|
||||||
import org.apache.jena.rdf.model.RDFNode;
|
import org.apache.jena.rdf.model.RDFNode;
|
||||||
import org.apache.jena.rdf.model.ResourceFactory;
|
import org.apache.jena.rdf.model.ResourceFactory;
|
||||||
import org.apache.jena.rdf.model.Statement;
|
import org.apache.jena.rdf.model.Statement;
|
||||||
import org.apache.jena.rdf.model.StmtIterator;
|
import org.apache.jena.rdf.model.StmtIterator;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will pass these variables to the template:
|
* This will pass these variables to the template:
|
||||||
* classGroupUri: uri of the classgroup associated with this page.
|
* classGroupUri: uri of the classgroup associated with this page.
|
||||||
* vClassGroup: a data structure that is the classgroup associated with this page.
|
* vClassGroup: a data structure that is the classgroup associated with this page.
|
||||||
*/
|
*/
|
||||||
public class InternalClassesDataGetter extends IndividualsForClassesDataGetter{
|
public class InternalClassesDataGetter extends IndividualsForClassesDataGetter{
|
||||||
private static final Log log = LogFactory.getLog(InternalClassesDataGetter.class);
|
private static final Log log = LogFactory.getLog(InternalClassesDataGetter.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with display model and data getter URI that will be called by reflection.
|
* Constructor with display model and data getter URI that will be called by reflection.
|
||||||
*/
|
*/
|
||||||
public InternalClassesDataGetter(VitroRequest vreq, Model displayModel, String dataGetterURI){
|
public InternalClassesDataGetter(VitroRequest vreq, Model displayModel, String dataGetterURI){
|
||||||
super(vreq, displayModel, dataGetterURI);
|
super(vreq, displayModel, dataGetterURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Use different template name for internal class template
|
//Use different template name for internal class template
|
||||||
@Override
|
@Override
|
||||||
protected void setTemplateName() {
|
protected void setTemplateName() {
|
||||||
super.restrictClassesTemplateName = "internalClass";
|
super.restrictClassesTemplateName = "internalClass";
|
||||||
}
|
}
|
||||||
|
|
||||||
//Retrieve classes and check whether or not page to be filtered by internal class only
|
//Retrieve classes and check whether or not page to be filtered by internal class only
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, Object> getClassIntersectionsMap(Model displayModel) {
|
protected Map<String, Object> getClassIntersectionsMap(Model displayModel) {
|
||||||
|
|
||||||
Map<String, Object> classesAndRestrictions = new HashMap<String, Object>();
|
Map<String, Object> classesAndRestrictions = new HashMap<String, Object>();
|
||||||
QuerySolutionMap initialBindings = new QuerySolutionMap();
|
QuerySolutionMap initialBindings = new QuerySolutionMap();
|
||||||
initialBindings.add("dataGetterUri", ResourceFactory.createResource(this.dataGetterURI));
|
initialBindings.add("dataGetterUri", ResourceFactory.createResource(this.dataGetterURI));
|
||||||
List<String> classes = new ArrayList<String>();
|
List<String> classes = new ArrayList<String>();
|
||||||
|
|
||||||
displayModel.enterCriticalSection(false);
|
displayModel.enterCriticalSection(false);
|
||||||
try{
|
try{
|
||||||
Query individualsForClassesInternalQuery = QueryFactory.create(individualsForClassesInternalQueryString);
|
Query individualsForClassesInternalQuery = QueryFactory.create(individualsForClassesInternalQueryString);
|
||||||
QueryExecution qexec = QueryExecutionFactory.create( individualsForClassesInternalQuery, displayModel , initialBindings);
|
QueryExecution qexec = QueryExecutionFactory.create( individualsForClassesInternalQuery, displayModel , initialBindings);
|
||||||
try{
|
try{
|
||||||
ResultSet resultSet = qexec.execSelect();
|
ResultSet resultSet = qexec.execSelect();
|
||||||
while(resultSet.hasNext()){
|
while(resultSet.hasNext()){
|
||||||
QuerySolution soln = resultSet.next();
|
QuerySolution soln = resultSet.next();
|
||||||
String dg = DataGetterUtils.nodeToString(soln.get("dg"));
|
String dg = DataGetterUtils.nodeToString(soln.get("dg"));
|
||||||
classes.add(DataGetterUtils.nodeToString(soln.get("class")));
|
classes.add(DataGetterUtils.nodeToString(soln.get("class")));
|
||||||
//node to string will convert null to empty string
|
//node to string will convert null to empty string
|
||||||
String isInternal = DataGetterUtils.nodeToString(soln.get("isInternal"));
|
String isInternal = DataGetterUtils.nodeToString(soln.get("isInternal"));
|
||||||
if(!isInternal.isEmpty()) {
|
if(!isInternal.isEmpty()) {
|
||||||
log.debug("Internal value is "+ isInternal);
|
log.debug("Internal value is "+ isInternal);
|
||||||
//Retrieve and add internal class
|
//Retrieve and add internal class
|
||||||
classesAndRestrictions.put("isInternal", isInternal);
|
classesAndRestrictions.put("isInternal", isInternal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( classes.size() == 0 ){
|
if( classes.size() == 0 ){
|
||||||
log.debug("No classes defined in display model for "+ this.dataGetterURI);
|
log.debug("No classes defined in display model for "+ this.dataGetterURI);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
classesAndRestrictions.put("classes", classes);
|
classesAndRestrictions.put("classes", classes);
|
||||||
return classesAndRestrictions;
|
return classesAndRestrictions;
|
||||||
}finally{
|
}finally{
|
||||||
qexec.close();
|
qexec.close();
|
||||||
}
|
}
|
||||||
}finally{
|
}finally{
|
||||||
displayModel.leaveCriticalSection();
|
displayModel.leaveCriticalSection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Retrieve current internal class uri to restrict by
|
//Retrieve current internal class uri to restrict by
|
||||||
@Override
|
@Override
|
||||||
protected List<String> retrieveRestrictClasses(
|
protected List<String> retrieveRestrictClasses(
|
||||||
ServletContext context, Map<String, Object> classIntersectionsMap) {
|
ServletContext context, Map<String, Object> classIntersectionsMap) {
|
||||||
List<String> restrictClasses = new ArrayList<String>();
|
List<String> restrictClasses = new ArrayList<String>();
|
||||||
String internalClass = (String) classIntersectionsMap.get("isInternal");
|
String internalClass = (String) classIntersectionsMap.get("isInternal");
|
||||||
//if internal class restriction specified and is true
|
//if internal class restriction specified and is true
|
||||||
if(internalClass != null && internalClass.equals("true")) {
|
if(internalClass != null && internalClass.equals("true")) {
|
||||||
//Get internal class
|
//Get internal class
|
||||||
Model mainModel = ModelAccess.on(context).getOntModel(ModelNames.TBOX_ASSERTIONS);
|
Model mainModel = ModelAccess.on(context).getOntModel(ModelNames.TBOX_ASSERTIONS);
|
||||||
StmtIterator internalIt = mainModel.listStatements(null, ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT), (RDFNode) null);
|
StmtIterator internalIt = mainModel.listStatements(null, ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT), (RDFNode) null);
|
||||||
//Checks for just one statement
|
//Checks for just one statement
|
||||||
if(internalIt.hasNext()){
|
if(internalIt.hasNext()){
|
||||||
Statement s = internalIt.nextStatement();
|
Statement s = internalIt.nextStatement();
|
||||||
//The class IS an internal class so the subject is what we're looking for
|
//The class IS an internal class so the subject is what we're looking for
|
||||||
String internalClassUri = s.getSubject().getURI();
|
String internalClassUri = s.getSubject().getURI();
|
||||||
log.debug("Found internal class uri " + internalClassUri);
|
log.debug("Found internal class uri " + internalClassUri);
|
||||||
restrictClasses.add(internalClassUri);
|
restrictClasses.add(internalClassUri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return restrictClasses;
|
return restrictClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getType(){
|
public String getType(){
|
||||||
return DataGetterUtils.generateDataGetterTypeURI(InternalClassesDataGetter.class.getName());
|
return DataGetterUtils.generateDataGetterTypeURI(InternalClassesDataGetter.class.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
static final protected String individualsForClassesInternalQueryString =
|
static final protected String individualsForClassesInternalQueryString =
|
||||||
DataGetterUtils.prefixes + "\n" +
|
DataGetterUtils.prefixes + "\n" +
|
||||||
"SELECT?class ?isInternal WHERE {\n" +
|
"SELECT?class ?isInternal WHERE {\n" +
|
||||||
" ?dataGetterUri <" + DisplayVocabulary.GETINDIVIDUALS_FOR_CLASS + "> ?class . \n" +
|
" ?dataGetterUri <" + DisplayVocabulary.GETINDIVIDUALS_FOR_CLASS + "> ?class . \n" +
|
||||||
" OPTIONAL { ?dataGetterUri <"+ DisplayVocabulary.RESTRICT_RESULTS_BY_INTERNAL + "> ?isInternal } .\n" +
|
" OPTIONAL { ?dataGetterUri <"+ DisplayVocabulary.RESTRICT_RESULTS_BY_INTERNAL + "> ?isInternal } .\n" +
|
||||||
"} \n" ;
|
"} \n" ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,82 +1,82 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.utils.menuManagement;
|
package edu.cornell.mannlib.vitro.webapp.utils.menuManagement;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
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.rdf.model.Model;
|
import org.apache.jena.rdf.model.Model;
|
||||||
import org.apache.jena.rdf.model.ModelFactory;
|
import org.apache.jena.rdf.model.ModelFactory;
|
||||||
import org.apache.jena.rdf.model.Resource;
|
import org.apache.jena.rdf.model.Resource;
|
||||||
import org.apache.jena.rdf.model.ResourceFactory;
|
import org.apache.jena.rdf.model.ResourceFactory;
|
||||||
import org.apache.jena.vocabulary.RDF;
|
import org.apache.jena.vocabulary.RDF;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.DataGetterUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.DataGetterUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.InternalClassesDataGetter;
|
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.InternalClassesDataGetter;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle processing of data retrieved from IndividualsForClasses data getter to return to form template
|
* Handle processing of data retrieved from IndividualsForClasses data getter to return to form template
|
||||||
* and handle processing of form submission to create the appropriate individuals for classes data getter
|
* and handle processing of form submission to create the appropriate individuals for classes data getter
|
||||||
*/
|
*/
|
||||||
public class ProcessInternalClasses extends ProcessIndividualsForClasses {
|
public class ProcessInternalClasses extends ProcessIndividualsForClasses {
|
||||||
private static final Log log = LogFactory.getLog(ProcessInternalClasses.class);
|
private static final Log log = LogFactory.getLog(ProcessInternalClasses.class);
|
||||||
|
|
||||||
/**Retrieve and populate**/
|
/**Retrieve and populate**/
|
||||||
|
|
||||||
//Based on institutional internal page and not general individualsForClasses
|
//Based on institutional internal page and not general individualsForClasses
|
||||||
@Override
|
@Override
|
||||||
protected void populateRestrictedClasses(Map<String, Object> pageData, Map<String, Object> templateData) {
|
protected void populateRestrictedClasses(Map<String, Object> pageData, Map<String, Object> templateData) {
|
||||||
//for internal page, restrict results by internal is true or false, otherwise get
|
//for internal page, restrict results by internal is true or false, otherwise get
|
||||||
//actual restriction classes?
|
//actual restriction classes?
|
||||||
//Get internal class
|
//Get internal class
|
||||||
String internalClassUris = (String) pageData.get("internalClass");
|
String internalClassUris = (String) pageData.get("internalClass");
|
||||||
if(internalClassUris != null && !internalClassUris.isEmpty()) {
|
if(internalClassUris != null && !internalClassUris.isEmpty()) {
|
||||||
templateData.put("isInternal", "true");
|
templateData.put("isInternal", "true");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Process submission**/
|
/**Process submission**/
|
||||||
//Check and see if we should use this process
|
//Check and see if we should use this process
|
||||||
//Use this if either internal class is selected or all classes have been selected
|
//Use this if either internal class is selected or all classes have been selected
|
||||||
public boolean useProcessor(VitroRequest vreq) {
|
public boolean useProcessor(VitroRequest vreq) {
|
||||||
return(internalClassSelected(vreq) || !allClassesSelected(vreq));
|
return(internalClassSelected(vreq) || !allClassesSelected(vreq));
|
||||||
}
|
}
|
||||||
public Model processSubmission(VitroRequest vreq, Resource dataGetterResource) {
|
public Model processSubmission(VitroRequest vreq, Resource dataGetterResource) {
|
||||||
String dataGetterTypeUri = DataGetterUtils.generateDataGetterTypeURI(InternalClassesDataGetter.class.getName());
|
String dataGetterTypeUri = DataGetterUtils.generateDataGetterTypeURI(InternalClassesDataGetter.class.getName());
|
||||||
String[] selectedClasses = vreq.getParameterValues("classInClassGroup");
|
String[] selectedClasses = vreq.getParameterValues("classInClassGroup");
|
||||||
Model dgModel = ModelFactory.createDefaultModel();
|
Model dgModel = ModelFactory.createDefaultModel();
|
||||||
dgModel.add(dgModel.createStatement(dataGetterResource,
|
dgModel.add(dgModel.createStatement(dataGetterResource,
|
||||||
RDF.type,
|
RDF.type,
|
||||||
ResourceFactory.createResource(dataGetterTypeUri)));
|
ResourceFactory.createResource(dataGetterTypeUri)));
|
||||||
for(String classUri: selectedClasses) {
|
for(String classUri: selectedClasses) {
|
||||||
dgModel.add(dgModel.createStatement(
|
dgModel.add(dgModel.createStatement(
|
||||||
dataGetterResource,
|
dataGetterResource,
|
||||||
ResourceFactory.createProperty(DisplayVocabulary.GETINDIVIDUALS_FOR_CLASS),
|
ResourceFactory.createProperty(DisplayVocabulary.GETINDIVIDUALS_FOR_CLASS),
|
||||||
ResourceFactory.createResource(classUri)));
|
ResourceFactory.createResource(classUri)));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Also check if internal class checked
|
//Also check if internal class checked
|
||||||
if(internalClassSelected(vreq)) {
|
if(internalClassSelected(vreq)) {
|
||||||
dgModel.add(dgModel.createStatement(
|
dgModel.add(dgModel.createStatement(
|
||||||
dataGetterResource,
|
dataGetterResource,
|
||||||
ResourceFactory.createProperty(DisplayVocabulary.RESTRICT_RESULTS_BY_INTERNAL),
|
ResourceFactory.createProperty(DisplayVocabulary.RESTRICT_RESULTS_BY_INTERNAL),
|
||||||
dgModel.createLiteral("true")));
|
dgModel.createLiteral("true")));
|
||||||
}
|
}
|
||||||
return dgModel;
|
return dgModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean allClassesSelected(VitroRequest vreq) {
|
private boolean allClassesSelected(VitroRequest vreq) {
|
||||||
String allClasses = vreq.getParameter("allSelected");
|
String allClasses = vreq.getParameter("allSelected");
|
||||||
return (allClasses != null && !allClasses.isEmpty());
|
return (allClasses != null && !allClasses.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean internalClassSelected(VitroRequest vreq) {
|
private boolean internalClassSelected(VitroRequest vreq) {
|
||||||
String internalClass = vreq.getParameter("display-internalClass");
|
String internalClass = vreq.getParameter("display-internalClass");
|
||||||
return (internalClass != null && !internalClass.isEmpty());
|
return (internalClass != null && !internalClass.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,60 +1,60 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.utils.menuManagement;
|
package edu.cornell.mannlib.vitro.webapp.utils.menuManagement;
|
||||||
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_ASSERTIONS;
|
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_ASSERTIONS;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
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.ontology.OntModel;
|
import org.apache.jena.ontology.OntModel;
|
||||||
import org.apache.jena.rdf.model.RDFNode;
|
import org.apache.jena.rdf.model.RDFNode;
|
||||||
import org.apache.jena.rdf.model.ResourceFactory;
|
import org.apache.jena.rdf.model.ResourceFactory;
|
||||||
import org.apache.jena.rdf.model.StmtIterator;
|
import org.apache.jena.rdf.model.StmtIterator;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This class includes methods that help in selecting a data getter based on
|
* This class includes methods that help in selecting a data getter based on
|
||||||
* parameters, and VIVO will have its own version or extend this
|
* parameters, and VIVO will have its own version or extend this
|
||||||
*/
|
*/
|
||||||
public class VIVOMenuManagementDataUtils implements MenuManagementDataUtils.IMenuManagementDataUtils {
|
public class VIVOMenuManagementDataUtils implements MenuManagementDataUtils.IMenuManagementDataUtils {
|
||||||
private static final Log log = LogFactory.getLog(VIVOMenuManagementDataUtils.class);
|
private static final Log log = LogFactory.getLog(VIVOMenuManagementDataUtils.class);
|
||||||
|
|
||||||
//Data that is to be returned to template that does not involve data getters
|
//Data that is to be returned to template that does not involve data getters
|
||||||
//e.g. what are the current class groups, etc.
|
//e.g. what are the current class groups, etc.
|
||||||
public void includeRequiredSystemData(ServletContext context, Map<String, Object> templateData) {
|
public void includeRequiredSystemData(ServletContext context, Map<String, Object> templateData) {
|
||||||
checkInstitutionalInternalClass(context, templateData);
|
checkInstitutionalInternalClass(context, templateData);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check whether any classes exist with internal class restrictions
|
//Check whether any classes exist with internal class restrictions
|
||||||
private void checkInstitutionalInternalClass(ServletContext context, Map<String, Object> templateData) {
|
private void checkInstitutionalInternalClass(ServletContext context, Map<String, Object> templateData) {
|
||||||
//TODO: replace with more generic ModelContext retrieval method
|
//TODO: replace with more generic ModelContext retrieval method
|
||||||
String internalClass = retrieveInternalClass(context);
|
String internalClass = retrieveInternalClass(context);
|
||||||
if(internalClass != null) {
|
if(internalClass != null) {
|
||||||
templateData.put("internalClass", internalClass);
|
templateData.put("internalClass", internalClass);
|
||||||
templateData.put("internalClassUri", internalClass);
|
templateData.put("internalClassUri", internalClass);
|
||||||
} else {
|
} else {
|
||||||
//need to initialize to empty string anyway
|
//need to initialize to empty string anyway
|
||||||
templateData.put("internalClassUri", "");
|
templateData.put("internalClassUri", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String retrieveInternalClass(ServletContext context) {
|
private String retrieveInternalClass(ServletContext context) {
|
||||||
OntModel mainModel = ModelAccess.on(context).getOntModel(TBOX_ASSERTIONS);
|
OntModel mainModel = ModelAccess.on(context).getOntModel(TBOX_ASSERTIONS);
|
||||||
StmtIterator internalIt = mainModel.listStatements(null, ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT), (RDFNode) null);
|
StmtIterator internalIt = mainModel.listStatements(null, ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT), (RDFNode) null);
|
||||||
if(internalIt.hasNext()) {
|
if(internalIt.hasNext()) {
|
||||||
String internalClass = internalIt.nextStatement().getSubject().getURI();
|
String internalClass = internalIt.nextStatement().getSubject().getURI();
|
||||||
return internalClass;
|
return internalClass;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,332 +1,332 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.coauthorship;
|
package edu.cornell.mannlib.vitro.webapp.visualization.coauthorship;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.VisualizationFrameworkConstants;
|
import edu.cornell.mannlib.vitro.webapp.controller.visualization.VisualizationFrameworkConstants;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CollaborationComparator;
|
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CollaborationComparator;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CollaborationData;
|
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CollaborationData;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CollaboratorComparator;
|
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CollaboratorComparator;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaboration;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaboration;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaborator;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaborator;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.OutputKeys;
|
import javax.xml.transform.OutputKeys;
|
||||||
import javax.xml.transform.Transformer;
|
import javax.xml.transform.Transformer;
|
||||||
import javax.xml.transform.TransformerException;
|
import javax.xml.transform.TransformerException;
|
||||||
import javax.xml.transform.TransformerFactory;
|
import javax.xml.transform.TransformerFactory;
|
||||||
import javax.xml.transform.dom.DOMSource;
|
import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
public class CoAuthorshipGraphMLWriter {
|
public class CoAuthorshipGraphMLWriter {
|
||||||
|
|
||||||
private StringBuilder coAuthorshipGraphMLContent;
|
private StringBuilder coAuthorshipGraphMLContent;
|
||||||
|
|
||||||
private final String GRAPHML_NS = "http://graphml.graphdrawing.org/xmlns";
|
private final String GRAPHML_NS = "http://graphml.graphdrawing.org/xmlns";
|
||||||
|
|
||||||
public CoAuthorshipGraphMLWriter(CollaborationData visVOContainer) {
|
public CoAuthorshipGraphMLWriter(CollaborationData visVOContainer) {
|
||||||
coAuthorshipGraphMLContent = createCoAuthorshipGraphMLContent(visVOContainer);
|
coAuthorshipGraphMLContent = createCoAuthorshipGraphMLContent(visVOContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private StringBuilder createCoAuthorshipGraphMLContent(CollaborationData coAuthorshipData) {
|
private StringBuilder createCoAuthorshipGraphMLContent(CollaborationData coAuthorshipData) {
|
||||||
|
|
||||||
StringBuilder graphMLContent = new StringBuilder();
|
StringBuilder graphMLContent = new StringBuilder();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||||
docFactory.setNamespaceAware(true);
|
docFactory.setNamespaceAware(true);
|
||||||
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
||||||
|
|
||||||
// root elements
|
// root elements
|
||||||
Document doc = docBuilder.newDocument();
|
Document doc = docBuilder.newDocument();
|
||||||
doc.setXmlVersion("1.0");
|
doc.setXmlVersion("1.0");
|
||||||
Element rootElement = doc.createElementNS(GRAPHML_NS, "graphml");
|
Element rootElement = doc.createElementNS(GRAPHML_NS, "graphml");
|
||||||
doc.appendChild(rootElement);
|
doc.appendChild(rootElement);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We are side-effecting "graphMLContent" object in this method since creating
|
* We are side-effecting "graphMLContent" object in this method since creating
|
||||||
* another String object to hold key definition data will be redundant & will
|
* another String object to hold key definition data will be redundant & will
|
||||||
* not serve the purpose.
|
* not serve the purpose.
|
||||||
* */
|
* */
|
||||||
generateKeyDefinitionContent(coAuthorshipData, rootElement);
|
generateKeyDefinitionContent(coAuthorshipData, rootElement);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Used to generate graph content. It will contain both the nodes & edge information.
|
* Used to generate graph content. It will contain both the nodes & edge information.
|
||||||
* We are side-effecting "graphMLContent".
|
* We are side-effecting "graphMLContent".
|
||||||
* */
|
* */
|
||||||
generateGraphContent(coAuthorshipData, rootElement);
|
generateGraphContent(coAuthorshipData, rootElement);
|
||||||
|
|
||||||
DOMSource source = new DOMSource(doc);
|
DOMSource source = new DOMSource(doc);
|
||||||
TransformerFactory transFactory = TransformerFactory.newInstance();
|
TransformerFactory transFactory = TransformerFactory.newInstance();
|
||||||
Transformer transformer = transFactory.newTransformer();
|
Transformer transformer = transFactory.newTransformer();
|
||||||
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
|
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
|
||||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||||
|
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
StreamResult result = new StreamResult(writer);
|
StreamResult result = new StreamResult(writer);
|
||||||
transformer.transform(source, result);
|
transformer.transform(source, result);
|
||||||
|
|
||||||
graphMLContent.append(writer.toString());
|
graphMLContent.append(writer.toString());
|
||||||
} catch (ParserConfigurationException | TransformerException e) {
|
} catch (ParserConfigurationException | TransformerException e) {
|
||||||
throw new IllegalStateException("XML error generating GraphML", e);
|
throw new IllegalStateException("XML error generating GraphML", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return graphMLContent;
|
return graphMLContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringBuilder getCoAuthorshipGraphMLContent() {
|
public StringBuilder getCoAuthorshipGraphMLContent() {
|
||||||
return coAuthorshipGraphMLContent;
|
return coAuthorshipGraphMLContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateGraphContent(CollaborationData coAuthorshipData, Element rootElement) {
|
private void generateGraphContent(CollaborationData coAuthorshipData, Element rootElement) {
|
||||||
Document doc = rootElement.getOwnerDocument();
|
Document doc = rootElement.getOwnerDocument();
|
||||||
|
|
||||||
Element graph = doc.createElementNS(GRAPHML_NS, "graph");
|
Element graph = doc.createElementNS(GRAPHML_NS, "graph");
|
||||||
graph.setAttribute("edgedefault", "undirected");
|
graph.setAttribute("edgedefault", "undirected");
|
||||||
rootElement.appendChild(graph);
|
rootElement.appendChild(graph);
|
||||||
|
|
||||||
if (coAuthorshipData.getCollaborators() != null && coAuthorshipData.getCollaborators().size() > 0) {
|
if (coAuthorshipData.getCollaborators() != null && coAuthorshipData.getCollaborators().size() > 0) {
|
||||||
generateNodeSectionContent(coAuthorshipData, graph);
|
generateNodeSectionContent(coAuthorshipData, graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (coAuthorshipData.getCollaborations() != null && coAuthorshipData.getCollaborations().size() > 0) {
|
if (coAuthorshipData.getCollaborations() != null && coAuthorshipData.getCollaborations().size() > 0) {
|
||||||
generateEdgeSectionContent(coAuthorshipData, graph);
|
generateEdgeSectionContent(coAuthorshipData, graph);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateEdgeSectionContent(CollaborationData coAuthorshipData, Element graphElement) {
|
private void generateEdgeSectionContent(CollaborationData coAuthorshipData, Element graphElement) {
|
||||||
Document doc = graphElement.getOwnerDocument();
|
Document doc = graphElement.getOwnerDocument();
|
||||||
|
|
||||||
graphElement.appendChild(doc.createComment("edges"));
|
graphElement.appendChild(doc.createComment("edges"));
|
||||||
|
|
||||||
Set<Collaboration> edges = coAuthorshipData.getCollaborations();
|
Set<Collaboration> edges = coAuthorshipData.getCollaborations();
|
||||||
List<Collaboration> orderedEdges = new ArrayList<Collaboration>(edges);
|
List<Collaboration> orderedEdges = new ArrayList<Collaboration>(edges);
|
||||||
orderedEdges.sort(new CollaborationComparator());
|
orderedEdges.sort(new CollaborationComparator());
|
||||||
|
|
||||||
for (Collaboration currentEdge : orderedEdges) {
|
for (Collaboration currentEdge : orderedEdges) {
|
||||||
/*
|
/*
|
||||||
* This method actually creates the XML code for a single Collaboration.
|
* This method actually creates the XML code for a single Collaboration.
|
||||||
* "graphMLContent" is being side-effected.
|
* "graphMLContent" is being side-effected.
|
||||||
* */
|
* */
|
||||||
getEdgeContent(graphElement, currentEdge);
|
getEdgeContent(graphElement, currentEdge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getEdgeContent(Element graphElement, Collaboration currentEdge) {
|
private void getEdgeContent(Element graphElement, Collaboration currentEdge) {
|
||||||
Document doc = graphElement.getOwnerDocument();
|
Document doc = graphElement.getOwnerDocument();
|
||||||
|
|
||||||
Element edge = doc.createElementNS(GRAPHML_NS, "edge");
|
Element edge = doc.createElementNS(GRAPHML_NS, "edge");
|
||||||
edge.setAttribute("id", String.valueOf(currentEdge.getCollaborationID()));
|
edge.setAttribute("id", String.valueOf(currentEdge.getCollaborationID()));
|
||||||
edge.setAttribute("source", String.valueOf(currentEdge.getSourceCollaborator().getCollaboratorID()));
|
edge.setAttribute("source", String.valueOf(currentEdge.getSourceCollaborator().getCollaboratorID()));
|
||||||
edge.setAttribute("target", String.valueOf(currentEdge.getTargetCollaborator().getCollaboratorID()));
|
edge.setAttribute("target", String.valueOf(currentEdge.getTargetCollaborator().getCollaboratorID()));
|
||||||
graphElement.appendChild(edge);
|
graphElement.appendChild(edge);
|
||||||
|
|
||||||
Element collaborator1 = doc.createElementNS(GRAPHML_NS, "data");
|
Element collaborator1 = doc.createElementNS(GRAPHML_NS, "data");
|
||||||
collaborator1.setAttribute("key", "collaborator1");
|
collaborator1.setAttribute("key", "collaborator1");
|
||||||
collaborator1.setTextContent(currentEdge.getSourceCollaborator().getCollaboratorName());
|
collaborator1.setTextContent(currentEdge.getSourceCollaborator().getCollaboratorName());
|
||||||
edge.appendChild(collaborator1);
|
edge.appendChild(collaborator1);
|
||||||
|
|
||||||
Element collaborator2 = doc.createElementNS(GRAPHML_NS, "data");
|
Element collaborator2 = doc.createElementNS(GRAPHML_NS, "data");
|
||||||
collaborator2.setAttribute("key", "collaborator2");
|
collaborator2.setAttribute("key", "collaborator2");
|
||||||
collaborator2.setTextContent(currentEdge.getTargetCollaborator().getCollaboratorName());
|
collaborator2.setTextContent(currentEdge.getTargetCollaborator().getCollaboratorName());
|
||||||
edge.appendChild(collaborator2);
|
edge.appendChild(collaborator2);
|
||||||
|
|
||||||
Element works = doc.createElementNS(GRAPHML_NS, "data");
|
Element works = doc.createElementNS(GRAPHML_NS, "data");
|
||||||
works.setAttribute("key", "number_of_coauthored_works");
|
works.setAttribute("key", "number_of_coauthored_works");
|
||||||
works.setTextContent(String.valueOf(currentEdge.getNumOfCollaborations()));
|
works.setTextContent(String.valueOf(currentEdge.getNumOfCollaborations()));
|
||||||
edge.appendChild(works);
|
edge.appendChild(works);
|
||||||
|
|
||||||
if (currentEdge.getEarliestCollaborationYearCount() != null) {
|
if (currentEdge.getEarliestCollaborationYearCount() != null) {
|
||||||
/*
|
/*
|
||||||
* There is no clean way of getting the map contents in java even though
|
* There is no clean way of getting the map contents in java even though
|
||||||
* we are sure to have only one entry on the map. So using the for loop.
|
* we are sure to have only one entry on the map. So using the for loop.
|
||||||
* */
|
* */
|
||||||
for (Map.Entry<String, Integer> publicationInfo : currentEdge.getEarliestCollaborationYearCount().entrySet()) {
|
for (Map.Entry<String, Integer> publicationInfo : currentEdge.getEarliestCollaborationYearCount().entrySet()) {
|
||||||
|
|
||||||
Element earliest = doc.createElementNS(GRAPHML_NS, "data");
|
Element earliest = doc.createElementNS(GRAPHML_NS, "data");
|
||||||
earliest.setAttribute("key", "earliest_collaboration");
|
earliest.setAttribute("key", "earliest_collaboration");
|
||||||
earliest.setTextContent(publicationInfo.getKey());
|
earliest.setTextContent(publicationInfo.getKey());
|
||||||
edge.appendChild(earliest);
|
edge.appendChild(earliest);
|
||||||
|
|
||||||
Element earliestCount = doc.createElementNS(GRAPHML_NS, "data");
|
Element earliestCount = doc.createElementNS(GRAPHML_NS, "data");
|
||||||
earliestCount.setAttribute("key", "num_earliest_collaboration");
|
earliestCount.setAttribute("key", "num_earliest_collaboration");
|
||||||
earliestCount.setTextContent(publicationInfo.getValue().toString());
|
earliestCount.setTextContent(publicationInfo.getValue().toString());
|
||||||
edge.appendChild(earliestCount);
|
edge.appendChild(earliestCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentEdge.getLatestCollaborationYearCount() != null) {
|
if (currentEdge.getLatestCollaborationYearCount() != null) {
|
||||||
for (Map.Entry<String, Integer> publicationInfo : currentEdge.getLatestCollaborationYearCount().entrySet()) {
|
for (Map.Entry<String, Integer> publicationInfo : currentEdge.getLatestCollaborationYearCount().entrySet()) {
|
||||||
Element latest = doc.createElementNS(GRAPHML_NS, "data");
|
Element latest = doc.createElementNS(GRAPHML_NS, "data");
|
||||||
latest.setAttribute("key", "latest_collaboration");
|
latest.setAttribute("key", "latest_collaboration");
|
||||||
latest.setTextContent(publicationInfo.getKey());
|
latest.setTextContent(publicationInfo.getKey());
|
||||||
edge.appendChild(latest);
|
edge.appendChild(latest);
|
||||||
|
|
||||||
Element latestCount = doc.createElementNS(GRAPHML_NS, "data");
|
Element latestCount = doc.createElementNS(GRAPHML_NS, "data");
|
||||||
latestCount.setAttribute("key", "num_latest_collaboration");
|
latestCount.setAttribute("key", "num_latest_collaboration");
|
||||||
latestCount.setTextContent(publicationInfo.getValue().toString());
|
latestCount.setTextContent(publicationInfo.getValue().toString());
|
||||||
edge.appendChild(latestCount);
|
edge.appendChild(latestCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentEdge.getUnknownCollaborationYearCount() != null) {
|
if (currentEdge.getUnknownCollaborationYearCount() != null) {
|
||||||
Element unknown = doc.createElementNS(GRAPHML_NS, "data");
|
Element unknown = doc.createElementNS(GRAPHML_NS, "data");
|
||||||
unknown.setAttribute("key", "num_unknown_collaboration");
|
unknown.setAttribute("key", "num_unknown_collaboration");
|
||||||
unknown.setTextContent(String.valueOf(currentEdge.getUnknownCollaborationYearCount()));
|
unknown.setTextContent(String.valueOf(currentEdge.getUnknownCollaborationYearCount()));
|
||||||
edge.appendChild(unknown);
|
edge.appendChild(unknown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateNodeSectionContent(CollaborationData coAuthorshipData, Element graphElement) {
|
private void generateNodeSectionContent(CollaborationData coAuthorshipData, Element graphElement) {
|
||||||
Document doc = graphElement.getOwnerDocument();
|
Document doc = graphElement.getOwnerDocument();
|
||||||
|
|
||||||
graphElement.appendChild(doc.createComment("nodes"));
|
graphElement.appendChild(doc.createComment("nodes"));
|
||||||
|
|
||||||
Collaborator egoNode = coAuthorshipData.getEgoCollaborator();
|
Collaborator egoNode = coAuthorshipData.getEgoCollaborator();
|
||||||
Set<Collaborator> authorNodes = coAuthorshipData.getCollaborators();
|
Set<Collaborator> authorNodes = coAuthorshipData.getCollaborators();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This method actually creates the XML code for a single Collaborator. "graphMLContent"
|
* This method actually creates the XML code for a single Collaborator. "graphMLContent"
|
||||||
* is being side-effected. The egoNode is added first because this is the "requirement"
|
* is being side-effected. The egoNode is added first because this is the "requirement"
|
||||||
* of the co-author vis. Ego should always come first.
|
* of the co-author vis. Ego should always come first.
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
getNodeContent(graphElement, egoNode);
|
getNodeContent(graphElement, egoNode);
|
||||||
|
|
||||||
List<Collaborator> orderedAuthorNodes = new ArrayList<Collaborator>(authorNodes);
|
List<Collaborator> orderedAuthorNodes = new ArrayList<Collaborator>(authorNodes);
|
||||||
orderedAuthorNodes.remove(egoNode);
|
orderedAuthorNodes.remove(egoNode);
|
||||||
|
|
||||||
orderedAuthorNodes.sort(new CollaboratorComparator());
|
orderedAuthorNodes.sort(new CollaboratorComparator());
|
||||||
|
|
||||||
for (Collaborator currNode : orderedAuthorNodes) {
|
for (Collaborator currNode : orderedAuthorNodes) {
|
||||||
/*
|
/*
|
||||||
* We have already printed the Ego Collaborator info.
|
* We have already printed the Ego Collaborator info.
|
||||||
* */
|
* */
|
||||||
if (currNode != egoNode) {
|
if (currNode != egoNode) {
|
||||||
getNodeContent(graphElement, currNode);
|
getNodeContent(graphElement, currNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getNodeContent(Element graphElement, Collaborator collaborator) {
|
private void getNodeContent(Element graphElement, Collaborator collaborator) {
|
||||||
Document doc = graphElement.getOwnerDocument();
|
Document doc = graphElement.getOwnerDocument();
|
||||||
|
|
||||||
ParamMap individualProfileURLParams =
|
ParamMap individualProfileURLParams =
|
||||||
new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, collaborator.getCollaboratorURI());
|
new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, collaborator.getCollaboratorURI());
|
||||||
|
|
||||||
String profileURL = UrlBuilder.getUrl(VisualizationFrameworkConstants.INDIVIDUAL_URL_PREFIX, individualProfileURLParams);
|
String profileURL = UrlBuilder.getUrl(VisualizationFrameworkConstants.INDIVIDUAL_URL_PREFIX, individualProfileURLParams);
|
||||||
|
|
||||||
Element node = doc.createElementNS(GRAPHML_NS, "node");
|
Element node = doc.createElementNS(GRAPHML_NS, "node");
|
||||||
node.setAttribute("id", String.valueOf(collaborator.getCollaboratorID()));
|
node.setAttribute("id", String.valueOf(collaborator.getCollaboratorID()));
|
||||||
graphElement.appendChild(node);
|
graphElement.appendChild(node);
|
||||||
|
|
||||||
Element url = doc.createElementNS(GRAPHML_NS, "data");
|
Element url = doc.createElementNS(GRAPHML_NS, "data");
|
||||||
url.setAttribute("key", "url");
|
url.setAttribute("key", "url");
|
||||||
url.setTextContent(collaborator.getCollaboratorURI());
|
url.setTextContent(collaborator.getCollaboratorURI());
|
||||||
node.appendChild(url);
|
node.appendChild(url);
|
||||||
|
|
||||||
Element label = doc.createElementNS(GRAPHML_NS, "data");
|
Element label = doc.createElementNS(GRAPHML_NS, "data");
|
||||||
label.setAttribute("key", "label");
|
label.setAttribute("key", "label");
|
||||||
label.setTextContent(collaborator.getCollaboratorName());
|
label.setTextContent(collaborator.getCollaboratorName());
|
||||||
node.appendChild(label);
|
node.appendChild(label);
|
||||||
|
|
||||||
if (profileURL != null) {
|
if (profileURL != null) {
|
||||||
Element profile = doc.createElementNS(GRAPHML_NS, "data");
|
Element profile = doc.createElementNS(GRAPHML_NS, "data");
|
||||||
profile.setAttribute("key", "profile_url");
|
profile.setAttribute("key", "profile_url");
|
||||||
profile.setTextContent(profileURL);
|
profile.setTextContent(profileURL);
|
||||||
node.appendChild(profile);
|
node.appendChild(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
Element works = doc.createElementNS(GRAPHML_NS, "data");
|
Element works = doc.createElementNS(GRAPHML_NS, "data");
|
||||||
works.setAttribute("key", "number_of_authored_works");
|
works.setAttribute("key", "number_of_authored_works");
|
||||||
works.setTextContent(String.valueOf(collaborator.getNumOfActivities()));
|
works.setTextContent(String.valueOf(collaborator.getNumOfActivities()));
|
||||||
node.appendChild(works);
|
node.appendChild(works);
|
||||||
|
|
||||||
if (collaborator.getEarliestActivityYearCount() != null) {
|
if (collaborator.getEarliestActivityYearCount() != null) {
|
||||||
/*
|
/*
|
||||||
* There is no clean way of getting the map contents in java even though
|
* There is no clean way of getting the map contents in java even though
|
||||||
* we are sure to have only one entry on the map. So using the for loop.
|
* we are sure to have only one entry on the map. So using the for loop.
|
||||||
* I am feeling dirty just about now.
|
* I am feeling dirty just about now.
|
||||||
* */
|
* */
|
||||||
for (Map.Entry<String, Integer> publicationInfo : collaborator.getEarliestActivityYearCount().entrySet()) {
|
for (Map.Entry<String, Integer> publicationInfo : collaborator.getEarliestActivityYearCount().entrySet()) {
|
||||||
Element earliest = doc.createElementNS(GRAPHML_NS, "data");
|
Element earliest = doc.createElementNS(GRAPHML_NS, "data");
|
||||||
earliest.setAttribute("key", "earliest_publication");
|
earliest.setAttribute("key", "earliest_publication");
|
||||||
earliest.setTextContent(publicationInfo.getKey());
|
earliest.setTextContent(publicationInfo.getKey());
|
||||||
node.appendChild(earliest);
|
node.appendChild(earliest);
|
||||||
|
|
||||||
Element earliestCount = doc.createElementNS(GRAPHML_NS, "data");
|
Element earliestCount = doc.createElementNS(GRAPHML_NS, "data");
|
||||||
earliestCount.setAttribute("key", "num_earliest_publication");
|
earliestCount.setAttribute("key", "num_earliest_publication");
|
||||||
earliestCount.setTextContent(publicationInfo.getValue().toString());
|
earliestCount.setTextContent(publicationInfo.getValue().toString());
|
||||||
node.appendChild(earliestCount);
|
node.appendChild(earliestCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collaborator.getLatestActivityYearCount() != null) {
|
if (collaborator.getLatestActivityYearCount() != null) {
|
||||||
for (Map.Entry<String, Integer> publicationInfo : collaborator.getLatestActivityYearCount().entrySet()) {
|
for (Map.Entry<String, Integer> publicationInfo : collaborator.getLatestActivityYearCount().entrySet()) {
|
||||||
Element latest = doc.createElementNS(GRAPHML_NS, "data");
|
Element latest = doc.createElementNS(GRAPHML_NS, "data");
|
||||||
latest.setAttribute("key", "latest_publication");
|
latest.setAttribute("key", "latest_publication");
|
||||||
latest.setTextContent(publicationInfo.getKey());
|
latest.setTextContent(publicationInfo.getKey());
|
||||||
node.appendChild(latest);
|
node.appendChild(latest);
|
||||||
|
|
||||||
Element latestCount = doc.createElementNS(GRAPHML_NS, "data");
|
Element latestCount = doc.createElementNS(GRAPHML_NS, "data");
|
||||||
latestCount.setAttribute("key", "num_latest_publication");
|
latestCount.setAttribute("key", "num_latest_publication");
|
||||||
latestCount.setTextContent(publicationInfo.getValue().toString());
|
latestCount.setTextContent(publicationInfo.getValue().toString());
|
||||||
node.appendChild(latestCount);
|
node.appendChild(latestCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collaborator.getUnknownActivityYearCount() != null) {
|
if (collaborator.getUnknownActivityYearCount() != null) {
|
||||||
Element unknown = doc.createElementNS(GRAPHML_NS, "data");
|
Element unknown = doc.createElementNS(GRAPHML_NS, "data");
|
||||||
unknown.setAttribute("key", "num_unknown_publication");
|
unknown.setAttribute("key", "num_unknown_publication");
|
||||||
unknown.setTextContent(String.valueOf(collaborator.getUnknownActivityYearCount()));
|
unknown.setTextContent(String.valueOf(collaborator.getUnknownActivityYearCount()));
|
||||||
node.appendChild(unknown);
|
node.appendChild(unknown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateKeyDefinitionContent(CollaborationData visVOContainer, Element rootElement) {
|
private void generateKeyDefinitionContent(CollaborationData visVOContainer, Element rootElement) {
|
||||||
/*
|
/*
|
||||||
* Generate the key definition content for node.
|
* Generate the key definition content for node.
|
||||||
* */
|
* */
|
||||||
getKeyDefinitionFromSchema(visVOContainer.getNodeSchema(), rootElement);
|
getKeyDefinitionFromSchema(visVOContainer.getNodeSchema(), rootElement);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generate the key definition content for edge.
|
* Generate the key definition content for edge.
|
||||||
* */
|
* */
|
||||||
getKeyDefinitionFromSchema(visVOContainer.getEdgeSchema(), rootElement);
|
getKeyDefinitionFromSchema(visVOContainer.getEdgeSchema(), rootElement);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getKeyDefinitionFromSchema(Set<Map<String, String>> schema, Element rootElement) {
|
private void getKeyDefinitionFromSchema(Set<Map<String, String>> schema, Element rootElement) {
|
||||||
Document doc = rootElement.getOwnerDocument();
|
Document doc = rootElement.getOwnerDocument();
|
||||||
|
|
||||||
for (Map<String, String> currentNodeSchemaAttribute : schema) {
|
for (Map<String, String> currentNodeSchemaAttribute : schema) {
|
||||||
Element key = doc.createElementNS(GRAPHML_NS, "key");
|
Element key = doc.createElementNS(GRAPHML_NS, "key");
|
||||||
|
|
||||||
for (Map.Entry<String, String> currentAttributeKey : currentNodeSchemaAttribute.entrySet()) {
|
for (Map.Entry<String, String> currentAttributeKey : currentNodeSchemaAttribute.entrySet()) {
|
||||||
key.setAttribute(currentAttributeKey.getKey(), currentAttributeKey.getValue());
|
key.setAttribute(currentAttributeKey.getKey(), currentAttributeKey.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentNodeSchemaAttribute.containsKey("default")) {
|
if (currentNodeSchemaAttribute.containsKey("default")) {
|
||||||
Element def = doc.createElementNS(GRAPHML_NS, "default");
|
Element def = doc.createElementNS(GRAPHML_NS, "default");
|
||||||
def.setTextContent(currentNodeSchemaAttribute.get("default"));
|
def.setTextContent(currentNodeSchemaAttribute.get("default"));
|
||||||
key.appendChild(def);
|
key.appendChild(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
rootElement.appendChild(key);
|
rootElement.appendChild(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,8 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UniqueIDGenerator
|
||||||
/**
|
/**
|
||||||
* This query runner is used to execute a sparql query to get all the publications
|
* This query runner is used to execute a sparql query to get all the publications
|
||||||
* for a particular individual. It will also fetch all the authors that worked
|
* for a particular individual. It will also fetch all the authors that worked
|
||||||
* on that particular publication.
|
* on that particular publication.
|
||||||
*
|
*
|
||||||
* @author cdtank
|
* @author cdtank
|
||||||
*/
|
*/
|
||||||
public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
|
public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
|
||||||
|
@ -63,7 +63,7 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
|
||||||
private RDFService rdfService;
|
private RDFService rdfService;
|
||||||
|
|
||||||
private VitroRequest vitroRequest;
|
private VitroRequest vitroRequest;
|
||||||
|
|
||||||
private Log log;
|
private Log log;
|
||||||
|
|
||||||
public CoAuthorshipQueryRunner(String egoURI, VitroRequest vreq, Log log) {
|
public CoAuthorshipQueryRunner(String egoURI, VitroRequest vreq, Log log) {
|
||||||
|
@ -77,12 +77,12 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
|
||||||
|
|
||||||
private static class QueryResultConsumer extends ResultSetConsumer {
|
private static class QueryResultConsumer extends ResultSetConsumer {
|
||||||
Set<Collaborator> nodes = new HashSet<Collaborator>();
|
Set<Collaborator> nodes = new HashSet<Collaborator>();
|
||||||
|
|
||||||
Map<String, Activity> biboDocumentURLToVO = new HashMap<String, Activity>();
|
Map<String, Activity> biboDocumentURLToVO = new HashMap<String, Activity>();
|
||||||
Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors = new HashMap<String, Set<Collaborator>>();
|
Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors = new HashMap<String, Set<Collaborator>>();
|
||||||
Map<String, Collaborator> nodeURLToVO = new HashMap<String, Collaborator>();
|
Map<String, Collaborator> nodeURLToVO = new HashMap<String, Collaborator>();
|
||||||
Map<String, Collaboration> edgeUniqueIdentifierToVO = new HashMap<String, Collaboration>();
|
Map<String, Collaboration> edgeUniqueIdentifierToVO = new HashMap<String, Collaboration>();
|
||||||
|
|
||||||
Collaborator egoNode = null;
|
Collaborator egoNode = null;
|
||||||
|
|
||||||
Set<Collaboration> edges = new HashSet<Collaboration>();
|
Set<Collaboration> edges = new HashSet<Collaboration>();
|
||||||
|
|
|
@ -28,10 +28,10 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequ
|
||||||
/**
|
/**
|
||||||
* This request handler is used when information related to co-authorship network
|
* This request handler is used when information related to co-authorship network
|
||||||
* for an individual is requested. It currently provides 2 outputs,
|
* for an individual is requested. It currently provides 2 outputs,
|
||||||
* 1. Graphml content representing the individual's co-authorship network
|
* 1. Graphml content representing the individual's co-authorship network
|
||||||
* 1. CSV file containing the list(& count) of unique co-authors with which
|
* 1. CSV file containing the list(& count) of unique co-authors with which
|
||||||
* the individual has worked over the years. This data powers the related sparkline.
|
* the individual has worked over the years. This data powers the related sparkline.
|
||||||
*
|
*
|
||||||
* @author cdtank
|
* @author cdtank
|
||||||
*/
|
*/
|
||||||
public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
|
public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
|
||||||
|
@ -54,7 +54,7 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
|
||||||
VitroRequest vitroRequest, Log log, Dataset dataset)
|
VitroRequest vitroRequest, Log log, Dataset dataset)
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
|
|
||||||
|
|
||||||
String egoURI = vitroRequest.getParameter(
|
String egoURI = vitroRequest.getParameter(
|
||||||
VisualizationFrameworkConstants
|
VisualizationFrameworkConstants
|
||||||
.INDIVIDUAL_URI_KEY);
|
.INDIVIDUAL_URI_KEY);
|
||||||
|
@ -65,88 +65,88 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
|
||||||
|
|
||||||
CoAuthorshipQueryRunner queryManager =
|
CoAuthorshipQueryRunner queryManager =
|
||||||
new CoAuthorshipQueryRunner(egoURI, vitroRequest, log);
|
new CoAuthorshipQueryRunner(egoURI, vitroRequest, log);
|
||||||
|
|
||||||
CollaborationData authorNodesAndEdges =
|
CollaborationData authorNodesAndEdges =
|
||||||
queryManager.getQueryResult();
|
queryManager.getQueryResult();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We will be using the same visualization package for both sparkline & coauthorship
|
* We will be using the same visualization package for both sparkline & coauthorship
|
||||||
* flash vis. We will use "VIS_MODE_KEY" as a modifier to differentiate
|
* flash vis. We will use "VIS_MODE_KEY" as a modifier to differentiate
|
||||||
* between these two. The default will be to render the coauthorship network vis.
|
* between these two. The default will be to render the coauthorship network vis.
|
||||||
* */
|
* */
|
||||||
if (VisualizationFrameworkConstants.COAUTHORS_COUNT_PER_YEAR_VIS_MODE
|
if (VisualizationFrameworkConstants.COAUTHORS_COUNT_PER_YEAR_VIS_MODE
|
||||||
.equalsIgnoreCase(visMode)) {
|
.equalsIgnoreCase(visMode)) {
|
||||||
/*
|
/*
|
||||||
* When the csv file is required - based on which sparkline visualization will
|
* When the csv file is required - based on which sparkline visualization will
|
||||||
* be rendered.
|
* be rendered.
|
||||||
* */
|
* */
|
||||||
return prepareCoauthorsCountPerYearDataResponse(authorNodesAndEdges);
|
return prepareCoauthorsCountPerYearDataResponse(authorNodesAndEdges);
|
||||||
|
|
||||||
} else if (VisualizationFrameworkConstants.COAUTHORS_LIST_VIS_MODE
|
} else if (VisualizationFrameworkConstants.COAUTHORS_LIST_VIS_MODE
|
||||||
.equalsIgnoreCase(visMode)) {
|
.equalsIgnoreCase(visMode)) {
|
||||||
/*
|
/*
|
||||||
* When the csv file is required - based on which sparkline visualization will
|
* When the csv file is required - based on which sparkline visualization will
|
||||||
* be rendered.
|
* be rendered.
|
||||||
* */
|
* */
|
||||||
return prepareCoauthorsListDataResponse(authorNodesAndEdges);
|
return prepareCoauthorsListDataResponse(authorNodesAndEdges);
|
||||||
|
|
||||||
} else if (VisualizationFrameworkConstants.COAUTHOR_NETWORK_DOWNLOAD_VIS_MODE
|
} else if (VisualizationFrameworkConstants.COAUTHOR_NETWORK_DOWNLOAD_VIS_MODE
|
||||||
.equalsIgnoreCase(visMode)) {
|
.equalsIgnoreCase(visMode)) {
|
||||||
/*
|
/*
|
||||||
* When the csv file is required - based on which sparkline visualization will
|
* When the csv file is required - based on which sparkline visualization will
|
||||||
* be rendered.
|
* be rendered.
|
||||||
* */
|
* */
|
||||||
return prepareNetworkDownloadDataResponse(authorNodesAndEdges);
|
return prepareNetworkDownloadDataResponse(authorNodesAndEdges);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* When the graphML file is required - based on which coauthorship network
|
* When the graphML file is required - based on which coauthorship network
|
||||||
* visualization will be rendered.
|
* visualization will be rendered.
|
||||||
* */
|
* */
|
||||||
return prepareNetworkStreamDataResponse(authorNodesAndEdges);
|
return prepareNetworkStreamDataResponse(authorNodesAndEdges);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseValues generateStandardVisualization(VitroRequest vitroRequest,
|
public ResponseValues generateStandardVisualization(VitroRequest vitroRequest,
|
||||||
Log log,
|
Log log,
|
||||||
Dataset dataset)
|
Dataset dataset)
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
|
|
||||||
throw new UnsupportedOperationException("CoAuthorship Visualization "
|
throw new UnsupportedOperationException("CoAuthorship Visualization "
|
||||||
+ "does not provide Standalone response.");
|
+ "does not provide Standalone response.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCoauthorsListCSVContent(CollaborationData coAuthorshipData) {
|
private String getCoauthorsListCSVContent(CollaborationData coAuthorshipData) {
|
||||||
|
|
||||||
StringBuilder csvFileContent = new StringBuilder();
|
StringBuilder csvFileContent = new StringBuilder();
|
||||||
|
|
||||||
csvFileContent.append("Co-author, Count\n");
|
csvFileContent.append("Co-author, Count\n");
|
||||||
|
|
||||||
for (Collaborator currNode : coAuthorshipData.getCollaborators()) {
|
for (Collaborator currNode : coAuthorshipData.getCollaborators()) {
|
||||||
/*
|
/*
|
||||||
* We have already printed the Ego Node info.
|
* We have already printed the Ego Node info.
|
||||||
* */
|
* */
|
||||||
if (currNode != coAuthorshipData.getEgoCollaborator()) {
|
if (currNode != coAuthorshipData.getEgoCollaborator()) {
|
||||||
|
|
||||||
|
|
||||||
csvFileContent.append(StringEscapeUtils.escapeCsv(currNode.getCollaboratorName()));
|
csvFileContent.append(StringEscapeUtils.escapeCsv(currNode.getCollaboratorName()));
|
||||||
csvFileContent.append(",");
|
csvFileContent.append(",");
|
||||||
csvFileContent.append(currNode.getNumOfActivities());
|
csvFileContent.append(currNode.getNumOfActivities());
|
||||||
csvFileContent.append("\n");
|
csvFileContent.append("\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return csvFileContent.toString();
|
return csvFileContent.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCoauthorsPerYearCSVContent(Map<String, Set<Collaborator>> yearToCoauthors) {
|
private String getCoauthorsPerYearCSVContent(Map<String, Set<Collaborator>> yearToCoauthors) {
|
||||||
|
|
||||||
StringBuilder csvFileContent = new StringBuilder();
|
StringBuilder csvFileContent = new StringBuilder();
|
||||||
|
|
||||||
csvFileContent.append("Year, Count, Co-author(s)\n");
|
csvFileContent.append("Year, Count, Co-author(s)\n");
|
||||||
|
|
||||||
for (Entry<String, Set<Collaborator>> currentEntry : yearToCoauthors.entrySet()) {
|
for (Entry<String, Set<Collaborator>> currentEntry : yearToCoauthors.entrySet()) {
|
||||||
csvFileContent.append(StringEscapeUtils.escapeCsv(currentEntry.getKey()));
|
csvFileContent.append(StringEscapeUtils.escapeCsv(currentEntry.getKey()));
|
||||||
csvFileContent.append(",");
|
csvFileContent.append(",");
|
||||||
|
@ -156,136 +156,136 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
|
||||||
getCoauthorNamesAsString(currentEntry.getValue())));
|
getCoauthorNamesAsString(currentEntry.getValue())));
|
||||||
csvFileContent.append("\n");
|
csvFileContent.append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return csvFileContent.toString();
|
return csvFileContent.toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCoauthorNamesAsString(Set<Collaborator> coAuthors) {
|
private String getCoauthorNamesAsString(Set<Collaborator> coAuthors) {
|
||||||
|
|
||||||
StringBuilder coAuthorsMerged = new StringBuilder();
|
StringBuilder coAuthorsMerged = new StringBuilder();
|
||||||
|
|
||||||
String coAuthorSeparator = "; ";
|
String coAuthorSeparator = "; ";
|
||||||
for (Collaborator currCoAuthor : coAuthors) {
|
for (Collaborator currCoAuthor : coAuthors) {
|
||||||
coAuthorsMerged.append(currCoAuthor.getCollaboratorName()).append(coAuthorSeparator);
|
coAuthorsMerged.append(currCoAuthor.getCollaboratorName()).append(coAuthorSeparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
return StringUtils.removeEnd(coAuthorsMerged.toString(), coAuthorSeparator);
|
return StringUtils.removeEnd(coAuthorsMerged.toString(), coAuthorSeparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides response when a csv file containing number & names of unique co-authors per
|
* Provides response when a csv file containing number & names of unique co-authors per
|
||||||
* year is requested.
|
* year is requested.
|
||||||
* @param authorNodesAndEdges Author nodes and edges
|
* @param authorNodesAndEdges Author nodes and edges
|
||||||
*/
|
*/
|
||||||
private Map<String, String> prepareCoauthorsCountPerYearDataResponse(
|
private Map<String, String> prepareCoauthorsCountPerYearDataResponse(
|
||||||
CollaborationData authorNodesAndEdges) {
|
CollaborationData authorNodesAndEdges) {
|
||||||
|
|
||||||
String outputFileName;
|
String outputFileName;
|
||||||
Map<String, Set<Collaborator>> yearToCoauthors = new TreeMap<String, Set<Collaborator>>();
|
Map<String, Set<Collaborator>> yearToCoauthors = new TreeMap<String, Set<Collaborator>>();
|
||||||
|
|
||||||
if (authorNodesAndEdges.getCollaborators() != null
|
if (authorNodesAndEdges.getCollaborators() != null
|
||||||
&& authorNodesAndEdges.getCollaborators().size() > 0) {
|
&& authorNodesAndEdges.getCollaborators().size() > 0) {
|
||||||
|
|
||||||
outputFileName = UtilityFunctions.slugify(authorNodesAndEdges
|
outputFileName = UtilityFunctions.slugify(authorNodesAndEdges
|
||||||
.getEgoCollaborator().getCollaboratorName())
|
.getEgoCollaborator().getCollaboratorName())
|
||||||
+ "_co-authors-per-year" + ".csv";
|
+ "_co-authors-per-year" + ".csv";
|
||||||
|
|
||||||
yearToCoauthors = UtilityFunctions.getActivityYearToCollaborators(authorNodesAndEdges);
|
yearToCoauthors = UtilityFunctions.getActivityYearToCollaborators(authorNodesAndEdges);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
outputFileName = "no_co-authors-per-year" + ".csv";
|
outputFileName = "no_co-authors-per-year" + ".csv";
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> fileData = new HashMap<String, String>();
|
Map<String, String> fileData = new HashMap<String, String>();
|
||||||
fileData.put(DataVisualizationController.FILE_NAME_KEY,
|
fileData.put(DataVisualizationController.FILE_NAME_KEY,
|
||||||
outputFileName);
|
outputFileName);
|
||||||
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
|
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
|
||||||
"application/octet-stream");
|
"application/octet-stream");
|
||||||
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
||||||
getCoauthorsPerYearCSVContent(yearToCoauthors));
|
getCoauthorsPerYearCSVContent(yearToCoauthors));
|
||||||
|
|
||||||
return fileData;
|
return fileData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides response when a csv file containing number & names of unique co-authors per
|
* Provides response when a csv file containing number & names of unique co-authors per
|
||||||
* year is requested.
|
* year is requested.
|
||||||
* @param coAuthorshipData Co authorship data
|
* @param coAuthorshipData Co authorship data
|
||||||
*/
|
*/
|
||||||
private Map<String, String> prepareCoauthorsListDataResponse(
|
private Map<String, String> prepareCoauthorsListDataResponse(
|
||||||
CollaborationData coAuthorshipData) {
|
CollaborationData coAuthorshipData) {
|
||||||
|
|
||||||
String outputFileName = "";
|
String outputFileName = "";
|
||||||
|
|
||||||
if (coAuthorshipData.getCollaborators() != null
|
if (coAuthorshipData.getCollaborators() != null
|
||||||
&& coAuthorshipData.getCollaborators().size() > 0) {
|
&& coAuthorshipData.getCollaborators().size() > 0) {
|
||||||
|
|
||||||
outputFileName = UtilityFunctions.slugify(coAuthorshipData.getEgoCollaborator()
|
outputFileName = UtilityFunctions.slugify(coAuthorshipData.getEgoCollaborator()
|
||||||
.getCollaboratorName())
|
.getCollaboratorName())
|
||||||
+ "_co-authors" + ".csv";
|
+ "_co-authors" + ".csv";
|
||||||
} else {
|
} else {
|
||||||
outputFileName = "no_co-authors" + ".csv";
|
outputFileName = "no_co-authors" + ".csv";
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> fileData = new HashMap<String, String>();
|
Map<String, String> fileData = new HashMap<String, String>();
|
||||||
fileData.put(DataVisualizationController.FILE_NAME_KEY,
|
fileData.put(DataVisualizationController.FILE_NAME_KEY,
|
||||||
outputFileName);
|
outputFileName);
|
||||||
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
|
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
|
||||||
"application/octet-stream");
|
"application/octet-stream");
|
||||||
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
||||||
getCoauthorsListCSVContent(coAuthorshipData));
|
getCoauthorsListCSVContent(coAuthorshipData));
|
||||||
|
|
||||||
return fileData;
|
return fileData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a response when graphml formatted co-authorship network is requested, typically by
|
* Provides a response when graphml formatted co-authorship network is requested, typically by
|
||||||
* the flash vis.
|
* the flash vis.
|
||||||
* @param authorNodesAndEdges Author nodes and edges
|
* @param authorNodesAndEdges Author nodes and edges
|
||||||
*/
|
*/
|
||||||
private Map<String, String> prepareNetworkStreamDataResponse(
|
private Map<String, String> prepareNetworkStreamDataResponse(
|
||||||
CollaborationData authorNodesAndEdges) {
|
CollaborationData authorNodesAndEdges) {
|
||||||
|
|
||||||
CoAuthorshipGraphMLWriter coAuthorshipGraphMLWriter =
|
CoAuthorshipGraphMLWriter coAuthorshipGraphMLWriter =
|
||||||
new CoAuthorshipGraphMLWriter(authorNodesAndEdges);
|
new CoAuthorshipGraphMLWriter(authorNodesAndEdges);
|
||||||
|
|
||||||
Map<String, String> fileData = new HashMap<String, String>();
|
Map<String, String> fileData = new HashMap<String, String>();
|
||||||
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
|
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
|
||||||
"text/xml");
|
"text/xml");
|
||||||
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
||||||
coAuthorshipGraphMLWriter.getCoAuthorshipGraphMLContent().toString());
|
coAuthorshipGraphMLWriter.getCoAuthorshipGraphMLContent().toString());
|
||||||
|
|
||||||
return fileData;
|
return fileData;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> prepareNetworkDownloadDataResponse(
|
private Map<String, String> prepareNetworkDownloadDataResponse(
|
||||||
CollaborationData authorNodesAndEdges) {
|
CollaborationData authorNodesAndEdges) {
|
||||||
|
|
||||||
String outputFileName = "";
|
String outputFileName = "";
|
||||||
|
|
||||||
if (authorNodesAndEdges.getCollaborators() != null
|
if (authorNodesAndEdges.getCollaborators() != null
|
||||||
&& authorNodesAndEdges.getCollaborators().size() > 0) {
|
&& authorNodesAndEdges.getCollaborators().size() > 0) {
|
||||||
|
|
||||||
outputFileName = UtilityFunctions.slugify(authorNodesAndEdges
|
outputFileName = UtilityFunctions.slugify(authorNodesAndEdges
|
||||||
.getEgoCollaborator().getCollaboratorName())
|
.getEgoCollaborator().getCollaboratorName())
|
||||||
+ "_co-author-network.graphml" + ".xml";
|
+ "_co-author-network.graphml" + ".xml";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
outputFileName = "no_co-author-network.graphml" + ".xml";
|
outputFileName = "no_co-author-network.graphml" + ".xml";
|
||||||
}
|
}
|
||||||
|
|
||||||
CoAuthorshipGraphMLWriter coAuthorshipGraphMLWriter =
|
CoAuthorshipGraphMLWriter coAuthorshipGraphMLWriter =
|
||||||
new CoAuthorshipGraphMLWriter(authorNodesAndEdges);
|
new CoAuthorshipGraphMLWriter(authorNodesAndEdges);
|
||||||
|
|
||||||
Map<String, String> fileData = new HashMap<String, String>();
|
Map<String, String> fileData = new HashMap<String, String>();
|
||||||
fileData.put(DataVisualizationController.FILE_NAME_KEY,
|
fileData.put(DataVisualizationController.FILE_NAME_KEY,
|
||||||
outputFileName);
|
outputFileName);
|
||||||
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
|
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
|
||||||
"text/xml");
|
"text/xml");
|
||||||
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
|
||||||
coAuthorshipGraphMLWriter.getCoAuthorshipGraphMLContent().toString());
|
coAuthorshipGraphMLWriter.getCoAuthorshipGraphMLContent().toString());
|
||||||
|
|
||||||
return fileData;
|
return fileData;
|
||||||
|
|
|
@ -1,254 +1,254 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.coauthorship;
|
package edu.cornell.mannlib.vitro.webapp.visualization.coauthorship;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.VisualizationFrameworkConstants;
|
import edu.cornell.mannlib.vitro.webapp.controller.visualization.VisualizationFrameworkConstants;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
|
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VisConstants;
|
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VisConstants;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaborator;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaborator;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.SparklineData;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.SparklineData;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.YearToEntityCountDataElement;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.YearToEntityCountDataElement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions;
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions;
|
||||||
|
|
||||||
|
|
||||||
public class CoAuthorshipVisCodeGenerator {
|
public class CoAuthorshipVisCodeGenerator {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There are 2 modes of sparkline that are available via this visualization.
|
* There are 2 modes of sparkline that are available via this visualization.
|
||||||
* 1. Short Sparkline - This sparkline will render all the data points (or sparks),
|
* 1. Short Sparkline - This sparkline will render all the data points (or sparks),
|
||||||
* which in this case are the coauthors over the years, from the last 10 years.
|
* which in this case are the coauthors over the years, from the last 10 years.
|
||||||
*
|
*
|
||||||
* 2. Full Sparkline - This sparkline will render all the data points (or sparks)
|
* 2. Full Sparkline - This sparkline will render all the data points (or sparks)
|
||||||
* spanning the career of the person & last 10 years at the minimum, in case if
|
* spanning the career of the person & last 10 years at the minimum, in case if
|
||||||
* the person started his career in the last 10 yeras.
|
* the person started his career in the last 10 yeras.
|
||||||
* */
|
* */
|
||||||
private static final String DEFAULT_VISCONTAINER_DIV_ID = "unique_coauthors_vis_container";
|
private static final String DEFAULT_VISCONTAINER_DIV_ID = "unique_coauthors_vis_container";
|
||||||
|
|
||||||
private Map<String, Set<Collaborator>> yearToUniqueCoauthors;
|
private Map<String, Set<Collaborator>> yearToUniqueCoauthors;
|
||||||
|
|
||||||
private Log log;
|
private Log log;
|
||||||
|
|
||||||
private SparklineData sparklineParameterVO;
|
private SparklineData sparklineParameterVO;
|
||||||
|
|
||||||
private String individualURI;
|
private String individualURI;
|
||||||
|
|
||||||
public CoAuthorshipVisCodeGenerator(String individualURI,
|
public CoAuthorshipVisCodeGenerator(String individualURI,
|
||||||
String visMode,
|
String visMode,
|
||||||
String visContainer,
|
String visContainer,
|
||||||
Map<String, Set<Collaborator>> yearToUniqueCoauthors,
|
Map<String, Set<Collaborator>> yearToUniqueCoauthors,
|
||||||
Log log) {
|
Log log) {
|
||||||
|
|
||||||
this.individualURI = individualURI;
|
this.individualURI = individualURI;
|
||||||
|
|
||||||
this.yearToUniqueCoauthors = yearToUniqueCoauthors;
|
this.yearToUniqueCoauthors = yearToUniqueCoauthors;
|
||||||
|
|
||||||
this.log = log;
|
this.log = log;
|
||||||
|
|
||||||
this.sparklineParameterVO = setupSparklineParameters(visMode, visContainer);
|
this.sparklineParameterVO = setupSparklineParameters(visMode, visContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used to setup parameters for the sparkline value object. These parameters
|
* This method is used to setup parameters for the sparkline value object. These parameters
|
||||||
* will be used in the template to construct the actual html/javascript code.
|
* will be used in the template to construct the actual html/javascript code.
|
||||||
* @param visMode Visualization mode
|
* @param visMode Visualization mode
|
||||||
* @param providedVisContainerID Container ID
|
* @param providedVisContainerID Container ID
|
||||||
*/
|
*/
|
||||||
private SparklineData setupSparklineParameters(String visMode,
|
private SparklineData setupSparklineParameters(String visMode,
|
||||||
String providedVisContainerID) {
|
String providedVisContainerID) {
|
||||||
|
|
||||||
SparklineData sparklineData = new SparklineData();
|
SparklineData sparklineData = new SparklineData();
|
||||||
|
|
||||||
int numOfYearsToBeRendered = 0;
|
int numOfYearsToBeRendered = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* It was decided that to prevent downward curve that happens if there are no publications
|
* It was decided that to prevent downward curve that happens if there are no publications
|
||||||
* in the current year seems a bit harsh, so we consider only publications from the last 10
|
* in the current year seems a bit harsh, so we consider only publications from the last 10
|
||||||
* complete years.
|
* complete years.
|
||||||
* */
|
* */
|
||||||
int currentYear = Calendar.getInstance().get(Calendar.YEAR) - 1;
|
int currentYear = Calendar.getInstance().get(Calendar.YEAR) - 1;
|
||||||
int shortSparkMinYear = currentYear
|
int shortSparkMinYear = currentYear
|
||||||
- VisConstants.MINIMUM_YEARS_CONSIDERED_FOR_SPARKLINE
|
- VisConstants.MINIMUM_YEARS_CONSIDERED_FOR_SPARKLINE
|
||||||
+ 1;
|
+ 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is required because when deciding the range of years over which the vis
|
* This is required because when deciding the range of years over which the vis
|
||||||
* was rendered we dont want to be influenced by the "DEFAULT_PUBLICATION_YEAR".
|
* was rendered we dont want to be influenced by the "DEFAULT_PUBLICATION_YEAR".
|
||||||
* */
|
* */
|
||||||
Set<String> publishedYears = new HashSet<String>(yearToUniqueCoauthors.keySet());
|
Set<String> publishedYears = new HashSet<String>(yearToUniqueCoauthors.keySet());
|
||||||
publishedYears.remove(VOConstants.DEFAULT_PUBLICATION_YEAR);
|
publishedYears.remove(VOConstants.DEFAULT_PUBLICATION_YEAR);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We are setting the default value of minPublishedYear to be 10 years before
|
* We are setting the default value of minPublishedYear to be 10 years before
|
||||||
* the current year (which is suitably represented by the shortSparkMinYear),
|
* the current year (which is suitably represented by the shortSparkMinYear),
|
||||||
* this in case we run into invalid set of published years.
|
* this in case we run into invalid set of published years.
|
||||||
* */
|
* */
|
||||||
int minPublishedYear = shortSparkMinYear;
|
int minPublishedYear = shortSparkMinYear;
|
||||||
|
|
||||||
String visContainerID = null;
|
String visContainerID = null;
|
||||||
|
|
||||||
if (yearToUniqueCoauthors.size() > 0) {
|
if (yearToUniqueCoauthors.size() > 0) {
|
||||||
try {
|
try {
|
||||||
minPublishedYear = Integer.parseInt(Collections.min(publishedYears));
|
minPublishedYear = Integer.parseInt(Collections.min(publishedYears));
|
||||||
} catch (NoSuchElementException | NumberFormatException e1) {
|
} catch (NoSuchElementException | NumberFormatException e1) {
|
||||||
log.debug("vis: " + e1.getMessage() + " error occurred for "
|
log.debug("vis: " + e1.getMessage() + " error occurred for "
|
||||||
+ yearToUniqueCoauthors.toString());
|
+ yearToUniqueCoauthors.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int minPubYearConsidered = 0;
|
int minPubYearConsidered = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There might be a case that the author has made his first publication within the
|
* There might be a case that the author has made his first publication within the
|
||||||
* last 10 years but we want to make sure that the sparkline is representative of
|
* last 10 years but we want to make sure that the sparkline is representative of
|
||||||
* at least the last 10 years, so we will set the minPubYearConsidered to
|
* at least the last 10 years, so we will set the minPubYearConsidered to
|
||||||
* "currentYear - 10" which is also given by "shortSparkMinYear".
|
* "currentYear - 10" which is also given by "shortSparkMinYear".
|
||||||
* */
|
* */
|
||||||
if (minPublishedYear > shortSparkMinYear) {
|
if (minPublishedYear > shortSparkMinYear) {
|
||||||
minPubYearConsidered = shortSparkMinYear;
|
minPubYearConsidered = shortSparkMinYear;
|
||||||
} else {
|
} else {
|
||||||
minPubYearConsidered = minPublishedYear;
|
minPubYearConsidered = minPublishedYear;
|
||||||
}
|
}
|
||||||
|
|
||||||
numOfYearsToBeRendered = currentYear - minPubYearConsidered + 1;
|
numOfYearsToBeRendered = currentYear - minPubYearConsidered + 1;
|
||||||
|
|
||||||
sparklineData.setNumOfYearsToBeRendered(numOfYearsToBeRendered);
|
sparklineData.setNumOfYearsToBeRendered(numOfYearsToBeRendered);
|
||||||
|
|
||||||
int uniqueCoAuthorCounter = 0;
|
int uniqueCoAuthorCounter = 0;
|
||||||
Set<Collaborator> allCoAuthorsWithKnownAuthorshipYears = new HashSet<Collaborator>();
|
Set<Collaborator> allCoAuthorsWithKnownAuthorshipYears = new HashSet<Collaborator>();
|
||||||
List<YearToEntityCountDataElement> yearToUniqueCoauthorsCountDataTable =
|
List<YearToEntityCountDataElement> yearToUniqueCoauthorsCountDataTable =
|
||||||
new ArrayList<YearToEntityCountDataElement>();
|
new ArrayList<YearToEntityCountDataElement>();
|
||||||
|
|
||||||
for (int publicationYear = minPubYearConsidered;
|
for (int publicationYear = minPubYearConsidered;
|
||||||
publicationYear <= currentYear;
|
publicationYear <= currentYear;
|
||||||
publicationYear++) {
|
publicationYear++) {
|
||||||
|
|
||||||
String publicationYearAsString = String.valueOf(publicationYear);
|
String publicationYearAsString = String.valueOf(publicationYear);
|
||||||
Set<Collaborator> currentCoAuthors = yearToUniqueCoauthors
|
Set<Collaborator> currentCoAuthors = yearToUniqueCoauthors
|
||||||
.get(publicationYearAsString);
|
.get(publicationYearAsString);
|
||||||
|
|
||||||
Integer currentUniqueCoAuthors = null;
|
Integer currentUniqueCoAuthors = null;
|
||||||
|
|
||||||
if (currentCoAuthors != null) {
|
if (currentCoAuthors != null) {
|
||||||
currentUniqueCoAuthors = currentCoAuthors.size();
|
currentUniqueCoAuthors = currentCoAuthors.size();
|
||||||
allCoAuthorsWithKnownAuthorshipYears.addAll(currentCoAuthors);
|
allCoAuthorsWithKnownAuthorshipYears.addAll(currentCoAuthors);
|
||||||
} else {
|
} else {
|
||||||
currentUniqueCoAuthors = 0;
|
currentUniqueCoAuthors = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
yearToUniqueCoauthorsCountDataTable.add(
|
yearToUniqueCoauthorsCountDataTable.add(
|
||||||
new YearToEntityCountDataElement(uniqueCoAuthorCounter,
|
new YearToEntityCountDataElement(uniqueCoAuthorCounter,
|
||||||
publicationYearAsString,
|
publicationYearAsString,
|
||||||
currentUniqueCoAuthors));
|
currentUniqueCoAuthors));
|
||||||
uniqueCoAuthorCounter++;
|
uniqueCoAuthorCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For the purpose of this visualization I have come up with a term "Sparks" which
|
* For the purpose of this visualization I have come up with a term "Sparks" which
|
||||||
* essentially means data points.
|
* essentially means data points.
|
||||||
* Sparks that will be rendered in full mode will always be the one's which have any year
|
* Sparks that will be rendered in full mode will always be the one's which have any year
|
||||||
* associated with it. Hence.
|
* associated with it. Hence.
|
||||||
* */
|
* */
|
||||||
sparklineData.setRenderedSparks(allCoAuthorsWithKnownAuthorshipYears.size());
|
sparklineData.setRenderedSparks(allCoAuthorsWithKnownAuthorshipYears.size());
|
||||||
|
|
||||||
sparklineData.setYearToEntityCountDataTable(yearToUniqueCoauthorsCountDataTable);
|
sparklineData.setYearToEntityCountDataTable(yearToUniqueCoauthorsCountDataTable);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is required only for the sparklines which convey collaborationships like
|
* This is required only for the sparklines which convey collaborationships like
|
||||||
* coinvestigatorships and coauthorship. There are edge cases where a collaborator can be
|
* coinvestigatorships and coauthorship. There are edge cases where a collaborator can be
|
||||||
* present for in a collaboration with known & unknown year. We do not want to repeat the
|
* present for in a collaboration with known & unknown year. We do not want to repeat the
|
||||||
* count for this collaborator when we present it in the front-end.
|
* count for this collaborator when we present it in the front-end.
|
||||||
* */
|
* */
|
||||||
Set<Collaborator> totalUniqueCoInvestigators =
|
Set<Collaborator> totalUniqueCoInvestigators =
|
||||||
new HashSet<Collaborator>(allCoAuthorsWithKnownAuthorshipYears);
|
new HashSet<Collaborator>(allCoAuthorsWithKnownAuthorshipYears);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Total publications will also consider publications that have no year associated with
|
* Total publications will also consider publications that have no year associated with
|
||||||
* them. Hence.
|
* them. Hence.
|
||||||
* */
|
* */
|
||||||
Integer unknownYearCoauthors = 0;
|
Integer unknownYearCoauthors = 0;
|
||||||
if (yearToUniqueCoauthors.get(VOConstants.DEFAULT_PUBLICATION_YEAR) != null) {
|
if (yearToUniqueCoauthors.get(VOConstants.DEFAULT_PUBLICATION_YEAR) != null) {
|
||||||
unknownYearCoauthors = yearToUniqueCoauthors
|
unknownYearCoauthors = yearToUniqueCoauthors
|
||||||
.get(VOConstants.DEFAULT_PUBLICATION_YEAR).size();
|
.get(VOConstants.DEFAULT_PUBLICATION_YEAR).size();
|
||||||
|
|
||||||
totalUniqueCoInvestigators.addAll(
|
totalUniqueCoInvestigators.addAll(
|
||||||
yearToUniqueCoauthors.get(VOConstants.DEFAULT_GRANT_YEAR));
|
yearToUniqueCoauthors.get(VOConstants.DEFAULT_GRANT_YEAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
sparklineData.setUnknownYearPublications(unknownYearCoauthors);
|
sparklineData.setUnknownYearPublications(unknownYearCoauthors);
|
||||||
|
|
||||||
sparklineData.setTotalCollaborationshipCount(totalUniqueCoInvestigators.size());
|
sparklineData.setTotalCollaborationshipCount(totalUniqueCoInvestigators.size());
|
||||||
|
|
||||||
if (providedVisContainerID != null) {
|
if (providedVisContainerID != null) {
|
||||||
visContainerID = providedVisContainerID;
|
visContainerID = providedVisContainerID;
|
||||||
} else {
|
} else {
|
||||||
visContainerID = DEFAULT_VISCONTAINER_DIV_ID;
|
visContainerID = DEFAULT_VISCONTAINER_DIV_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
sparklineData.setVisContainerDivID(visContainerID);
|
sparklineData.setVisContainerDivID(visContainerID);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* By default these represents the range of the rendered sparks. Only in case of
|
* By default these represents the range of the rendered sparks. Only in case of
|
||||||
* "short" sparkline mode we will set the Earliest RenderedPublication year to
|
* "short" sparkline mode we will set the Earliest RenderedPublication year to
|
||||||
* "currentYear - 10".
|
* "currentYear - 10".
|
||||||
* */
|
* */
|
||||||
sparklineData.setEarliestYearConsidered(minPubYearConsidered);
|
sparklineData.setEarliestYearConsidered(minPubYearConsidered);
|
||||||
sparklineData.setEarliestRenderedPublicationYear(minPublishedYear);
|
sparklineData.setEarliestRenderedPublicationYear(minPublishedYear);
|
||||||
sparklineData.setLatestRenderedPublicationYear(currentYear);
|
sparklineData.setLatestRenderedPublicationYear(currentYear);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The Full Sparkline will be rendered by default. Only if the url has specific mention of
|
* The Full Sparkline will be rendered by default. Only if the url has specific mention of
|
||||||
* SHORT_SPARKLINE_MODE_KEY then we render the short sparkline and not otherwise.
|
* SHORT_SPARKLINE_MODE_KEY then we render the short sparkline and not otherwise.
|
||||||
* */
|
* */
|
||||||
if (VisualizationFrameworkConstants.SHORT_SPARKLINE_VIS_MODE.equalsIgnoreCase(visMode)) {
|
if (VisualizationFrameworkConstants.SHORT_SPARKLINE_VIS_MODE.equalsIgnoreCase(visMode)) {
|
||||||
|
|
||||||
sparklineData.setEarliestRenderedPublicationYear(shortSparkMinYear);
|
sparklineData.setEarliestRenderedPublicationYear(shortSparkMinYear);
|
||||||
sparklineData.setShortVisMode(true);
|
sparklineData.setShortVisMode(true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sparklineData.setShortVisMode(false);
|
sparklineData.setShortVisMode(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yearToUniqueCoauthors.size() > 0) {
|
if (yearToUniqueCoauthors.size() > 0) {
|
||||||
|
|
||||||
sparklineData.setFullTimelineNetworkLink(
|
sparklineData.setFullTimelineNetworkLink(
|
||||||
UtilityFunctions.getCollaboratorshipNetworkLink(
|
UtilityFunctions.getCollaboratorshipNetworkLink(
|
||||||
individualURI,
|
individualURI,
|
||||||
VisualizationFrameworkConstants.PERSON_LEVEL_VIS,
|
VisualizationFrameworkConstants.PERSON_LEVEL_VIS,
|
||||||
VisualizationFrameworkConstants.COAUTHOR_VIS_MODE));
|
VisualizationFrameworkConstants.COAUTHOR_VIS_MODE));
|
||||||
|
|
||||||
sparklineData.setDownloadDataLink(
|
sparklineData.setDownloadDataLink(
|
||||||
UtilityFunctions.getCSVDownloadURL(
|
UtilityFunctions.getCSVDownloadURL(
|
||||||
individualURI,
|
individualURI,
|
||||||
VisualizationFrameworkConstants.COAUTHORSHIP_VIS,
|
VisualizationFrameworkConstants.COAUTHORSHIP_VIS,
|
||||||
VisualizationFrameworkConstants.COAUTHORS_COUNT_PER_YEAR_VIS_MODE));
|
VisualizationFrameworkConstants.COAUTHORS_COUNT_PER_YEAR_VIS_MODE));
|
||||||
|
|
||||||
Map<String, Integer> yearToUniqueCoauthorsCount = new HashMap<String, Integer>();
|
Map<String, Integer> yearToUniqueCoauthorsCount = new HashMap<String, Integer>();
|
||||||
|
|
||||||
for (Map.Entry<String, Set<Collaborator>> currentYearToCoAuthors
|
for (Map.Entry<String, Set<Collaborator>> currentYearToCoAuthors
|
||||||
: yearToUniqueCoauthors.entrySet()) {
|
: yearToUniqueCoauthors.entrySet()) {
|
||||||
yearToUniqueCoauthorsCount.put(currentYearToCoAuthors.getKey(),
|
yearToUniqueCoauthorsCount.put(currentYearToCoAuthors.getKey(),
|
||||||
currentYearToCoAuthors.getValue().size());
|
currentYearToCoAuthors.getValue().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
sparklineData.setYearToActivityCount(yearToUniqueCoauthorsCount);
|
sparklineData.setYearToActivityCount(yearToUniqueCoauthorsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sparklineData;
|
return sparklineData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SparklineData getValueObjectContainer() {
|
public SparklineData getValueObjectContainer() {
|
||||||
return this.sparklineParameterVO;
|
return this.sparklineParameterVO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,169 +27,169 @@ public class CoAuthorshipData extends CollaborationData {
|
||||||
public Set<Map<String, String>> initializeEdgeSchema() {
|
public Set<Map<String, String>> initializeEdgeSchema() {
|
||||||
|
|
||||||
Set<Map<String, String>> edgeSchema = new HashSet<Map<String, String>>();
|
Set<Map<String, String>> edgeSchema = new HashSet<Map<String, String>>();
|
||||||
|
|
||||||
Map<String, String> schemaAttributes = new LinkedHashMap<String, String>();
|
Map<String, String> schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "collaborator1");
|
schemaAttributes.put("id", "collaborator1");
|
||||||
schemaAttributes.put("for", "edge");
|
schemaAttributes.put("for", "edge");
|
||||||
schemaAttributes.put("attr.name", "collaborator1");
|
schemaAttributes.put("attr.name", "collaborator1");
|
||||||
schemaAttributes.put("attr.type", "string");
|
schemaAttributes.put("attr.type", "string");
|
||||||
|
|
||||||
edgeSchema.add(schemaAttributes);
|
edgeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "collaborator2");
|
schemaAttributes.put("id", "collaborator2");
|
||||||
schemaAttributes.put("for", "edge");
|
schemaAttributes.put("for", "edge");
|
||||||
schemaAttributes.put("attr.name", "collaborator2");
|
schemaAttributes.put("attr.name", "collaborator2");
|
||||||
schemaAttributes.put("attr.type", "string");
|
schemaAttributes.put("attr.type", "string");
|
||||||
|
|
||||||
edgeSchema.add(schemaAttributes);
|
edgeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "number_of_coauthored_works");
|
schemaAttributes.put("id", "number_of_coauthored_works");
|
||||||
schemaAttributes.put("for", "edge");
|
schemaAttributes.put("for", "edge");
|
||||||
schemaAttributes.put("attr.name", "number_of_coauthored_works");
|
schemaAttributes.put("attr.name", "number_of_coauthored_works");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
edgeSchema.add(schemaAttributes);
|
edgeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "earliest_collaboration");
|
schemaAttributes.put("id", "earliest_collaboration");
|
||||||
schemaAttributes.put("for", "edge");
|
schemaAttributes.put("for", "edge");
|
||||||
schemaAttributes.put("attr.name", "earliest_collaboration");
|
schemaAttributes.put("attr.name", "earliest_collaboration");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
edgeSchema.add(schemaAttributes);
|
edgeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "num_earliest_collaboration");
|
schemaAttributes.put("id", "num_earliest_collaboration");
|
||||||
schemaAttributes.put("for", "edge");
|
schemaAttributes.put("for", "edge");
|
||||||
schemaAttributes.put("attr.name", "num_earliest_collaboration");
|
schemaAttributes.put("attr.name", "num_earliest_collaboration");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
edgeSchema.add(schemaAttributes);
|
edgeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "latest_collaboration");
|
schemaAttributes.put("id", "latest_collaboration");
|
||||||
schemaAttributes.put("for", "edge");
|
schemaAttributes.put("for", "edge");
|
||||||
schemaAttributes.put("attr.name", "latest_collaboration");
|
schemaAttributes.put("attr.name", "latest_collaboration");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
edgeSchema.add(schemaAttributes);
|
edgeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "num_latest_collaboration");
|
schemaAttributes.put("id", "num_latest_collaboration");
|
||||||
schemaAttributes.put("for", "edge");
|
schemaAttributes.put("for", "edge");
|
||||||
schemaAttributes.put("attr.name", "num_latest_collaboration");
|
schemaAttributes.put("attr.name", "num_latest_collaboration");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
edgeSchema.add(schemaAttributes);
|
edgeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "num_unknown_collaboration");
|
schemaAttributes.put("id", "num_unknown_collaboration");
|
||||||
schemaAttributes.put("for", "edge");
|
schemaAttributes.put("for", "edge");
|
||||||
schemaAttributes.put("attr.name", "num_unknown_collaboration");
|
schemaAttributes.put("attr.name", "num_unknown_collaboration");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
edgeSchema.add(schemaAttributes);
|
edgeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
return edgeSchema;
|
return edgeSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Set<Map<String, String>> initializeNodeSchema() {
|
public Set<Map<String, String>> initializeNodeSchema() {
|
||||||
|
|
||||||
Set<Map<String, String>> nodeSchema = new HashSet<Map<String, String>>();
|
Set<Map<String, String>> nodeSchema = new HashSet<Map<String, String>>();
|
||||||
|
|
||||||
Map<String, String> schemaAttributes = new LinkedHashMap<String, String>();
|
Map<String, String> schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "url");
|
schemaAttributes.put("id", "url");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "url");
|
schemaAttributes.put("attr.name", "url");
|
||||||
schemaAttributes.put("attr.type", "string");
|
schemaAttributes.put("attr.type", "string");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "label");
|
schemaAttributes.put("id", "label");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "label");
|
schemaAttributes.put("attr.name", "label");
|
||||||
schemaAttributes.put("attr.type", "string");
|
schemaAttributes.put("attr.type", "string");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "profile_url");
|
schemaAttributes.put("id", "profile_url");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "profile_url");
|
schemaAttributes.put("attr.name", "profile_url");
|
||||||
schemaAttributes.put("attr.type", "string");
|
schemaAttributes.put("attr.type", "string");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "number_of_authored_works");
|
schemaAttributes.put("id", "number_of_authored_works");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "number_of_authored_works");
|
schemaAttributes.put("attr.name", "number_of_authored_works");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "earliest_publication");
|
schemaAttributes.put("id", "earliest_publication");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "earliest_publication");
|
schemaAttributes.put("attr.name", "earliest_publication");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "num_earliest_publication");
|
schemaAttributes.put("id", "num_earliest_publication");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "num_earliest_publication");
|
schemaAttributes.put("attr.name", "num_earliest_publication");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "latest_publication");
|
schemaAttributes.put("id", "latest_publication");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "latest_publication");
|
schemaAttributes.put("attr.name", "latest_publication");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "num_latest_publication");
|
schemaAttributes.put("id", "num_latest_publication");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "num_latest_publication");
|
schemaAttributes.put("attr.name", "num_latest_publication");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "num_unknown_publication");
|
schemaAttributes.put("id", "num_unknown_publication");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "num_unknown_publication");
|
schemaAttributes.put("attr.name", "num_unknown_publication");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
|
|
||||||
return nodeSchema;
|
return nodeSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,169 +27,169 @@ public class CoInvestigationData extends CollaborationData {
|
||||||
public Set<Map<String, String>> initializeEdgeSchema() {
|
public Set<Map<String, String>> initializeEdgeSchema() {
|
||||||
|
|
||||||
Set<Map<String, String>> edgeSchema = new HashSet<Map<String, String>>();
|
Set<Map<String, String>> edgeSchema = new HashSet<Map<String, String>>();
|
||||||
|
|
||||||
Map<String, String> schemaAttributes = new LinkedHashMap<String, String>();
|
Map<String, String> schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "collaborator1");
|
schemaAttributes.put("id", "collaborator1");
|
||||||
schemaAttributes.put("for", "edge");
|
schemaAttributes.put("for", "edge");
|
||||||
schemaAttributes.put("attr.name", "collaborator1");
|
schemaAttributes.put("attr.name", "collaborator1");
|
||||||
schemaAttributes.put("attr.type", "string");
|
schemaAttributes.put("attr.type", "string");
|
||||||
|
|
||||||
edgeSchema.add(schemaAttributes);
|
edgeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "collaborator2");
|
schemaAttributes.put("id", "collaborator2");
|
||||||
schemaAttributes.put("for", "edge");
|
schemaAttributes.put("for", "edge");
|
||||||
schemaAttributes.put("attr.name", "collaborator2");
|
schemaAttributes.put("attr.name", "collaborator2");
|
||||||
schemaAttributes.put("attr.type", "string");
|
schemaAttributes.put("attr.type", "string");
|
||||||
|
|
||||||
edgeSchema.add(schemaAttributes);
|
edgeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "number_of_coinvestigated_grants");
|
schemaAttributes.put("id", "number_of_coinvestigated_grants");
|
||||||
schemaAttributes.put("for", "edge");
|
schemaAttributes.put("for", "edge");
|
||||||
schemaAttributes.put("attr.name", "number_of_coinvestigated_grants");
|
schemaAttributes.put("attr.name", "number_of_coinvestigated_grants");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
edgeSchema.add(schemaAttributes);
|
edgeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "earliest_collaboration");
|
schemaAttributes.put("id", "earliest_collaboration");
|
||||||
schemaAttributes.put("for", "edge");
|
schemaAttributes.put("for", "edge");
|
||||||
schemaAttributes.put("attr.name", "earliest_collaboration");
|
schemaAttributes.put("attr.name", "earliest_collaboration");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
edgeSchema.add(schemaAttributes);
|
edgeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "num_earliest_collaboration");
|
schemaAttributes.put("id", "num_earliest_collaboration");
|
||||||
schemaAttributes.put("for", "edge");
|
schemaAttributes.put("for", "edge");
|
||||||
schemaAttributes.put("attr.name", "num_earliest_collaboration");
|
schemaAttributes.put("attr.name", "num_earliest_collaboration");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
edgeSchema.add(schemaAttributes);
|
edgeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "latest_collaboration");
|
schemaAttributes.put("id", "latest_collaboration");
|
||||||
schemaAttributes.put("for", "edge");
|
schemaAttributes.put("for", "edge");
|
||||||
schemaAttributes.put("attr.name", "latest_collaboration");
|
schemaAttributes.put("attr.name", "latest_collaboration");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
edgeSchema.add(schemaAttributes);
|
edgeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "num_latest_collaboration");
|
schemaAttributes.put("id", "num_latest_collaboration");
|
||||||
schemaAttributes.put("for", "edge");
|
schemaAttributes.put("for", "edge");
|
||||||
schemaAttributes.put("attr.name", "num_latest_collaboration");
|
schemaAttributes.put("attr.name", "num_latest_collaboration");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
edgeSchema.add(schemaAttributes);
|
edgeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "num_unknown_collaboration");
|
schemaAttributes.put("id", "num_unknown_collaboration");
|
||||||
schemaAttributes.put("for", "edge");
|
schemaAttributes.put("for", "edge");
|
||||||
schemaAttributes.put("attr.name", "num_unknown_collaboration");
|
schemaAttributes.put("attr.name", "num_unknown_collaboration");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
edgeSchema.add(schemaAttributes);
|
edgeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
return edgeSchema;
|
return edgeSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Set<Map<String, String>> initializeNodeSchema() {
|
public Set<Map<String, String>> initializeNodeSchema() {
|
||||||
|
|
||||||
Set<Map<String, String>> nodeSchema = new HashSet<Map<String, String>>();
|
Set<Map<String, String>> nodeSchema = new HashSet<Map<String, String>>();
|
||||||
|
|
||||||
Map<String, String> schemaAttributes = new LinkedHashMap<String, String>();
|
Map<String, String> schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "url");
|
schemaAttributes.put("id", "url");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "url");
|
schemaAttributes.put("attr.name", "url");
|
||||||
schemaAttributes.put("attr.type", "string");
|
schemaAttributes.put("attr.type", "string");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "label");
|
schemaAttributes.put("id", "label");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "label");
|
schemaAttributes.put("attr.name", "label");
|
||||||
schemaAttributes.put("attr.type", "string");
|
schemaAttributes.put("attr.type", "string");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "profile_url");
|
schemaAttributes.put("id", "profile_url");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "profile_url");
|
schemaAttributes.put("attr.name", "profile_url");
|
||||||
schemaAttributes.put("attr.type", "string");
|
schemaAttributes.put("attr.type", "string");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "number_of_investigated_grants");
|
schemaAttributes.put("id", "number_of_investigated_grants");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "number_of_investigated_grants");
|
schemaAttributes.put("attr.name", "number_of_investigated_grants");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "earliest_grant");
|
schemaAttributes.put("id", "earliest_grant");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "earliest_grant");
|
schemaAttributes.put("attr.name", "earliest_grant");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "num_earliest_grant");
|
schemaAttributes.put("id", "num_earliest_grant");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "num_earliest_grant");
|
schemaAttributes.put("attr.name", "num_earliest_grant");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "latest_grant");
|
schemaAttributes.put("id", "latest_grant");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "latest_grant");
|
schemaAttributes.put("attr.name", "latest_grant");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "num_latest_grant");
|
schemaAttributes.put("id", "num_latest_grant");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "num_latest_grant");
|
schemaAttributes.put("attr.name", "num_latest_grant");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
schemaAttributes = new LinkedHashMap<String, String>();
|
schemaAttributes = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
schemaAttributes.put("id", "num_unknown_grant");
|
schemaAttributes.put("id", "num_unknown_grant");
|
||||||
schemaAttributes.put("for", "node");
|
schemaAttributes.put("for", "node");
|
||||||
schemaAttributes.put("attr.name", "num_unknown_grant");
|
schemaAttributes.put("attr.name", "num_unknown_grant");
|
||||||
schemaAttributes.put("attr.type", "int");
|
schemaAttributes.put("attr.type", "int");
|
||||||
|
|
||||||
nodeSchema.add(schemaAttributes);
|
nodeSchema.add(schemaAttributes);
|
||||||
|
|
||||||
|
|
||||||
return nodeSchema;
|
return nodeSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils;
|
package edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaboration;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaboration;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Comparator is used to sort the edges based on their IDs in ascending order.
|
* This Comparator is used to sort the edges based on their IDs in ascending order.
|
||||||
* @author cdtank
|
* @author cdtank
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CollaborationComparator implements Comparator<Collaboration> {
|
public class CollaborationComparator implements Comparator<Collaboration> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(Collaboration arg0, Collaboration arg1) {
|
public int compare(Collaboration arg0, Collaboration arg1) {
|
||||||
return arg0.getCollaborationID() - arg1.getCollaborationID();
|
return arg0.getCollaborationID() - arg1.getCollaborationID();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,73 +1,73 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils;
|
package edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaboration;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaboration;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaborator;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaborator;
|
||||||
|
|
||||||
public abstract class CollaborationData {
|
public abstract class CollaborationData {
|
||||||
|
|
||||||
private Set<Collaborator> collaborators;
|
private Set<Collaborator> collaborators;
|
||||||
private Set<Collaboration> collaborations;
|
private Set<Collaboration> collaborations;
|
||||||
private Collaborator egoCollaborator;
|
private Collaborator egoCollaborator;
|
||||||
private Set<Map<String, String>> NODE_SCHEMA;
|
private Set<Map<String, String>> NODE_SCHEMA;
|
||||||
private Set<Map<String, String>> EDGE_SCHEMA;
|
private Set<Map<String, String>> EDGE_SCHEMA;
|
||||||
|
|
||||||
private Date builtFromCacheTime = null;
|
private Date builtFromCacheTime = null;
|
||||||
|
|
||||||
public CollaborationData(Collaborator egoCollaborator,
|
public CollaborationData(Collaborator egoCollaborator,
|
||||||
Set<Collaborator> collaborators,
|
Set<Collaborator> collaborators,
|
||||||
Set<Collaboration> collaborations) {
|
Set<Collaboration> collaborations) {
|
||||||
this.egoCollaborator = egoCollaborator;
|
this.egoCollaborator = egoCollaborator;
|
||||||
this.collaborators = collaborators;
|
this.collaborators = collaborators;
|
||||||
this.collaborations = collaborations;
|
this.collaborations = collaborations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getBuiltFromCacheTime() { return builtFromCacheTime; }
|
public Date getBuiltFromCacheTime() { return builtFromCacheTime; }
|
||||||
|
|
||||||
public Set<Collaborator> getCollaborators() {
|
public Set<Collaborator> getCollaborators() {
|
||||||
return collaborators;
|
return collaborators;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Collaboration> getCollaborations() {
|
public Set<Collaboration> getCollaborations() {
|
||||||
return collaborations;
|
return collaborations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collaborator getEgoCollaborator() {
|
public Collaborator getEgoCollaborator() {
|
||||||
return egoCollaborator;
|
return egoCollaborator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Node Schema for graphML
|
* Node Schema for graphML
|
||||||
* */
|
* */
|
||||||
public Set<Map<String, String>> getNodeSchema() {
|
public Set<Map<String, String>> getNodeSchema() {
|
||||||
|
|
||||||
if (NODE_SCHEMA == null) {
|
if (NODE_SCHEMA == null) {
|
||||||
NODE_SCHEMA = initializeNodeSchema();
|
NODE_SCHEMA = initializeNodeSchema();
|
||||||
}
|
}
|
||||||
|
|
||||||
return NODE_SCHEMA;
|
return NODE_SCHEMA;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Edge Schema for graphML
|
* Edge Schema for graphML
|
||||||
* */
|
* */
|
||||||
public Set<Map<String, String>> getEdgeSchema() {
|
public Set<Map<String, String>> getEdgeSchema() {
|
||||||
|
|
||||||
if (EDGE_SCHEMA == null) {
|
if (EDGE_SCHEMA == null) {
|
||||||
EDGE_SCHEMA = initializeEdgeSchema();
|
EDGE_SCHEMA = initializeEdgeSchema();
|
||||||
}
|
}
|
||||||
|
|
||||||
return EDGE_SCHEMA;
|
return EDGE_SCHEMA;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBuiltFromCacheTime(Date time) { this.builtFromCacheTime = time; }
|
public void setBuiltFromCacheTime(Date time) { this.builtFromCacheTime = time; }
|
||||||
|
|
||||||
abstract Set<Map<String, String>> initializeEdgeSchema();
|
abstract Set<Map<String, String>> initializeEdgeSchema();
|
||||||
|
|
||||||
abstract Set<Map<String, String>> initializeNodeSchema();
|
abstract Set<Map<String, String>> initializeNodeSchema();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils;
|
package edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaborator;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaborator;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Comparator is used to sort the nodes based on their IDs in ascending order.
|
* This Comparator is used to sort the nodes based on their IDs in ascending order.
|
||||||
* @author cdtank
|
* @author cdtank
|
||||||
*/
|
*/
|
||||||
public class CollaboratorComparator implements Comparator<Collaborator> {
|
public class CollaboratorComparator implements Comparator<Collaborator> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(Collaborator arg0, Collaborator arg1) {
|
public int compare(Collaborator arg0, Collaborator arg1) {
|
||||||
return arg0.getCollaboratorID() - arg1.getCollaboratorID();
|
return arg0.getCollaboratorID() - arg1.getCollaboratorID();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue