Merge branch 'develop' of git://github.com/vivo-project/VIVO into develop

This commit is contained in:
Jim Blake 2017-11-08 13:53:33 -05:00
commit e9e2bad1cd
240 changed files with 4246 additions and 8979 deletions

View file

@ -17,24 +17,25 @@ https://wiki.duraspace.org/display/VIVO/
### Installation Instructions ### Installation Instructions
Installation instructions for the latest release can be found at this location on the wiki: Installation instructions for the latest release can be found at this location on the wiki:
https://wiki.duraspace.org/display/VIVODOC19x/Installing+VIVO#InstallingVIVO-Git https://wiki.duraspace.org/display/VIVODOC19x/Installing+VIVO#InstallingVIVO-GitHubInstallingfromGitHub
## Contact us ## Contact us
There are several ways to contact the VIVO community. There are several ways to contact the VIVO community.
Whatever your interest, we would be pleased to hear from you. Whatever your interest, we would be pleased to hear from you.
#### Contact form ### Contact form
http://vivoweb.org/support/user-feedback http://vivoweb.org/support/user-feedback
#### Mailing lists ### Mailing lists
##### [vivo-all](https://groups.google.com/forum/#!forum/vivo-all)
#### [vivo-all](https://groups.google.com/forum/#!forum/vivo-all)
This updates list provides news to the VIVO community of interest to all. This updates list provides news to the VIVO community of interest to all.
##### [vivo-community](https://groups.google.com/forum/#!forum/vivo-community) #### [vivo-community](https://groups.google.com/forum/#!forum/vivo-community)
Join the VIVO community! Here you'll find non-technical discussion regarding participation, the VIVO Join the VIVO community! Here you'll find non-technical discussion regarding participation, the VIVO
conference, policy, project management, outreach, and engagement. conference, policy, project management, outreach, and engagement.
##### [vivo-tech](https://groups.google.com/forum/#!forum/vivo-tech) #### [vivo-tech](https://groups.google.com/forum/#!forum/vivo-tech)
The best place to get your hands dirty in the VIVO Project. The best place to get your hands dirty in the VIVO Project.
Developers and implementers frequent this list to get the latest on feature design, Developers and implementers frequent this list to get the latest on feature design,
development, implementation, and testing. development, implementation, and testing.

4
api/findbugs.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
mvn -Dfindbugs.maxHeap=4096 -Dfindbugs.timeout=6000000 compile findbugs:findbugs findbugs:gui

View file

@ -7,13 +7,13 @@
<groupId>org.vivoweb</groupId> <groupId>org.vivoweb</groupId>
<artifactId>vivo-api</artifactId> <artifactId>vivo-api</artifactId>
<version>1.10.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<parent> <parent>
<groupId>org.vivoweb</groupId> <groupId>org.vivoweb</groupId>
<artifactId>vivo-project</artifactId> <artifactId>vivo-project</artifactId>
<version>1.10.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>..</relativePath> <relativePath>..</relativePath>
</parent> </parent>
@ -30,20 +30,25 @@
<type>pom</type> <type>pom</type>
</dependency> </dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>fluent-hc</artifactId>
<version>4.5.3</version>
</dependency>
<dependency> <dependency>
<groupId>com.itextpdf</groupId> <groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId> <artifactId>itextpdf</artifactId>
<version>5.0.6</version> <version>5.5.12</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId> <artifactId>spring-beans</artifactId>
<version>2.5.6</version> <version>4.3.11.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId> <artifactId>spring-context</artifactId>
<version>2.5.6</version> <version>4.3.11.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
@ -52,15 +57,15 @@
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.vivoweb.dependencies</groupId> <groupId>org.vivoweb</groupId>
<artifactId>orcid-api-client</artifactId> <artifactId>orcid-api-client</artifactId>
<version>0.2</version> <version>0.6.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId> <artifactId>javax.servlet-api</artifactId>
<version>2.5</version> <version>3.1.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -71,7 +76,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.xml</groupId> <groupId>javax.xml</groupId>
<artifactId>jaxrpc</artifactId> <artifactId>jaxrpc-api</artifactId>
<version>1.1</version> <version>1.1</version>
</dependency> </dependency>
@ -88,4 +93,26 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.5</version>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
<failOnError>true</failOnError>
<plugins>
<plugin>
<groupId>com.h3xstream.findsecbugs</groupId>
<artifactId>findsecbugs-plugin</artifactId>
<version>LATEST</version> <!-- Auto-update to the latest stable -->
</plugin>
</plugins>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

View file

@ -58,9 +58,9 @@ public class AgrovocService implements ExternalConceptService {
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://aims.fao.org/skosmos/rest/v1/"; protected final String conceptSkosMosBase = "http://artemide.art.uniroma2.it:8081/skosmos/rest/v1/";
protected final String conceptsSkosMosSearch = conceptSkosMosBase + "search?"; protected final String conceptsSkosMosSearch = conceptSkosMosBase + "search?";
protected final String conceptSkosMosURL = conceptSkosMosBase + "/agrovoc/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<Concept>(); List<Concept> conceptList = new ArrayList<Concept>();
@ -145,7 +145,7 @@ public class AgrovocService implements ExternalConceptService {
public List<Concept> processResults(String term) throws Exception { public List<Concept> processResults(String term) throws Exception {
@ -190,7 +190,7 @@ public class AgrovocService implements ExternalConceptService {
} }
protected String getAgrovocTermCode(String rdf) throws Exception { protected String getAgrovocTermCode(String rdf) throws Exception {
String termcode = new String(); String termcode = "";
try { try {
Document doc = XMLUtils.parse(rdf); Document doc = XMLUtils.parse(rdf);
NodeList nodes = doc.getElementsByTagName("hasCodeAgrovoc"); NodeList nodes = doc.getElementsByTagName("hasCodeAgrovoc");
@ -199,13 +199,7 @@ public class AgrovocService implements ExternalConceptService {
termcode = node.getTextContent(); termcode = node.getTextContent();
} }
} catch (SAXException e) { } catch (SAXException | IOException | ParserConfigurationException e) {
// e.printStackTrace();
throw e;
} catch (ParserConfigurationException e) {
// e.printStackTrace();
throw e;
} catch (IOException e) {
// e.printStackTrace(); // e.printStackTrace();
throw e; throw e;
} }
@ -213,7 +207,7 @@ public class AgrovocService implements ExternalConceptService {
} }
protected String getConceptURIFromRDF(String rdf) { protected String getConceptURIFromRDF(String rdf) {
String conceptUri = new String(); 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");
@ -222,13 +216,7 @@ public class AgrovocService implements ExternalConceptService {
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 e) { } catch (IOException | ParserConfigurationException | SAXException e) {
e.printStackTrace();
System.err.println("rdf: " + rdf);
} catch (SAXException e) {
e.printStackTrace();
System.err.println("rdf: " + rdf);
} catch (ParserConfigurationException e) {
e.printStackTrace(); e.printStackTrace();
System.err.println("rdf: " + rdf); System.err.println("rdf: " + rdf);
} }
@ -254,13 +242,7 @@ public class AgrovocService implements ExternalConceptService {
} }
} catch (IOException e) { } catch (IOException | ParserConfigurationException | SAXException e) {
e.printStackTrace();
System.err.println("rdf: " + rdf);
} catch (SAXException e) {
e.printStackTrace();
System.err.println("rdf: " + rdf);
} catch (ParserConfigurationException e) {
e.printStackTrace(); e.printStackTrace();
System.err.println("rdf: " + rdf); System.err.println("rdf: " + rdf);
} }
@ -270,7 +252,7 @@ public class AgrovocService implements ExternalConceptService {
protected String getDbpediaDescription(String uri) throws Exception { protected String getDbpediaDescription(String uri) throws Exception {
String descriptionSource = " (Source: DBpedia)"; String descriptionSource = " (Source: DBpedia)";
String description = new String(); 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"
@ -329,7 +311,7 @@ public class AgrovocService implements ExternalConceptService {
* @param uri The URI * @param uri The URI
*/ */
protected String stripConceptId(String uri) { protected String stripConceptId(String uri) {
String conceptId = new String(); 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;

View file

@ -150,7 +150,7 @@ public class GemetService implements ExternalConceptService {
if (obj.has(key)) { if (obj.has(key)) {
return obj.get(key).asText(); return obj.get(key).asText();
} else { } else {
return new String(""); return "";
} }
} }
@ -160,7 +160,7 @@ public class GemetService implements ExternalConceptService {
* @throws Exception * @throws Exception
*/ */
protected String getAvailableLangs(String concept_uri) throws Exception { protected String getAvailableLangs(String concept_uri) throws Exception {
String result = new String(); String result = "";
String serviceUrl = GemetWS_address + "getAvailableLanguages" + String serviceUrl = GemetWS_address + "getAvailableLanguages" +
"?concept_uri=" + concept_uri; "?concept_uri=" + concept_uri;
try { try {
@ -177,7 +177,7 @@ public class GemetService implements ExternalConceptService {
* @throws Exception * @throws Exception
*/ */
protected String getConcept(String concept_uri) throws Exception { protected String getConcept(String concept_uri) throws Exception {
String result = new String(); String result = "";
String serviceUrl = GemetWS_address + "getConcept" + String serviceUrl = GemetWS_address + "getConcept" +
"?concept_uri=" + concept_uri + "?concept_uri=" + concept_uri +
"&language=en"; "&language=en";
@ -196,20 +196,27 @@ public class GemetService implements ExternalConceptService {
* @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 = new String(); String result = "";
String property_uri = new String(); String property_uri = "";
if (property.equals("definition")) { switch (property) {
property_uri = definitionUri; case "definition":
} else if (property.equals("preferredLabel")) { property_uri = definitionUri;
property_uri = prefLabelUri; break;
} else if (property.equals("scopeNote")) { case "preferredLabel":
property_uri = scopeNoteUri; property_uri = prefLabelUri;
} else if (property.equals("nonPreferredLabels")) { break;
property_uri = altLabelUri; case "scopeNote":
} else if (property.equals("example")) { property_uri = scopeNoteUri;
property_uri = exampleUri; break;
} else if (property.equals("acronymLabel")) { case "nonPreferredLabels":
property_uri = acronymLabelUri; property_uri = altLabelUri;
break;
case "example":
property_uri = exampleUri;
break;
case "acronymLabel":
property_uri = acronymLabelUri;
break;
} }
String serviceUrl = GemetWS_address + "getAllTranslationsForConcept" + String serviceUrl = GemetWS_address + "getAllTranslationsForConcept" +
@ -234,14 +241,18 @@ public class GemetService implements ExternalConceptService {
* @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 = new String(); String result = "";
String relation_uri = new String(); String relation_uri = "";
if (relation.equals("broader")) { switch (relation) {
relation_uri = broaderUri; case "broader":
} else if (relation.equals("narrower")) { relation_uri = broaderUri;
relation_uri = narrowerUri; break;
} else if (relation.equals("related")) { case "narrower":
relation_uri = relatedUri; relation_uri = narrowerUri;
break;
case "related":
relation_uri = relatedUri;
break;
} }
String serviceUrl = GemetWS_address + "getRelatedConcepts" + String serviceUrl = GemetWS_address + "getRelatedConcepts" +
"?concept_uri=" + concept_uri + "?concept_uri=" + concept_uri +
@ -263,7 +274,7 @@ public class GemetService implements ExternalConceptService {
* @throws Exception * @throws Exception
*/ */
protected String getConceptsMatchingKeyword(String keyword) throws Exception { protected String getConceptsMatchingKeyword(String keyword) throws Exception {
String result = new String(); 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 +
@ -283,7 +294,7 @@ public class GemetService implements ExternalConceptService {
* @param url URI * @param url URI
*/ */
protected String getGemetResults(String url) throws Exception { protected String getGemetResults(String url) throws Exception {
String results = new String(); String results = "";
//System.out.println("url: "+url); //System.out.println("url: "+url);
try { try {
@ -310,7 +321,7 @@ public class GemetService implements ExternalConceptService {
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 = new String(); 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>();
@ -338,7 +349,7 @@ public class GemetService implements ExternalConceptService {
} }
protected String stripConceptId(String uri) { protected String stripConceptId(String uri) {
String conceptId = new String(); 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;

View file

@ -176,7 +176,7 @@ public class LCSHService implements ExternalConceptService {
protected List<String> getConceptURIFromXML(String rdf) { protected List<String> getConceptURIFromXML(String rdf) {
List<String> uris = new ArrayList<String>(); List<String> uris = new ArrayList<String>();
String conceptUri = new String(); String conceptUri = "";
try { try {
Document doc = XMLUtils.parse(rdf); Document doc = XMLUtils.parse(rdf);
NodeList nodes = doc.getElementsByTagName("entry"); NodeList nodes = doc.getElementsByTagName("entry");
@ -202,15 +202,10 @@ public class LCSHService implements ExternalConceptService {
uris.add(conceptUri); uris.add(conceptUri);
} }
} catch (IOException e) { } catch (IOException | ParserConfigurationException | SAXException e) {
log.error("error occurred in parsing " +rdf, e); log.error("error occurred in parsing " +rdf, e);
} catch (SAXException e) {
log.error("error occurred in parsing " +rdf, e);
} catch (ParserConfigurationException e) {
log.error("error occurred in parsing " +rdf, e);
} }
return uris; return uris;
} }
@ -222,7 +217,7 @@ public class LCSHService implements ExternalConceptService {
* @param uri URI * @param uri URI
*/ */
protected String stripConceptId(String uri) { protected String stripConceptId(String uri) {
String conceptId = new String(); 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;

View file

@ -2,13 +2,11 @@
package edu.cornell.mannlib.semservices.service.impl; package edu.cornell.mannlib.semservices.service.impl;
import java.io.BufferedReader; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStream;
import java.io.StringWriter;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
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;
@ -20,195 +18,212 @@ 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.client.fluent.Form;
import org.apache.http.client.fluent.Request;
import org.apache.http.client.utils.URIBuilder;
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 final String submissionUrl = "http://link.informatics.stonybrook.edu/MeaningLookup/MlServiceServlet?";
private static final String baseUri = "http://link.informatics.stonybrook.edu/umls/CUI/";
private static final String endpoint = "http://link.informatics.stonybrook.edu/sparql/";
private static final String schemeURI = "http://link.informatics.stonybrook.edu/umls";
@Override
public List<Concept> getConcepts(String term) throws Exception {
List<Concept> conceptList = new ArrayList<Concept>();
String results = null; private static String UTS_REST_API_URL = "https://uts-ws.nlm.nih.gov/rest";
String dataUrl = submissionUrl + "textToProcess=" private static String SEARCH_PATH = "/search/current";
+ URLEncoder.encode(term, "UTF-8") private static String SEARCH_PARAMETER = "string";
+ "&format=json"; private static String SEARCH_TYPE_PARAMETER = "searchType";
private static String SEARCH_TYPE = "rightTruncation";
private static String PAGE_SIZE_PARAMETER = "pageSize";
private static String RETURN_TYPE_PARAMETER = "returnIdType";
private static String RETURN_TYPE = "concept";
private static String TICKET_PARAMETER = "ticket";
try { private static String ticketGrantingTicketURL = null;
StringWriter sw = new StringWriter(); private static long lastUpdate = -1;
URL rss = new URL(dataUrl);
BufferedReader in = new BufferedReader(new InputStreamReader( private static String username = null;
rss.openStream())); private static String password = null;
String inputLine; private static String apikey = null;
while ((inputLine = in.readLine()) != null) {
sw.write(inputLine);
}
in.close();
results = sw.toString(); private static String pageSize = "50";
//System.out.println("results before processing: "+results);
conceptList = processOutput(results);
return conceptList;
} catch (Exception ex) { private static String UMLS_AUTH_USER_URL = "https://utslogin.nlm.nih.gov/cas/v1/tickets";
logger.error("error occurred in servlet", ex); private static String UMLS_AUTH_KEY_URL = "https://utslogin.nlm.nih.gov/cas/v1/api-key";
return null; private static String UTS_SERVICE_URL = "http://umlsks.nlm.nih.gov";
}
}
public List<Concept> processResults(String term) throws Exception { {
String results = null; if (username == null || apikey == null) {
String dataUrl = submissionUrl + "textToProcess=" final Properties properties = new Properties();
+ URLEncoder.encode(term, "UTF-8") + "&format=json"; try (InputStream stream = getClass().getResourceAsStream("/umls.properties")) {
properties.load(stream);
username = properties.getProperty("username");
password = properties.getProperty("password");
apikey = properties.getProperty("apikey");
try { String exPageSize = properties.getProperty("pagesize");
try {
StringWriter sw = new StringWriter(); if (!StringUtils.isEmpty(exPageSize)) {
URL rss = new URL(dataUrl); int iPageSize = Integer.parseInt(exPageSize, 10);
if (iPageSize > 5 && iPageSize < 200) {
BufferedReader in = new BufferedReader(new InputStreamReader(rss.openStream())); pageSize = Integer.toString(iPageSize, 10);
String inputLine; }
while ((inputLine = in.readLine()) != null) { }
sw.write(inputLine); } catch (Exception e) {
} }
in.close(); } catch (IOException e) {
results = sw.toString();
//System.out.println("results before processing: "+results);
List<Concept> conceptList = processOutput(results);
return conceptList;
} catch (Exception ex) {
logger.error("error occurred in servlet", ex);
return null;
}
}
/**
* @param uri URI
*/
public List<Concept> getConceptsByURIWithSparql(String uri)
throws Exception {
// deprecating this method...just return an empty list
List<Concept> conceptList = new ArrayList<Concept>();
return conceptList;
}
/**
* @param results Results to process
*/
private List<Concept> processOutput(String results) throws Exception {
List<Concept> conceptList = new ArrayList<Concept>();
List<String> bestMatchIdList = new ArrayList<String>();
String bestMatchId = new String();
boolean bestMatchFound = false;
boolean allFound = false;
try {
ObjectNode json = (ObjectNode) JacksonUtils.parseJson(results);
//System.out.println(json.toString());
if (json.has("Best Match")) {
bestMatchFound = true;
//System.out.println("Best Match");
ArrayNode bestMatchArray = (ArrayNode) json.get("Best Match");
int len = bestMatchArray.size();
if (len > 1) {
logger.debug("Found this many best matches: "+ len);
} }
int i; }
for (i = 0; i < len; i++) { }
ObjectNode o = (ObjectNode) bestMatchArray.get(i);
//System.out.println(o.toString());
Concept concept = new Concept();
concept.setDefinedBy(schemeURI);
concept.setBestMatch("true");
String cui = getJsonValue(o, "CUI");
bestMatchIdList.add(cui);
concept.setConceptId(cui); public boolean isConfigured() {
concept.setLabel(getJsonValue(o, "label")); return !(StringUtils.isEmpty(username) && StringUtils.isEmpty(apikey));
concept.setType(getJsonValue(o, "type")); }
concept.setDefinition(getJsonValue(o, "definition"));
concept.setUri(baseUri + cui); @Override
concept.setSchemeURI(schemeURI); public List<Concept> getConcepts(String term) throws Exception {
conceptList.add(concept); String ticket = getSingleUseTicket();
}
} List<Concept> conceptList = new ArrayList<Concept>();
if (json.has("All")) {
allFound = true; String results = null;
ArrayNode allArray = (ArrayNode) json.get("All");
try {
URIBuilder b = new URIBuilder(UTS_REST_API_URL + SEARCH_PATH);
b.addParameter(SEARCH_PARAMETER, term);
b.addParameter(RETURN_TYPE_PARAMETER, RETURN_TYPE);
b.addParameter(SEARCH_TYPE_PARAMETER, SEARCH_TYPE);
b.addParameter(PAGE_SIZE_PARAMETER, pageSize);
b.addParameter(TICKET_PARAMETER, ticket);
results = Request.Get(b.build())
.connectTimeout(3000)
.socketTimeout(3000)
.execute().returnContent().asString();
conceptList = processOutput(results);
return conceptList;
} catch (Exception ex) {
logger.error("error occurred in servlet", ex);
return null;
}
}
public List<Concept> processResults(String term) throws Exception {
return getConcepts(term);
}
/**
* @param uri URI
*/
public List<Concept> getConceptsByURIWithSparql(String uri) throws Exception {
// deprecating this method...just return an empty list
List<Concept> conceptList = new ArrayList<Concept>();
return conceptList;
}
/**
* @param results Results to process
*/
private List<Concept> processOutput(String results) throws Exception {
List<Concept> conceptList = new ArrayList<Concept>();
List<String> bestMatchIdList = new ArrayList<String>();
String bestMatchId = "";
try {
ObjectNode json = (ObjectNode) JacksonUtils.parseJson(results);
ArrayNode allArray = (ArrayNode) json.get("result").get("results");
int len = allArray.size(); int len = allArray.size();
//System.out.println("size of best match array: "+ len);
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);
//System.out.println(o.toString());
Concept concept = new Concept();
concept.setDefinedBy(schemeURI);
String cui = getJsonValue(o, "CUI");
concept.setConceptId(cui);
concept.setLabel(getJsonValue(o, "label")); Concept concept = new Concept();
concept.setType(getJsonValue(o, "type")); concept.setDefinedBy(UTS_SERVICE_URL);
concept.setDefinition(getJsonValue(o, "definition")); concept.setSchemeURI(UTS_SERVICE_URL);
concept.setUri(baseUri + cui);
concept.setSchemeURI(schemeURI); concept.setType(RETURN_TYPE);
// prevent duplicate concepts in list concept.setConceptId(getJsonValue(o, "ui"));
if (! bestMatchIdList.contains(cui)) { concept.setLabel(getJsonValue(o, "name"));
concept.setBestMatch("false"); concept.setUri(getJsonValue(o, "uri"));
conceptList.add(concept);
} concept.setBestMatch("false");
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 (! bestMatchFound && !allFound) {
// we did not get a bestMatch or All element
throw new ConceptsNotFoundException();
}
// if (conceptList.size() == 0) {
return conceptList; throw new ConceptsNotFoundException();
}
} //
return conceptList;
/** }
* 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 key Key to retrieve * Get a string from a json object or an empty string if there is no value for the given key
*/ *
protected String getJsonValue(ObjectNode obj, String key) { * @param obj JSON Object
if (obj.has(key)) { * @param key Key to retrieve
return obj.get(key).asText(); */
} else { protected String getJsonValue(ObjectNode obj, String key) {
return new String(""); if (obj.has(key)) {
} return obj.get(key).asText();
} } else {
return "";
}
}
protected String stripConceptId(String uri) {
String conceptId = "";
int lastslash = uri.lastIndexOf('/');
conceptId = uri.substring(lastslash + 1, uri.length());
return conceptId;
}
protected String stripConceptId(String uri) { private synchronized void getTicketGrantingTicket() {
String conceptId = new String(); if (StringUtils.isEmpty(username) && StringUtils.isEmpty(apikey)) {
int lastslash = uri.lastIndexOf('/'); throw new IllegalStateException("Unable to read umls.properties");
conceptId = uri.substring(lastslash + 1, uri.length()); }
return conceptId;
}
if (ticketGrantingTicketURL == null || lastUpdate + 28700000L < System.currentTimeMillis()) {
try {
if (!StringUtils.isEmpty(apikey)) {
ticketGrantingTicketURL = Request.Post(UMLS_AUTH_KEY_URL).useExpectContinue().version(HttpVersion.HTTP_1_1)
.bodyForm(Form.form().add("apikey", apikey).build())
.execute().returnResponse().getFirstHeader("location").getValue();
} else {
ticketGrantingTicketURL = Request.Post(UMLS_AUTH_USER_URL).useExpectContinue().version(HttpVersion.HTTP_1_1)
.bodyForm(Form.form().add("username", username).add("password", password).build())
.execute().returnResponse().getFirstHeader("location").getValue();
}
} catch (IOException e) {
throw new IllegalStateException("Unable to get ticket granting ticket.");
}
lastUpdate = System.currentTimeMillis();
}
}
private String getSingleUseTicket() {
getTicketGrantingTicket();
String ticket = "";
try {
ticket = Request.Post(ticketGrantingTicketURL).useExpectContinue().version(HttpVersion.HTTP_1_1)
.bodyForm(Form.form().add("service", UTS_SERVICE_URL).build())
.execute().returnContent().asString();
} catch (IOException e) {
throw new IllegalStateException("Unable to get ticket.");
}
return ticket;
}
} }

View file

@ -14,6 +14,9 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Exc
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 javax.servlet.annotation.WebServlet;
@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;

View file

@ -24,10 +24,12 @@ import edu.cornell.mannlib.vitro.webapp.controller.individual.IndividualRequestA
import edu.cornell.mannlib.vitro.webapp.controller.individual.IndividualRequestAnalyzer; import edu.cornell.mannlib.vitro.webapp.controller.individual.IndividualRequestAnalyzer;
import edu.cornell.mannlib.vitro.webapp.controller.individual.IndividualRequestInfo; import edu.cornell.mannlib.vitro.webapp.controller.individual.IndividualRequestInfo;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils; import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.VIVOIndividualTemplateModel;
import freemarker.ext.beans.BeansWrapper; import freemarker.ext.beans.BeansWrapper;
import freemarker.template.DefaultObjectWrapper; import freemarker.template.DefaultObjectWrapper;
import javax.servlet.annotation.WebServlet;
@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;

View file

@ -7,21 +7,16 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
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.json.JSONException;
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.RDFNode;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.ajax.VitroAjaxController;
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.jena.QueryUtils; import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
@ -65,11 +60,11 @@ public class GeoFocusMapLocations extends AbstractAjaxResponder {
} }
@Override @Override
public String prepareResponse() throws IOException, JSONException { public String prepareResponse() throws IOException {
try { try {
geoLocations = getGeoLocations(vreq); geoLocations = getGeoLocations(vreq);
String response = "["; 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 = "";
@ -112,18 +107,18 @@ public class GeoFocusMapLocations extends AbstractAjaxResponder {
+ "\",\"local\": \"" + "\",\"local\": \""
+ local + local
+ "\"}},"; + "\"}},";
response += tempStr; response.append(tempStr);
previousLabel = label; previousLabel = label;
} }
} }
if ( response.lastIndexOf(",") > 0 ) { if ( response.lastIndexOf(",") > 0 ) {
response = response.substring(0, response.lastIndexOf(",")); response = new StringBuilder(response.substring(0, response.lastIndexOf(",")));
} }
response += " ]"; response.append(" ]");
if ( log.isDebugEnabled() ) { if ( log.isDebugEnabled() ) {
log.debug(response); log.debug(response.toString());
} }
return response; return response.toString();
} catch (Exception e) { } catch (Exception e) {
log.error("Failed geographic focus locations", e); log.error("Failed geographic focus locations", e);
return EMPTY_RESPONSE; return EMPTY_RESPONSE;

View file

@ -2,27 +2,20 @@
package edu.cornell.mannlib.vitro.webapp.controller.ajax; package edu.cornell.mannlib.vitro.webapp.controller.ajax;
import java.io.IOException; import java.io.IOException;
import java.lang.Integer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
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.json.JSONException;
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.RDFNode;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.ajax.VitroAjaxController;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils; import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
public class GeoFocusResearcherCount extends AbstractAjaxResponder { public class GeoFocusResearcherCount extends AbstractAjaxResponder {
@ -44,19 +37,19 @@ public class GeoFocusResearcherCount extends AbstractAjaxResponder {
} }
@Override @Override
public String prepareResponse() throws IOException, JSONException { public String prepareResponse() throws IOException {
try { try {
geoFocusCount = getGeoFocusCount(vreq); geoFocusCount = getGeoFocusCount(vreq);
String response = "{ "; 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 += "\"count\": \"" + theCount + "\""; response.append("\"count\": \"").append(theCount).append("\"");
} }
response += " }"; response.append(" }");
log.debug(response); log.debug(response.toString());
return response; return response.toString();
} catch (Exception e) { } catch (Exception e) {
log.error("Failed geographic focus count", e); log.error("Failed geographic focus count", e);
return EMPTY_RESPONSE; return EMPTY_RESPONSE;

View file

@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.ajax;
import java.io.IOException; import java.io.IOException;
import javax.servlet.ServletException; import javax.servlet.ServletException;
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;
@ -17,6 +18,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.ajax.VitroAjaxController;
* Handle the AJAX functions that are specific to the "new" home page sections, at * Handle the AJAX functions that are specific to the "new" home page sections, at
* this point just the mapping of geographic locations. * this point just the mapping of geographic locations.
*/ */
@WebServlet(name = "HomePageAjax", urlPatterns = {"/homePageAjax"} )
public class HomePageAjaxController extends VitroAjaxController { public class HomePageAjaxController extends VitroAjaxController {
private static final Log log = LogFactory private static final Log log = LogFactory
.getLog(HomePageAjaxController.class); .getLog(HomePageAjaxController.class);

View file

@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.ajax;
import java.io.IOException; import java.io.IOException;
import javax.servlet.ServletException; import javax.servlet.ServletException;
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;
@ -17,6 +18,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.ajax.VitroAjaxController;
* Handle the AJAX functions that are specific to the "new" home page sections, at * Handle the AJAX functions that are specific to the "new" home page sections, at
* this point just the mapping of geographic locations. * this point just the mapping of geographic locations.
*/ */
@WebServlet(name = "QrCodeAjax", urlPatterns = {"/qrCodeAjax"} )
public class QrCodeAjaxController extends VitroAjaxController { public class QrCodeAjaxController extends VitroAjaxController {
private static final Log log = LogFactory private static final Log log = LogFactory
.getLog(QrCodeAjaxController.class); .getLog(QrCodeAjaxController.class);

View file

@ -11,7 +11,6 @@ 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.json.JSONException;
import org.apache.jena.query.QuerySolution; import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.ResultSet; import org.apache.jena.query.ResultSet;
@ -54,7 +53,7 @@ public class QrCodeDetails extends AbstractAjaxResponder {
} }
@Override @Override
public String prepareResponse() throws IOException, JSONException { public String prepareResponse() throws IOException {
try { try {
Individual individual = getIndividualFromRequest(vreq); Individual individual = getIndividualFromRequest(vreq);
String firstName = ""; String firstName = "";

View file

@ -7,6 +7,7 @@ import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_ASSER
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
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;
@ -34,6 +35,7 @@ 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"} )
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);

View file

@ -24,7 +24,10 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils; import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import javax.servlet.annotation.WebServlet;
@WebServlet(name = "ManageGrantsForIndividualController", urlPatterns = {"/manageGrants"} )
public class ManageGrantsForIndividualController extends FreemarkerHttpServlet { 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());

View file

@ -24,7 +24,10 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils; import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import javax.servlet.annotation.WebServlet;
@WebServlet(name = "ManagePeopleForOrganizationController", urlPatterns = {"/managePeople"} )
public class ManagePeopleForOrganizationController extends FreemarkerHttpServlet { 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());

View file

@ -24,7 +24,10 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils; import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import javax.servlet.annotation.WebServlet;
@WebServlet(name = "ManagePublicationsForIndividualController", urlPatterns = {"/managePublications"} )
public class ManagePublicationsForIndividualController extends FreemarkerHttpServlet { public class ManagePublicationsForIndividualController extends FreemarkerHttpServlet {
private static final Log log = LogFactory.getLog(ManagePublicationsForIndividualController.class.getName()); private static final Log log = LogFactory.getLog(ManagePublicationsForIndividualController.class.getName());

View file

@ -1,42 +0,0 @@
/* $This file is distributed under the terms of the license in LICENSE$ */
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.visualization.tools.ToolsRequestHandler;
public class VIVOSiteAdminController extends BaseSiteAdminController {
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(VIVOSiteAdminController.class);
@Override
protected Map<String, Object> getSiteMaintenanceUrls(VitroRequest vreq) {
Map<String, Object> urls = super.getSiteMaintenanceUrls(vreq);
if (PolicyHelper.isAuthorizedForActions(vreq, ToolsRequestHandler.REQUIRED_ACTIONS)) {
urls.put("rebuildVisCache", UrlBuilder.getUrl("/vis/tools"));
}
return urls;
}
@Override
protected Map<String, Object> getSiteConfigData(VitroRequest vreq) {
Map<String, Object> data = super.getSiteConfigData(vreq);
if (PolicyHelper.isAuthorizedForActions(vreq, InstitutionalInternalClassController.REQUIRED_ACTIONS)) {
data.put("internalClass", UrlBuilder.getUrl("/processInstitutionalInternalClass"));
}
return data;
}
}

View file

@ -6,10 +6,8 @@ import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVParser;
@ -221,24 +219,24 @@ class CsvFileHarvestJob implements FileHarvestJob {
try { try {
int rowNum = 0; int rowNum = 0;
int numberFields = 0; int numberFields = 0;
String errorMsg = "File header does not match template"; StringBuilder errorMsg = new StringBuilder("File header does not match template");
for (CSVRecord cRecord : cReader) { for (CSVRecord cRecord : cReader) {
rowNum++; rowNum++;
if (false) { if (false) {
numberFields = cRecord.size(); numberFields = cRecord.size();
errorMsg += "file header items: "; errorMsg.append("file header items: ");
for(int i = 0; i < cRecord.size(); i++) { for(int i = 0; i < cRecord.size(); i++) {
errorMsg += cRecord.get(i) + ", "; errorMsg.append(cRecord.get(i)).append(", ");
} }
} else { } else {
if (cRecord.size() > 0) { if (cRecord.size() > 0) {
if(cRecord.size() != numberFields) { if(cRecord.size() != numberFields) {
if (errorMsg != null) { if (errorMsg != null) {
errorMsg += "template items: "; errorMsg.append("template items: ");
for(int i = 0; i < cRecord.size(); i++) { for(int i = 0; i < cRecord.size(); i++) {
errorMsg += cRecord.get(i) + ", "; errorMsg.append(cRecord.get(i)).append(", ");
} }
return errorMsg; return errorMsg.toString();
} }
return "Mismatch in number of entries in row " + rowNum + ": expected " + numberFields + ", found " + cRecord.size(); return "Mismatch in number of entries in row " + rowNum + ": expected " + numberFields + ", found " + cRecord.size();
} }

View file

@ -20,15 +20,17 @@ import java.util.Set;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
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 javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileItem;
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.json.JSONException;
import org.json.JSONObject;
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;
@ -44,6 +46,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Res
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.filestorage.impl.FileStorageImplWrapper; import edu.cornell.mannlib.vitro.webapp.filestorage.impl.FileStorageImplWrapper;
@WebServlet(name = "FileHarvestController", urlPatterns = {"/harvester/harvest"})
public class FileHarvestController extends FreemarkerHttpServlet { public class FileHarvestController extends FreemarkerHttpServlet {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -293,7 +296,7 @@ public class FileHarvestController extends FreemarkerHttpServlet {
private void doFileUploadPost(HttpServletRequest request, HttpServletResponse response) private void doFileUploadPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException { throws IOException, ServletException {
JSONObject json = generateJson(false); ObjectNode json = generateJson(false);
try { try {
VitroRequest vreq = new VitroRequest(request); VitroRequest vreq = new VitroRequest(request);
@ -362,41 +365,22 @@ public class FileHarvestController extends FreemarkerHttpServlet {
} }
//prepare the results which will be sent back to the browser for display //prepare the results which will be sent back to the browser for display
try { json.put("success", success);
json.put("success", success); json.put("fileName", name);
json.put("fileName", name); json.put("errorMessage", errorMessage);
json.put("errorMessage", errorMessage);
}
catch(JSONException e) {
log.error(e, e);
return;
}
} else { } else {
//if for some reason no file was included with the request, send an error back //if for some reason no file was included with the request, send an error back
try { json.put("success", false);
json.put("success", false); json.put("fileName", "(none)");
json.put("fileName", "(none)"); json.put("errorMessage", "No file uploaded");
json.put("errorMessage", "No file uploaded");
} catch(JSONException e) {
log.error(e, e);
return;
}
} }
} catch(ExceptionVisibleToUser e) { } catch(ExceptionVisibleToUser e) {
log.error(e, e); log.error(e, e);
//handle exceptions whose message is for the user //handle exceptions whose message is for the user
try { json.put("success", false);
json.put("success", false); json.put("filename", "(none)");
json.put("filename", "(none)"); json.put("errorMessage", e.getMessage());
json.put("errorMessage", e.getMessage());
} catch(JSONException f) {
log.error(f, f);
return;
}
} catch(Exception e) { } catch(Exception e) {
log.error(e, e); log.error(e, e);
json = generateJson(true); json = generateJson(true);
@ -414,7 +398,7 @@ public class FileHarvestController extends FreemarkerHttpServlet {
*/ */
private void doHarvestPost(HttpServletRequest request, HttpServletResponse response) { private void doHarvestPost(HttpServletRequest request, HttpServletResponse response) {
JSONObject json; ObjectNode json;
try { try {
VitroRequest vreq = new VitroRequest(request); VitroRequest vreq = new VitroRequest(request);
FileHarvestJob job = getJob(vreq, vreq.getParameter(PARAMETER_JOB)); FileHarvestJob job = getJob(vreq, vreq.getParameter(PARAMETER_JOB));
@ -452,7 +436,7 @@ public class FileHarvestController extends FreemarkerHttpServlet {
*/ */
private void doCheckHarvestStatusPost(HttpServletRequest request, HttpServletResponse response) { private void doCheckHarvestStatusPost(HttpServletRequest request, HttpServletResponse response) {
JSONObject json; ObjectNode json;
try { try {
String newline = "\n"; String newline = "\n";
@ -471,24 +455,24 @@ public class FileHarvestController extends FreemarkerHttpServlet {
unsentLogLinesList.clear(); unsentLogLinesList.clear();
} }
String progressSinceLastCheck = ""; StringBuilder progressSinceLastCheck = new StringBuilder();
for(int i = 0; i < unsentLogLines.length; i++) { for (String unsentLogLine : unsentLogLines) {
progressSinceLastCheck += unsentLogLines[i] + newline; progressSinceLastCheck.append(unsentLogLine).append(newline);
} }
boolean finished = sessionInfo.isFinished(); boolean finished = sessionInfo.isFinished();
boolean abnormalTermination = false; boolean abnormalTermination = false;
VitroRequest vreq = new VitroRequest(request); VitroRequest vreq = new VitroRequest(request);
ArrayList<String> newlyAddedUrls = new ArrayList<String>(); ArrayNode newlyAddedUrls = JsonNodeFactory.instance.arrayNode();
ArrayList<String> newlyAddedUris = new ArrayList<String>(); ArrayNode newlyAddedUris = JsonNodeFactory.instance.arrayNode();
if(finished) { if(finished) {
newlyAddedUris = sessionInfo.newlyAddedUris; if (sessionInfo.newlyAddedUris != null) {
if(newlyAddedUris != null) { for(String uri : sessionInfo.newlyAddedUris) {
for(String uri : newlyAddedUris) { newlyAddedUris.add(uri);
newlyAddedUrls.add(UrlBuilder.getIndividualProfileUrl(uri, vreq)); newlyAddedUrls.add(UrlBuilder.getIndividualProfileUrl(uri, vreq));
} }
} }
//remove all entries in "sessionIdTo..." mappings for this session ID //remove all entries in "sessionIdTo..." mappings for this session ID
@ -500,7 +484,7 @@ public class FileHarvestController extends FreemarkerHttpServlet {
if(!abnormalTermination) { if(!abnormalTermination) {
json = generateJson(false); json = generateJson(false);
json.put("progressSinceLastCheck", progressSinceLastCheck); json.put("progressSinceLastCheck", progressSinceLastCheck.toString());
json.put("finished", finished); json.put("finished", finished);
json.put("newlyAddedUris", newlyAddedUris); json.put("newlyAddedUris", newlyAddedUris);
json.put("newlyAddedUrls", newlyAddedUrls); json.put("newlyAddedUrls", newlyAddedUrls);
@ -651,9 +635,10 @@ public class FileHarvestController extends FreemarkerHttpServlet {
boolean match = false; boolean match = false;
String[] validRdfTypesForJob = job.getRdfTypesForLinks(); String[] validRdfTypesForJob = job.getRdfTypesForLinks();
for(String rdfType : validRdfTypesForJob) { for(String rdfType : validRdfTypesForJob) {
if(types.contains(rdfType)) if(types.contains(rdfType)) {
match = true; match = true;
break; break;
}
} }
if(match) { if(match) {
@ -742,28 +727,17 @@ public class FileHarvestController extends FreemarkerHttpServlet {
} }
} }
/** /**
* Create a new JSON object * Create a new JSON object
* @param fatalError whether the fatal error flag should be set on this object * @param fatalError whether the fatal error flag should be set on this object
* @return the new JSON object * @return the new JSON object
*/ */
private JSONObject generateJson(boolean fatalError) { private ObjectNode generateJson(boolean fatalError) {
JSONObject json = null; ObjectNode json = JsonNodeFactory.instance.objectNode();
try { json.put("fatalError", fatalError);
json = new JSONObject();
json.put("fatalError", fatalError);
} catch(JSONException e) {
log.error(e.getMessage(), e);
}
return json; return json;
} }
/** /**
* Information relating to a particular user session, created just before the harvester thread is starting. * Information relating to a particular user session, created just before the harvester thread is starting.
* @author mbarbieri * @author mbarbieri

View file

@ -3,6 +3,7 @@
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;
/* //PLEASE SEE JAVADOC COMMENT FOR CLASS BELOW /* //PLEASE SEE JAVADOC COMMENT FOR CLASS BELOW
import org.vivoweb.harvester.diff.Diff; import org.vivoweb.harvester.diff.Diff;
@ -172,14 +173,12 @@ class Harvester {
*/ */
public static String[] stringsToArray(Object ... args) { public static String[] stringsToArray(Object ... args) {
ArrayList<String> allData = new ArrayList<String>(); ArrayList<String> allData = new ArrayList<String>();
for(int i = 0; i < args.length; i++) { for (Object arg : args) {
if(args[i] instanceof String[]) { if (arg instanceof String[]) {
String[] array = (String[])(args[i]); String[] array = (String[]) (arg);
for(int j = 0; j < array.length; j++) { Collections.addAll(allData, array);
allData.add(array[j]);
}
} else { } else {
allData.add(args[i].toString()); allData.add(arg.toString());
} }
} }
return allData.toArray(new String[allData.size()]); return allData.toArray(new String[allData.size()]);

View file

@ -6,9 +6,11 @@ import java.io.IOException;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.ServletException; import javax.servlet.ServletException;
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 com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -32,6 +34,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequ
* @author cdtank * @author cdtank
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
@WebServlet(name = "AjaxVisualizationController", urlPatterns = {"/visualizationAjax"})
public class AjaxVisualizationController extends FreemarkerHttpServlet { public class AjaxVisualizationController extends FreemarkerHttpServlet {
public static final String URL_ENCODING_SCHEME = "UTF-8"; public static final String URL_ENCODING_SCHEME = "UTF-8";
@ -138,7 +141,7 @@ public class AjaxVisualizationController extends FreemarkerHttpServlet {
return visRequestHandler.generateAjaxVisualization(vitroRequest, return visRequestHandler.generateAjaxVisualization(vitroRequest,
log, log,
dataset); dataset);
} catch (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(),

View file

@ -6,9 +6,11 @@ import java.io.IOException;
import java.util.Map; import java.util.Map;
import javax.servlet.ServletException; import javax.servlet.ServletException;
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 com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -30,6 +32,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequ
* @author cdtank * @author cdtank
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
@WebServlet(name = "DataVisualizationController", urlPatterns = {"/visualizationData"})
public class DataVisualizationController extends VitroHttpServlet { public class DataVisualizationController extends VitroHttpServlet {
public static final String URL_ENCODING_SCHEME = "UTF-8"; public static final String URL_ENCODING_SCHEME = "UTF-8";
@ -90,10 +93,8 @@ public class DataVisualizationController extends VitroHttpServlet {
response, response,
log); log);
} }
return; } else {
} else {
UtilityFunctions.handleMalformedParameters( UtilityFunctions.handleMalformedParameters(
"Inappropriate query parameters were submitted.", "Inappropriate query parameters were submitted.",
@ -126,18 +127,18 @@ public class DataVisualizationController extends VitroHttpServlet {
Dataset dataset = setupJENADataSource(vitroRequest); Dataset dataset = setupJENADataSource(vitroRequest);
if (dataset != null && visRequestHandler != null) { if (dataset != null && visRequestHandler != null) {
return visRequestHandler.generateDataVisualization(vitroRequest, try {
log, return visRequestHandler.generateDataVisualization(vitroRequest,
dataset); log,
dataset);
} else { } catch (JsonProcessingException e) {
}
String errorMessage = "Data Model Empty &/or Inappropriate "
+ "query parameters were submitted. ";
throw new MalformedQueryParametersException(errorMessage);
} }
String errorMessage = "Data Model Empty &/or Inappropriate "
+ "query parameters were submitted. ";
throw new MalformedQueryParametersException(errorMessage);
} }
private VisualizationRequestHandler getVisualizationRequestHandler( private VisualizationRequestHandler getVisualizationRequestHandler(

View file

@ -3,11 +3,13 @@
package edu.cornell.mannlib.vitro.webapp.controller.visualization; package edu.cornell.mannlib.vitro.webapp.controller.visualization;
import java.util.ArrayList; import java.util.ArrayList;
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.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.annotation.WebServlet;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -33,6 +35,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequ
* @author cdtank * @author cdtank
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
@WebServlet(name = "ShortURLVisualizationController", urlPatterns = {"/vis/*"})
public class ShortURLVisualizationController extends FreemarkerHttpServlet { public class ShortURLVisualizationController extends FreemarkerHttpServlet {
public static final String URL_ENCODING_SCHEME = "UTF-8"; public static final String URL_ENCODING_SCHEME = "UTF-8";
@ -247,9 +250,7 @@ public class ShortURLVisualizationController extends FreemarkerHttpServlet {
if (urlParams.length > 1 if (urlParams.length > 1
&& urlParams[0].equalsIgnoreCase("vis")) { && urlParams[0].equalsIgnoreCase("vis")) {
for (int ii=1; ii < urlParams.length; ii++) { matchedGroups.addAll(Arrays.asList(urlParams).subList(1, urlParams.length));
matchedGroups.add(urlParams[ii]);
}
} }
return matchedGroups; return matchedGroups;

View file

@ -3,6 +3,7 @@
package edu.cornell.mannlib.vitro.webapp.controller.visualization; package edu.cornell.mannlib.vitro.webapp.controller.visualization;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.annotation.WebServlet;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -27,6 +28,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequ
* @author cdtank * @author cdtank
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
@WebServlet(name = "StandardVisualizationController", urlPatterns = {"/visualizationfm","/visualization"})
public class StandardVisualizationController extends FreemarkerHttpServlet { public class StandardVisualizationController extends FreemarkerHttpServlet {
public static final String URL_ENCODING_SCHEME = "UTF-8"; public static final String URL_ENCODING_SCHEME = "UTF-8";

View file

@ -1,8 +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.edit.n3editing; package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.JspToGeneratorMapping;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View file

@ -6,7 +6,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
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;

View file

@ -8,8 +8,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Literal;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3ValidatorVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3ValidatorVTwo;

View file

@ -411,7 +411,7 @@ public class AddAssociatedConceptGenerator extends VivoBaseGenerator implements
private void sortConcepts(List<AssociatedConceptInfo> concepts) { private void sortConcepts(List<AssociatedConceptInfo> concepts) {
Collections.sort(concepts, new AssociatedConceptInfoComparator()); concepts.sort(new AssociatedConceptInfoComparator());
log.debug("Concepts should be sorted now" + concepts.toString()); log.debug("Concepts should be sorted now" + concepts.toString());
} }

View file

@ -4,7 +4,6 @@ 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.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -23,17 +22,12 @@ import org.apache.commons.logging.LogFactory;
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.RDFNode; import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Literal;
import org.apache.jena.vocabulary.RDFS; import org.apache.jena.vocabulary.RDFS;
import org.apache.jena.vocabulary.XSD; import org.apache.jena.vocabulary.XSD;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyComparator;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils; import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.PublicationHasAuthorValidator; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.PublicationHasAuthorValidator;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
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;

View file

@ -2,8 +2,6 @@
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 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;

View file

@ -75,9 +75,7 @@ public class AddConceptThroughObjectPropertyGenerator extends DefaultObjectPrope
if (!rangeVClass.isUnion()) { if (!rangeVClass.isUnion()) {
types.add(rangeVClass); types.add(rangeVClass);
} else { } else {
for (VClass unionComponent : rangeVClass.getUnionComponents()) { types.addAll(rangeVClass.getUnionComponents());
types.add(unionComponent);
}
} }
return types; return types;
} else { } else {

View file

@ -1,10 +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.edit.n3editing.configuration.generators; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -12,9 +8,6 @@ import org.apache.commons.logging.LogFactory;
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.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.vocabulary.XSD; import org.apache.jena.vocabulary.XSD;

View file

@ -4,7 +4,6 @@ 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.ChildVClassesWithParent;
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.

View file

@ -4,7 +4,6 @@ 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.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -23,17 +22,12 @@ import org.apache.commons.logging.LogFactory;
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.RDFNode; import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Literal;
import org.apache.jena.vocabulary.RDFS; import org.apache.jena.vocabulary.RDFS;
import org.apache.jena.vocabulary.XSD; import org.apache.jena.vocabulary.XSD;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyComparator;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils; import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.FirstAndLastNameValidator; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.FirstAndLastNameValidator;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
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;

View file

@ -2,12 +2,9 @@
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.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
@ -17,12 +14,8 @@ import org.apache.commons.logging.LogFactory;
import org.apache.jena.vocabulary.XSD; import org.apache.jena.vocabulary.XSD;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
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.ChildVClassesOptions;
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.VTwo.fields.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
public class AddFullNameToPersonGenerator extends VivoBaseGenerator implements public class AddFullNameToPersonGenerator extends VivoBaseGenerator implements

View file

@ -3,7 +3,6 @@
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.dao.VitroVocabulary;
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;

View file

@ -2,27 +2,16 @@
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.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
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.vocabulary.XSD;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
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.ChildVClassesOptions;
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.VTwo.fields.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
public class AddOrcidIdToPersonGenerator extends VivoBaseGenerator implements public class AddOrcidIdToPersonGenerator extends VivoBaseGenerator implements

View file

@ -14,10 +14,8 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.AutocompleteRequiredInput
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
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.ChildVClassesOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesWithParent; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesWithParent;
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.VTwo.fields.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator implements public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator implements

View file

@ -3,7 +3,6 @@
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.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;

View file

@ -3,7 +3,6 @@
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.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;

View file

@ -3,24 +3,15 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.apache.jena.vocabulary.XSD; import org.apache.jena.vocabulary.XSD;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.AutocompleteRequiredInputValidator; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.AutocompleteRequiredInputValidator;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
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.ChildVClassesWithParent;
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.FieldVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
public class GrantAdministeredByGenerator extends VivoBaseGenerator implements public class GrantAdministeredByGenerator extends VivoBaseGenerator implements

View file

@ -13,13 +13,9 @@ import org.apache.jena.vocabulary.XSD;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.FirstAndLastNameValidator; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.FirstAndLastNameValidator;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
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.ChildVClassesOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesWithParent; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesWithParent;
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.VTwo.fields.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
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;

View file

@ -18,6 +18,7 @@ import java.util.Map;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
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;
@ -296,18 +297,18 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
//for selection when creating a new label //for selection when creating a new label
//The assumption here is we don't want to allow the user to add a new label when a label //The assumption here is we don't want to allow the user to add a new label when a label
//already exists in that language //already exists in that language
if(languageName != "untyped" && !existingLabelsLanguageNames.contains(languageName)) { if(!"untyped".equals(languageName) && !existingLabelsLanguageNames.contains(languageName)) {
availableLocales.add(localeInfo); availableLocales.add(localeInfo);
} }
} }
//Sort list by language label and return //Sort list by language label and return
Collections.sort(availableLocales, new Comparator<HashMap<String, String>>() { availableLocales.sort(new Comparator<HashMap<String, String>>() {
public int compare(HashMap<String, String> h1, HashMap<String, String> h2) { public int compare(HashMap<String, String> h1, HashMap<String, String> h2) {
String languageName1 = (String) h1.get("label"); String languageName1 = (String) h1.get("label");
String languageName2 = (String) h2.get("label"); String languageName2 = (String) h2.get("label");
return languageName1.compareTo(languageName2); return languageName1.compareTo(languageName2);
} }
}); });
return availableLocales; return availableLocales;
} }
@ -368,7 +369,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
for(Literal l: labels) { for(Literal l: labels) {
String languageTag = l.getLanguage(); String languageTag = l.getLanguage();
String languageName = ""; String languageName = "";
if(languageTag == "") { if(StringUtils.isEmpty(languageTag)) {
languageName = "untyped"; languageName = "untyped";
} }
else if(localeCodeToNameMap.containsKey(languageTag)) { else if(localeCodeToNameMap.containsKey(languageTag)) {
@ -377,7 +378,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
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(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>());
} }
@ -397,7 +398,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
LabelInformationComparator lic = new LabelInformationComparator(); LabelInformationComparator lic = new LabelInformationComparator();
for(String languageName: labelsHash.keySet()) { for(String languageName: labelsHash.keySet()) {
List<LabelInformation> labelInfo = labelsHash.get(languageName); List<LabelInformation> labelInfo = labelsHash.get(languageName);
Collections.sort(labelInfo, lic); labelInfo.sort(lic);
} }
return labelsHash; return labelsHash;

View file

@ -3,24 +3,15 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.apache.jena.vocabulary.XSD; import org.apache.jena.vocabulary.XSD;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.AutocompleteRequiredInputValidator; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.AutocompleteRequiredInputValidator;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
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.ChildVClassesWithParent;
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.FieldVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
public class OrganizationAdministersGrantGenerator extends VivoBaseGenerator implements public class OrganizationAdministersGrantGenerator extends VivoBaseGenerator implements

View file

@ -16,7 +16,6 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.FirstAndLastNameValidator
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
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.ChildVClassesOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesWithParent; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesWithParent;
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.VTwo.fields.IndividualsViaVClassOptions; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaVClassOptions;

View file

@ -17,7 +17,6 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisio
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.ChildVClassesWithParent; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesWithParent;
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.VTwo.fields.IndividualsViaVClassOptions;
public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
implements EditConfigurationGenerator { implements EditConfigurationGenerator {

View file

@ -15,7 +15,6 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalVali
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
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.VTwo.fields.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements

View file

@ -2,12 +2,9 @@
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.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
@ -17,12 +14,8 @@ import org.apache.commons.logging.LogFactory;
import org.apache.jena.vocabulary.XSD; import org.apache.jena.vocabulary.XSD;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
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.ChildVClassesOptions;
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.VTwo.fields.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
public class PersonHasEmailGenerator extends VivoBaseGenerator implements public class PersonHasEmailGenerator extends VivoBaseGenerator implements

View file

@ -4,7 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
@ -16,11 +15,9 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.AutocompleteRequiredInput
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
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.ChildVClassesWithParent;
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;
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.VTwo.fields.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
public class PersonHasIssuedCredentialGenerator extends VivoBaseGenerator implements public class PersonHasIssuedCredentialGenerator extends VivoBaseGenerator implements

View file

@ -17,10 +17,8 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.AutocompleteRequiredInput
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
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.ChildVClassesOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesWithParent; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesWithParent;
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.VTwo.fields.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
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;

View file

@ -2,12 +2,9 @@
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.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
@ -17,12 +14,8 @@ import org.apache.commons.logging.LogFactory;
import org.apache.jena.vocabulary.XSD; import org.apache.jena.vocabulary.XSD;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
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.ChildVClassesOptions;
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.VTwo.fields.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
public class PersonHasPreferredTitleGenerator extends VivoBaseGenerator implements public class PersonHasPreferredTitleGenerator extends VivoBaseGenerator implements

View file

@ -11,15 +11,9 @@ import javax.servlet.http.HttpSession;
import org.apache.jena.vocabulary.XSD; import org.apache.jena.vocabulary.XSD;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.FirstAndLastNameValidator; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.FirstAndLastNameValidator;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
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.ChildVClassesOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesWithParent;
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.VTwo.fields.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
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;

View file

@ -2,12 +2,9 @@
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.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
@ -17,12 +14,8 @@ import org.apache.commons.logging.LogFactory;
import org.apache.jena.vocabulary.XSD; import org.apache.jena.vocabulary.XSD;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
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.ChildVClassesOptions;
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.VTwo.fields.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
public class SubjectHasMailingAddressGenerator extends VivoBaseGenerator implements public class SubjectHasMailingAddressGenerator extends VivoBaseGenerator implements

View file

@ -2,18 +2,14 @@
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.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
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.commons.lang3.StringUtils;
import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Literal;
import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Model;
@ -22,12 +18,8 @@ import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.vocabulary.XSD; import org.apache.jena.vocabulary.XSD;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
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.ChildVClassesOptions;
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.VTwo.fields.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
public class SubjectHasPhoneFaxNumberGenerator extends VivoBaseGenerator implements public class SubjectHasPhoneFaxNumberGenerator extends VivoBaseGenerator implements

View file

@ -7,7 +7,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.searchresult.VIVOIndividualSearchResult;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;

View file

@ -20,7 +20,6 @@ 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.preprocessors.FoafNameToRdfsLabelPreprocessor;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
/** /**

View file

@ -746,7 +746,7 @@ public class AddAssociatedConceptsPreprocessor extends
//This will either generate or retrieve URIs for the concept semantic type labels if they exist //This will either generate or retrieve URIs for the concept semantic type labels if they exist
//We will then update the submission to include this //We will then update the submission to include this
private String getConceptSemanticTypeURIValues() { private String getConceptSemanticTypeURIValues() {
String pseudoInputString = ""; StringBuilder pseudoInputString = new StringBuilder();
if(conceptSemanticTypeLabelValues != null && !conceptSemanticTypeLabelValues.isEmpty()) { if(conceptSemanticTypeLabelValues != null && !conceptSemanticTypeLabelValues.isEmpty()) {
String[] conceptSemanticTypeLabels = convertDelimitedStringToArray(conceptSemanticTypeLabelValues); String[] conceptSemanticTypeLabels = convertDelimitedStringToArray(conceptSemanticTypeLabelValues);
//keep track of what label values already exist and to which label variables they map //keep track of what label values already exist and to which label variables they map
@ -758,10 +758,10 @@ public class AddAssociatedConceptsPreprocessor extends
if(numberLabels == 1) { if(numberLabels == 1) {
String label = conceptSemanticTypeLabels[0]; String label = conceptSemanticTypeLabels[0];
String uri = getURIForSemanticTypeLabel(label); String uri = getURIForSemanticTypeLabel(label);
if(uri != "") { if(!StringUtils.isEmpty(uri)) {
String[] urisToAdd = new String[1]; String[] urisToAdd = new String[1];
urisToAdd[0] = uri; urisToAdd[0] = uri;
pseudoInputString = uri; pseudoInputString = new StringBuilder(uri);
log.debug("uris to add" + uri); log.debug("uris to add" + uri);
submission.addUriToForm(this.editConfiguration, "conceptSemanticTypeURI", urisToAdd); submission.addUriToForm(this.editConfiguration, "conceptSemanticTypeURI", urisToAdd);
} }
@ -801,7 +801,7 @@ public class AddAssociatedConceptsPreprocessor extends
//Make or retrieve URI for this label //Make or retrieve URI for this label
//TODO: Do we create this string with empty inputs ? //TODO: Do we create this string with empty inputs ?
String uri = getURIForSemanticTypeLabel(label); String uri = getURIForSemanticTypeLabel(label);
if(uri != "") { if(!StringUtils.isEmpty(uri)) {
//uri var shouldn't be repeated? //uri var shouldn't be repeated?
if(!this.conceptSemanticTypeURIVarToValueMap.containsKey(uriVar)) { if(!this.conceptSemanticTypeURIVarToValueMap.containsKey(uriVar)) {
this.conceptSemanticTypeURIVarToValueMap.put(uriVar, new ArrayList<String>()); this.conceptSemanticTypeURIVarToValueMap.put(uriVar, new ArrayList<String>());
@ -809,21 +809,21 @@ public class AddAssociatedConceptsPreprocessor extends
} }
} }
if(i != 0) { if(i != 0) {
pseudoInputString += ","; pseudoInputString.append(",");
} }
pseudoInputString += uri; pseudoInputString.append(uri);
} }
//Add this string to the uris for the form //Add this string to the uris for the form
String[] urisToAdd = new String[1]; String[] urisToAdd = new String[1];
urisToAdd[0] = pseudoInputString; urisToAdd[0] = pseudoInputString.toString();
log.debug("uris to add" + pseudoInputString); log.debug("uris to add" + pseudoInputString);
submission.addUriToForm(this.editConfiguration, "conceptSemanticTypeURI", urisToAdd); submission.addUriToForm(this.editConfiguration, "conceptSemanticTypeURI", urisToAdd);
} }
} }
return pseudoInputString; return pseudoInputString.toString();
} }
private String getURIForSemanticTypeLabel(String label) { private String getURIForSemanticTypeLabel(String label) {

View file

@ -3,27 +3,16 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.jena.ontology.OntModel;
import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Literal;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.ResIterator;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.Statement;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
/* /*
* This preprocessor is used to set the language attribute on the label based on the user selection * This preprocessor is used to set the language attribute on the label based on the user selection
* on the manage labels page when adding a new label. * on the manage labels page when adding a new label.
*/ */
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;

View file

@ -4,40 +4,10 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocess
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.Literal;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.vocabulary.XSD;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.shared.Lock;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
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.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 edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
import org.vivoweb.webapp.util.ModelUtils;
public class RoleToActivityPredicatePreprocessor extends RoleToPredicatePreprocessor { public class RoleToActivityPredicatePreprocessor extends RoleToPredicatePreprocessor {
public RoleToActivityPredicatePreprocessor(EditConfigurationVTwo editConfig, WebappDaoFactory wadf) { public RoleToActivityPredicatePreprocessor(EditConfigurationVTwo editConfig, WebappDaoFactory wadf) {

View file

@ -5,37 +5,16 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocess
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 java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
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.QueryExecution;
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.Literal;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.vocabulary.XSD;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.shared.Lock;
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.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.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 edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
import org.vivoweb.webapp.util.ModelUtils; import org.vivoweb.webapp.util.ModelUtils;

View file

@ -0,0 +1,138 @@
package edu.cornell.mannlib.vitro.webapp.search.controller;
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.dao.ApplicationDao;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
@WebServlet(name = "FedSearchController", urlPatterns = {"/FS.xml","/ctsasearch"} ) // fedsearch
public class FedSearchController extends PagedSearchController {
private static final Log log = LogFactory.getLog(FedSearchController.class);
private String classgroup;
private String populationType;
private String getClassgroup(HttpServletRequest req) {
if (classgroup == null) {
ConfigurationProperties configuration = ConfigurationProperties.getBean(req.getSession().getServletContext());
classgroup = configuration.getProperty("ctsa.classgroup", "http://vivoweb.org/ontology#vitroClassGrouppeople");
}
return classgroup;
}
private String getPopulationType(HttpServletRequest req) {
if (populationType == null) {
ConfigurationProperties configuration = ConfigurationProperties.getBean(req.getSession().getServletContext());
populationType = configuration.getProperty("ctsa.classgroup.type", "faculty,staff,students");
}
return populationType;
}
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
StringBuffer url = request.getRequestURL();
String uri = request.getRequestURI();
String serverBase = url.substring(0, url.indexOf(uri));
if (request.getRequestURI().contains("FS.xml")) {
try {
VitroRequest vreq = new VitroRequest(request);
Map<String, Object> body = new HashMap<String, Object>();
response.setCharacterEncoding("UTF-8");
response.setContentType("text/xml;charset=UTF-8");
response.setHeader("Content-Disposition", "attachment; filename=FS.xml");
ApplicationDao aDao = vreq.getUnfilteredWebappDaoFactory().getApplicationDao();
ApplicationBean applicationForEditing = aDao.getApplicationBean();
body.put("ApplicationName", applicationForEditing.getApplicationName());
body.put("serverBase", serverBase);
writeTemplate("search-fs.ftl", body, request, response);
} catch (Exception e) {
log.error(e, e);
}
} else {
try {
Map<String, String[]> additionalParams = new TreeMap<>();
String classgroup = getClassgroup(request);
additionalParams.put("classgroup", new String[] { classgroup });
VitroRequest vreq = new VitroRequest(new RequestWrapper(request, additionalParams));
ResponseValues rvalues = processRequest(vreq);
response.setCharacterEncoding("UTF-8");
response.setContentType("text/xml;charset=UTF-8");
response.setHeader("Content-Disposition", "attachment; filename=search.xml");
Map<String, Object> body = new HashMap<String, Object>();
body.putAll(rvalues.getMap());
// Note - the template requires the following properties from the above map
// querytext
// hitCount
body.put("populationType", getPopulationType(request));
body.put("classgroup", classgroup);
body.put("serverBase", serverBase);
writeTemplate("search-fsresult.ftl", body, request, response);
} catch (Exception e) {
log.error(e, e);
}
}
}
private class RequestWrapper extends HttpServletRequestWrapper {
private Map<String, String[]> allParameters = null;
public RequestWrapper(HttpServletRequest request, final Map<String, String[]> additionalParams) {
super(request);
allParameters = new TreeMap<String, String[]>();
allParameters.putAll(super.getParameterMap());
allParameters.putAll(additionalParams);
allParameters = Collections.unmodifiableMap(allParameters);
}
@Override
public Map<String, String[]> getParameterMap() {
return allParameters;
}
@Override
public String getParameter(final String name) {
String[] strings = getParameterMap().get(name);
if (strings != null) {
return strings[0];
}
return super.getParameter(name);
}
@Override
public Enumeration<String> getParameterNames() {
return Collections.enumeration(getParameterMap().keySet());
}
@Override
public String[] getParameterValues(final String name) {
return getParameterMap().get(name);
}
}
}

View file

@ -213,7 +213,7 @@ public class CalculateParameters implements DocumentModifier, ContextModelsUser
queryList = null; queryList = null;
Iterator<String> itr = adjacentNodes.iterator(); Iterator<String> itr = adjacentNodes.iterator();
while(itr.hasNext()){ while(itr.hasNext()){
adjacentNodesConcat.append(itr.next() + " "); adjacentNodesConcat.append(itr.next()).append(" ");
} }
info[0] = adjacentNodesConcat.toString(); info[0] = adjacentNodesConcat.toString();

View file

@ -353,13 +353,9 @@ public class LabelsAcrossContextNodes implements IndexingUriFinder,
String subjectUri = stmt.getSubject().getURI(); String subjectUri = stmt.getSubject().getURI();
String predicateUri = stmt.getPredicate().getURI(); String predicateUri = stmt.getPredicate().getURI();
if (incomingPropertyUri.equals(predicateUri) return incomingPropertyUri.equals(predicateUri)
&& (contextNodeClasses.isEmpty() || isAnyMatch( && (contextNodeClasses.isEmpty() || isAnyMatch(
contextNodeClasses, getTypes(subjectUri)))) { contextNodeClasses, getTypes(subjectUri)));
return true;
} else {
return false;
}
} }
private boolean isAnyMatch(Set<String> set1, Set<String> set2) { private boolean isAnyMatch(Set<String> set1, Set<String> set2) {

View file

@ -8,6 +8,7 @@ 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.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -25,6 +26,7 @@ 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"} )
public class ConceptSearchServlet extends VitroHttpServlet { public class ConceptSearchServlet extends VitroHttpServlet {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View file

@ -72,15 +72,11 @@ public class ConceptSearchServiceUtils {
Class classDefinition = Class.forName(searchServiceClassName); Class classDefinition = Class.forName(searchServiceClassName);
object = classDefinition.newInstance(); object = classDefinition.newInstance();
conceptServiceClass = (ExternalConceptService) object; conceptServiceClass = (ExternalConceptService) object;
} catch (InstantiationException e) { } catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) {
System.out.println(e); System.out.println(e);
} catch (IllegalAccessException e) { }
System.out.println(e);
} catch (ClassNotFoundException e) { if(conceptServiceClass == null){
System.out.println(e);
}
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;
} }

View file

@ -2,7 +2,11 @@
package edu.cornell.mannlib.vitro.webapp.visualization.capabilitymap; package edu.cornell.mannlib.vitro.webapp.visualization.capabilitymap;
import com.google.gson.Gson; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.jena.query.Dataset; import org.apache.jena.query.Dataset;
import org.apache.jena.query.QueryExecution; import org.apache.jena.query.QueryExecution;
@ -49,7 +53,7 @@ public class CapabilityMapRequestHandler implements VisualizationRequestHandler
} }
@Override @Override
public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log, Dataset dataSource) throws MalformedQueryParametersException { public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log, Dataset dataSource) throws MalformedQueryParametersException, JsonProcessingException {
ConceptLabelMap conceptLabelMap = VisualizationCaches.conceptToLabel.getNoWait(vitroRequest.getRDFService()); ConceptLabelMap conceptLabelMap = VisualizationCaches.conceptToLabel.getNoWait(vitroRequest.getRDFService());
ConceptPeopleMap conceptPeopleMap = VisualizationCaches.conceptToPeopleMap.getNoWait(vitroRequest.getRDFService()); ConceptPeopleMap conceptPeopleMap = VisualizationCaches.conceptToPeopleMap.getNoWait(vitroRequest.getRDFService());
OrganizationPeopleMap organizationPeopleMap = VisualizationCaches.organisationToPeopleMap.getNoWait(vitroRequest.getRDFService()); OrganizationPeopleMap organizationPeopleMap = VisualizationCaches.organisationToPeopleMap.getNoWait(vitroRequest.getRDFService());
@ -67,8 +71,8 @@ public class CapabilityMapRequestHandler implements VisualizationRequestHandler
} }
} }
Gson gson = new Gson(); ObjectMapper mapper = new ObjectMapper();
return gson.toJson(concepts); return mapper.writeValueAsString(concepts);
} }
return ""; return "";
} }
@ -96,13 +100,13 @@ public class CapabilityMapRequestHandler implements VisualizationRequestHandler
} }
response.results.add(result); response.results.add(result);
Gson gson = new Gson(); ObjectMapper mapper = new ObjectMapper();
String callback = vitroRequest.getParameter("callback"); String callback = vitroRequest.getParameter("callback");
if (!StringUtils.isEmpty(callback)) { if (!StringUtils.isEmpty(callback)) {
return callback + "(" + gson.toJson(response) + ");"; return callback + "(" + mapper.writeValueAsString(response) + ");";
} }
return gson.toJson(response); return mapper.writeValueAsString(response);
} }
String query = vitroRequest.getParameter("query"); String query = vitroRequest.getParameter("query");
@ -150,13 +154,12 @@ public class CapabilityMapRequestHandler implements VisualizationRequestHandler
response.results.add(result); response.results.add(result);
} }
Gson gson = new Gson(); ObjectMapper mapper = new ObjectMapper();
String callback = vitroRequest.getParameter("callback"); String callback = vitroRequest.getParameter("callback");
if (!StringUtils.isEmpty(callback)) { if (!StringUtils.isEmpty(callback)) {
return callback + "(" + gson.toJson(response) + ");"; return callback + "(" + mapper.writeValueAsString(response) + ");";
} }
return gson.toJson(response); return mapper.writeValueAsString(response);
} }
return ""; return "";

View file

@ -2,9 +2,14 @@
package edu.cornell.mannlib.vitro.webapp.visualization.capabilitymap; package edu.cornell.mannlib.vitro.webapp.visualization.capabilitymap;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL)
class CapabilityMapResponse { class CapabilityMapResponse {
@JsonProperty
List<CapabilityMapResult> results = new ArrayList<CapabilityMapResult>(); List<CapabilityMapResult> results = new ArrayList<CapabilityMapResult>();
} }

View file

@ -2,67 +2,71 @@
package edu.cornell.mannlib.vitro.webapp.visualization.capabilitymap; package edu.cornell.mannlib.vitro.webapp.visualization.capabilitymap;
import com.google.gson.annotations.SerializedName; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonInclude(JsonInclude.Include.NON_NULL)
class CapabilityMapResult { class CapabilityMapResult {
@JsonProperty
String[] clusters; String[] clusters;
@SerializedName("md_1") @JsonProperty("md_1")
String profileId; String profileId;
@SerializedName("md_2") @JsonProperty("md_2")
String description; String description;
@SerializedName("md_3") @JsonProperty("md_3")
String thumbNail; String thumbNail;
@SerializedName("md_4") @JsonProperty("md_4")
String department; String department;
@SerializedName("md_5") @JsonProperty("md_5")
String overview; String overview;
@SerializedName("md_6") @JsonProperty("md_6")
String geographicFocus; String geographicFocus;
@SerializedName("md_7") @JsonProperty("md_7")
String geographicLocation; String geographicLocation;
@SerializedName("md_8") @JsonProperty("md_8")
String[] grants; String[] grants;
@SerializedName("md_A") @JsonProperty("md_A")
String firstName; String firstName;
@SerializedName("md_B") @JsonProperty("md_B")
String lastName; String lastName;
@SerializedName("md_F") @JsonProperty("md_F")
String fax; String fax;
@SerializedName("md_G") @JsonProperty("md_G")
String email; String email;
@SerializedName("md_H") @JsonProperty("md_H")
String availableForSupervision; String availableForSupervision;
@SerializedName("md_I") @JsonProperty("md_I")
String homepage; String homepage;
@SerializedName("md_L") @JsonProperty("md_L")
String phoneNumber; String phoneNumber;
@SerializedName("md_U") @JsonProperty("md_U")
String[] publications; String[] publications;
@SerializedName("md_X") @JsonProperty("md_X")
String[] researchOverview; String[] researchOverview;
@SerializedName("md_Y") @JsonProperty("md_Y")
String[] subjectArea; String[] subjectArea;
@SerializedName("md_Z") @JsonProperty("md_Z")
String preferredTitle; String preferredTitle;
@JsonProperty
String query; String query;
} }

View file

@ -2,7 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.visualization.coauthorship; package edu.cornell.mannlib.vitro.webapp.visualization.coauthorship;
import java.io.OutputStreamWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -26,7 +25,6 @@ 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.TransformerConfigurationException;
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;
@ -81,15 +79,11 @@ public class CoAuthorshipGraphMLWriter {
transformer.transform(source, result); transformer.transform(source, result);
graphMLContent.append(writer.toString()); graphMLContent.append(writer.toString());
} catch (TransformerConfigurationException e) { } catch (ParserConfigurationException | TransformerException e) {
throw new IllegalStateException("XML error generating GraphML", e);
} catch (TransformerException e) {
throw new IllegalStateException("XML error generating GraphML", e);
} catch (ParserConfigurationException 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() {
@ -119,7 +113,7 @@ public class CoAuthorshipGraphMLWriter {
Set<Collaboration> edges = coAuthorshipData.getCollaborations(); Set<Collaboration> edges = coAuthorshipData.getCollaborations();
List<Collaboration> orderedEdges = new ArrayList<Collaboration>(edges); List<Collaboration> orderedEdges = new ArrayList<Collaboration>(edges);
Collections.sort(orderedEdges, new CollaborationComparator()); orderedEdges.sort(new CollaborationComparator());
for (Collaboration currentEdge : orderedEdges) { for (Collaboration currentEdge : orderedEdges) {
/* /*
@ -214,7 +208,7 @@ public class CoAuthorshipGraphMLWriter {
List<Collaborator> orderedAuthorNodes = new ArrayList<Collaborator>(authorNodes); List<Collaborator> orderedAuthorNodes = new ArrayList<Collaborator>(authorNodes);
orderedAuthorNodes.remove(egoNode); orderedAuthorNodes.remove(egoNode);
Collections.sort(orderedAuthorNodes, new CollaboratorComparator()); orderedAuthorNodes.sort(new CollaboratorComparator());
for (Collaborator currNode : orderedAuthorNodes) { for (Collaborator currNode : orderedAuthorNodes) {
/* /*

View file

@ -285,7 +285,7 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
List<Collaborator> coAuthorNodes = List<Collaborator> coAuthorNodes =
new ArrayList<Collaborator>(currentBiboDocumentEntry.getValue()); new ArrayList<Collaborator>(currentBiboDocumentEntry.getValue());
Collections.sort(coAuthorNodes, new CollaboratorComparator()); coAuthorNodes.sort(new CollaboratorComparator());
int numOfCoAuthors = coAuthorNodes.size(); int numOfCoAuthors = coAuthorNodes.size();

View file

@ -22,7 +22,6 @@ import edu.cornell.mannlib.vitro.webapp.controller.visualization.VisualizationFr
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.exceptions.MalformedQueryParametersException; import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
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.visutils.QueryRunner;
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions; 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;
@ -168,7 +167,7 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
String coAuthorSeparator = "; "; String coAuthorSeparator = "; ";
for (Collaborator currCoAuthor : coAuthors) { for (Collaborator currCoAuthor : coAuthors) {
coAuthorsMerged.append(currCoAuthor.getCollaboratorName() + coAuthorSeparator); coAuthorsMerged.append(currCoAuthor.getCollaboratorName()).append(coAuthorSeparator);
} }
return StringUtils.removeEnd(coAuthorsMerged.toString(), coAuthorSeparator); return StringUtils.removeEnd(coAuthorsMerged.toString(), coAuthorSeparator);

View file

@ -101,14 +101,11 @@ public class CoAuthorshipVisCodeGenerator {
if (yearToUniqueCoauthors.size() > 0) { if (yearToUniqueCoauthors.size() > 0) {
try { try {
minPublishedYear = Integer.parseInt(Collections.min(publishedYears)); minPublishedYear = Integer.parseInt(Collections.min(publishedYears));
} catch (NoSuchElementException 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());
} catch (NumberFormatException e2) {
log.debug("vis: " + e2.getMessage() + " error occurred for "
+ yearToUniqueCoauthors.toString());
} }
} }
int minPubYearConsidered = 0; int minPubYearConsidered = 0;
@ -254,4 +251,4 @@ public class CoAuthorshipVisCodeGenerator {
public SparklineData getValueObjectContainer() { public SparklineData getValueObjectContainer() {
return this.sparklineParameterVO; return this.sparklineParameterVO;
} }
} }

View file

@ -52,8 +52,7 @@ public class QueryConstants {
StringBuilder prefixSection = new StringBuilder(); StringBuilder prefixSection = new StringBuilder();
for (Map.Entry<String, String> prefixEntry : PREFIX_TO_NAMESPACE.entrySet()) { for (Map.Entry<String, String> prefixEntry : PREFIX_TO_NAMESPACE.entrySet()) {
prefixSection.append("PREFIX " + prefixEntry.getKey() prefixSection.append("PREFIX ").append(prefixEntry.getKey()).append(": <").append(prefixEntry.getValue()).append(">\n");
+ ": <" + prefixEntry.getValue() + ">\n");
} }
return prefixSection.toString(); return prefixSection.toString();
} }

View file

@ -15,11 +15,6 @@ import org.apache.jena.iri.IRI;
import org.apache.jena.iri.IRIFactory; import org.apache.jena.iri.IRIFactory;
import org.apache.jena.iri.Violation; import org.apache.jena.iri.Violation;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.Syntax; import org.apache.jena.query.Syntax;
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;

View file

@ -533,7 +533,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
* */ * */
List<Collaborator> coPINodes = List<Collaborator> coPINodes =
new ArrayList<Collaborator>(currentGrantEntry.getValue()); new ArrayList<Collaborator>(currentGrantEntry.getValue());
Collections.sort(coPINodes, new CollaboratorComparator()); coPINodes.sort(new CollaboratorComparator());
int numOfCoPIs = coPINodes.size(); int numOfCoPIs = coPINodes.size();

View file

@ -164,7 +164,7 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
String coPISeparator = ";"; String coPISeparator = ";";
for (Collaborator currentCoPI : coInvestigators) { for (Collaborator currentCoPI : coInvestigators) {
coPIsMerged.append(currentCoPI.getCollaboratorName() + coPISeparator); coPIsMerged.append(currentCoPI.getCollaboratorName()).append(coPISeparator);
} }
return StringUtils.removeEnd(coPIsMerged.toString(), coPISeparator); return StringUtils.removeEnd(coPIsMerged.toString(), coPISeparator);

View file

@ -25,7 +25,6 @@ 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.TransformerConfigurationException;
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;
@ -83,15 +82,11 @@ public class CoPIGraphMLWriter {
transformer.transform(source, result); transformer.transform(source, result);
graphMLContent.append(writer.toString()); graphMLContent.append(writer.toString());
} catch (TransformerConfigurationException e) { } catch (ParserConfigurationException | TransformerException e) {
throw new IllegalStateException("XML error generating GraphML", e);
} catch (TransformerException e) {
throw new IllegalStateException("XML error generating GraphML", e);
} catch (ParserConfigurationException e) {
throw new IllegalStateException("XML error generating GraphML", e); throw new IllegalStateException("XML error generating GraphML", e);
} }
return graphMLContent; return graphMLContent;
} }
public StringBuilder getCoPIGraphMLContent(){ public StringBuilder getCoPIGraphMLContent(){
@ -121,7 +116,7 @@ public class CoPIGraphMLWriter {
Set<Collaboration> edges = coPIData.getCollaborations(); Set<Collaboration> edges = coPIData.getCollaborations();
List<Collaboration> orderedEdges = new ArrayList<Collaboration>(edges); List<Collaboration> orderedEdges = new ArrayList<Collaboration>(edges);
Collections.sort(orderedEdges, new CollaborationComparator()); orderedEdges.sort(new CollaborationComparator());
for (Collaboration currentEdge : orderedEdges) { for (Collaboration currentEdge : orderedEdges) {
/* /*
@ -218,7 +213,7 @@ public class CoPIGraphMLWriter {
List<Collaborator> orderedPINodes = new ArrayList<Collaborator>(piNodes); List<Collaborator> orderedPINodes = new ArrayList<Collaborator>(piNodes);
orderedPINodes.remove(egoNode); orderedPINodes.remove(egoNode);
Collections.sort(orderedPINodes, new CollaboratorComparator()); orderedPINodes.sort(new CollaboratorComparator());
for (Collaborator currNode : orderedPINodes) { for (Collaborator currNode : orderedPINodes) {

View file

@ -111,14 +111,11 @@ public class CoPIVisCodeGenerator {
try { try {
minGrantYear = Integer.parseInt(Collections minGrantYear = Integer.parseInt(Collections
.min(investigatedYears)); .min(investigatedYears));
} catch (NoSuchElementException e1) { } catch (NoSuchElementException | NumberFormatException e1) {
log.debug("vis: " + e1.getMessage() + " error occurred for " log.debug("vis: " + e1.getMessage() + " error occurred for "
+ yearToUniqueCoPIs.toString()); + yearToUniqueCoPIs.toString());
} catch (NumberFormatException e2) {
log.debug("vis: " + e2.getMessage() + " error occurred for "
+ yearToUniqueCoPIs.toString());
} }
} }
int minGrantYearConsidered = 0; int minGrantYearConsidered = 0;

View file

@ -9,6 +9,11 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.jena.query.QuerySolution; import org.apache.jena.query.QuerySolution;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
@ -26,7 +31,6 @@ import org.apache.commons.lang3.StringEscapeUtils;
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 com.google.gson.Gson;
import org.apache.jena.query.Dataset; import org.apache.jena.query.Dataset;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
@ -164,7 +168,7 @@ public class MapOfScienceVisualizationRequestHandler implements VisualizationReq
private Map<String, String> getSubjectPersonEntityAndGenerateDataResponse( private Map<String, String> getSubjectPersonEntityAndGenerateDataResponse(
VitroRequest vitroRequest, String subjectEntityURI, String entityLabel, VisConstants.DataVisMode dataOuputFormat) VitroRequest vitroRequest, String subjectEntityURI, String entityLabel, VisConstants.DataVisMode dataOuputFormat)
throws MalformedQueryParametersException { throws MalformedQueryParametersException, JsonProcessingException {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
try { try {
@ -191,7 +195,6 @@ public class MapOfScienceVisualizationRequestHandler implements VisualizationReq
Map<String, String> fileData = new HashMap<String, String>(); Map<String, String> fileData = new HashMap<String, String>();
if (VisConstants.DataVisMode.JSON.equals(dataOuputFormat)) { if (VisConstants.DataVisMode.JSON.equals(dataOuputFormat)) {
Gson json = new Gson();
Set jsonContent = new HashSet(); Set jsonContent = new HashSet();
MapOfScience entityJson = new MapOfScience(subjectEntityURI); MapOfScience entityJson = new MapOfScience(subjectEntityURI);
@ -203,8 +206,10 @@ public class MapOfScienceVisualizationRequestHandler implements VisualizationReq
jsonContent.add(entityJson); jsonContent.add(entityJson);
ObjectMapper mapper = new ObjectMapper();
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY, "application/octet-stream"); fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY, "application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY, json.toJson(jsonContent)); fileData.put(DataVisualizationController.FILE_CONTENT_KEY, mapper.writeValueAsString(jsonContent));
} else { } else {
if (StringUtils.isBlank(entityLabel)) { if (StringUtils.isBlank(entityLabel)) {
entityLabel = "no-name"; entityLabel = "no-name";
@ -239,7 +244,7 @@ public class MapOfScienceVisualizationRequestHandler implements VisualizationReq
private Map<String, String> getSubjectEntityAndGenerateDataResponse( private Map<String, String> getSubjectEntityAndGenerateDataResponse(
VitroRequest vitroRequest, String subjectEntityURI, String entityLabel, VisConstants.DataVisMode dataOuputFormat) VitroRequest vitroRequest, String subjectEntityURI, String entityLabel, VisConstants.DataVisMode dataOuputFormat)
throws MalformedQueryParametersException { throws MalformedQueryParametersException, JsonProcessingException {
RDFService rdfService = vitroRequest.getRDFService(); RDFService rdfService = vitroRequest.getRDFService();
@ -290,7 +295,6 @@ public class MapOfScienceVisualizationRequestHandler implements VisualizationReq
Map<String, String> fileData = new HashMap<String, String>(); Map<String, String> fileData = new HashMap<String, String>();
if (VisConstants.DataVisMode.JSON.equals(dataOuputFormat)) { if (VisConstants.DataVisMode.JSON.equals(dataOuputFormat)) {
Gson json = new Gson();
Set jsonContent = new HashSet(); Set jsonContent = new HashSet();
MapOfScience entityJson = new MapOfScience(subjectEntityURI); MapOfScience entityJson = new MapOfScience(subjectEntityURI);
@ -312,8 +316,10 @@ public class MapOfScienceVisualizationRequestHandler implements VisualizationReq
jsonContent.add(entityJson); jsonContent.add(entityJson);
ObjectMapper mapper = new ObjectMapper();
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY, "application/octet-stream"); fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY, "application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY, json.toJson(jsonContent)); fileData.put(DataVisualizationController.FILE_CONTENT_KEY, mapper.writeValueAsString(jsonContent));
} else { } else {
if (StringUtils.isBlank(entityLabel)) { if (StringUtils.isBlank(entityLabel)) {
entityLabel = "no-organization"; entityLabel = "no-organization";
@ -356,26 +362,25 @@ public class MapOfScienceVisualizationRequestHandler implements VisualizationReq
return fileData; return fileData;
} }
private Map<String, String> prepareStandaloneDataErrorResponse() { private Map<String, String> prepareStandaloneDataErrorResponse() throws JsonProcessingException {
GenericQueryMap errorDataResponse = new GenericQueryMap(); GenericQueryMap errorDataResponse = new GenericQueryMap();
errorDataResponse.addEntry("error", "No Publications for this Entity found in VIVO."); errorDataResponse.addEntry("error", "No Publications for this Entity found in VIVO.");
Gson jsonErrorResponse = new Gson();
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,
"application/octet-stream"); "application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY, jsonErrorResponse.toJson(errorDataResponse)); ObjectMapper mapper = new ObjectMapper();
fileData.put(DataVisualizationController.FILE_CONTENT_KEY, mapper.writeValueAsString(errorDataResponse));
return fileData; return fileData;
} }
@Override @Override
public Map<String, String> generateDataVisualization(VitroRequest vitroRequest, Log log, Dataset dataset) public Map<String, String> generateDataVisualization(VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException, JsonProcessingException {
String entityURI = vitroRequest.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY); String entityURI = vitroRequest.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);

View file

@ -9,10 +9,11 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.cornell.mannlib.vitro.webapp.visualization.utilities.VisualizationCaches; import edu.cornell.mannlib.vitro.webapp.visualization.utilities.VisualizationCaches;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import com.google.gson.Gson;
import org.apache.jena.query.Dataset; import org.apache.jena.query.Dataset;
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
@ -35,7 +36,7 @@ public class ModelConstructorRequestHandler implements
@Override @Override
public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log, public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log,
Dataset dataSource) throws MalformedQueryParametersException { Dataset dataSource) throws MalformedQueryParametersException, JsonProcessingException {
return regenerateConstructedModels(vitroRequest, dataSource); return regenerateConstructedModels(vitroRequest, dataSource);
} }
@ -82,7 +83,7 @@ public class ModelConstructorRequestHandler implements
} }
private Map<String, String> regenerateConstructedModels(VitroRequest vitroRequest, private Map<String, String> regenerateConstructedModels(VitroRequest vitroRequest,
Dataset dataSource) { Dataset dataSource) throws JsonProcessingException {
VisualizationCaches.rebuildAll(vitroRequest.getRDFService()); VisualizationCaches.rebuildAll(vitroRequest.getRDFService());
@ -103,23 +104,19 @@ public class ModelConstructorRequestHandler implements
parseModelIdentifier.getType(), vitroRequest.getRDFService()); parseModelIdentifier.getType(), vitroRequest.getRDFService());
refreshedModels.add(parseModelIdentifier); refreshedModels.add(parseModelIdentifier);
} catch (IllegalConstructedModelIdentifierException e) { } catch (IllegalConstructedModelIdentifierException | MalformedQueryParametersException e) {
e.printStackTrace();
} catch (MalformedQueryParametersException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
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,
"application/octet-stream"); "application/octet-stream");
Gson json = new Gson(); ObjectMapper mapper = new ObjectMapper();
fileData.put(DataVisualizationController.FILE_CONTENT_KEY, fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
json.toJson(refreshedModels)); mapper.writeValueAsString(refreshedModels));
return fileData; return fileData;
} }

View file

@ -112,7 +112,7 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
UtilityFunctions.getYearToActivityCount(authorGrants); UtilityFunctions.getYearToActivityCount(authorGrants);
boolean shouldVIVOrenderVis = yearToGrantCount.size() > 0 ? true : false; boolean shouldVIVOrenderVis = (yearToGrantCount.size() > 0);
/* /*
* Computations required to generate HTML for the sparkline & related context. * Computations required to generate HTML for the sparkline & related context.

View file

@ -102,14 +102,11 @@ public class PersonGrantCountVisCodeGenerator {
try { try {
minGrantYear = Integer.parseInt(Collections minGrantYear = Integer.parseInt(Collections
.min(grantYears)); .min(grantYears));
} catch (NoSuchElementException e1) { } catch (NoSuchElementException | NumberFormatException e1) {
log.debug("vis: " + e1.getMessage() + " error occurred for " log.debug("vis: " + e1.getMessage() + " error occurred for "
+ yearToGrantCount.toString()); + yearToGrantCount.toString());
} catch (NumberFormatException e2) {
log.debug("vis: " + e2.getMessage() + " error occurred for "
+ yearToGrantCount.toString());
} }
} }
int minGrantYearConsidered = 0; int minGrantYearConsidered = 0;

View file

@ -5,7 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.visualization.personlevel;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CoAuthorshipData; import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CoAuthorshipData;
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CoInvestigationData; import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CoInvestigationData;
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.CollaborationDataViewHelper; import edu.cornell.mannlib.vitro.webapp.visualization.visutils.CollaborationDataViewHelper;

View file

@ -7,7 +7,6 @@ import java.util.Set;
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.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.vocabulary.RDFS; import org.apache.jena.vocabulary.RDFS;
@ -20,21 +19,17 @@ import org.apache.jena.iri.IRI;
import org.apache.jena.iri.IRIFactory; import org.apache.jena.iri.IRIFactory;
import org.apache.jena.iri.Violation; import org.apache.jena.iri.Violation;
import org.apache.jena.query.Dataset;
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.Syntax; import org.apache.jena.query.Syntax;
import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.rdf.model.RDFNode;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants; import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels;
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException; import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity; import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Individual;
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.QueryRunner; import edu.cornell.mannlib.vitro.webapp.visualization.visutils.QueryRunner;

View file

@ -21,7 +21,6 @@ import edu.cornell.mannlib.vitro.webapp.controller.visualization.DataVisualizati
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.exceptions.MalformedQueryParametersException; import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity; import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Individual;
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.visutils.QueryRunner; import edu.cornell.mannlib.vitro.webapp.visualization.visutils.QueryRunner;
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions; import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions;

View file

@ -103,14 +103,11 @@ public class PersonPublicationCountVisCodeGenerator {
if (yearToPublicationCount.size() > 0) { if (yearToPublicationCount.size() > 0) {
try { try {
minPublishedYear = Integer.parseInt(Collections.min(publishedYears)); minPublishedYear = Integer.parseInt(Collections.min(publishedYears));
} catch (NoSuchElementException e1) { } catch (NoSuchElementException | NumberFormatException e1) {
log.debug("vis: " + e1.getMessage() + " error occurred for " log.debug("vis: " + e1.getMessage() + " error occurred for "
+ yearToPublicationCount.toString()); + yearToPublicationCount.toString());
} catch (NumberFormatException e2) {
log.debug("vis: " + e2.getMessage() + " error occurred for "
+ yearToPublicationCount.toString());
} }
} }
int minPubYearConsidered = 0; int minPubYearConsidered = 0;
@ -233,4 +230,4 @@ public class PersonPublicationCountVisCodeGenerator {
public SparklineData getValueObjectContainer() { public SparklineData getValueObjectContainer() {
return this.sparklineParameterVO; return this.sparklineParameterVO;
} }
} }

View file

@ -5,7 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.visualization.setup;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.visualization.utilities.CachingRDFServiceExecutor; import edu.cornell.mannlib.vitro.webapp.visualization.utilities.CachingRDFServiceExecutor;
import edu.cornell.mannlib.vitro.webapp.visualization.utilities.VisualizationCaches;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextEvent;

View file

@ -27,40 +27,14 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.QueryRunner;
public class OrganizationUtilityFunctions { public class OrganizationUtilityFunctions {
public static String getHighestLevelOrganizationURI(ResultSet resultSet, public static String getHighestLevelOrganizationURI(ResultSet resultSet, Map<String, String> fieldLabelToOutputFieldLabel) {
Map<String, String> fieldLabelToOutputFieldLabel) {
GenericQueryMap queryResult = new GenericQueryMap();
while (resultSet.hasNext()) { while (resultSet.hasNext()) {
QuerySolution solution = resultSet.nextSolution(); QuerySolution solution = resultSet.nextSolution();
RDFNode organizationNode = solution RDFNode organizationNode = solution.get(fieldLabelToOutputFieldLabel.get("organization"));
.get(fieldLabelToOutputFieldLabel.get("organization"));
if (organizationNode != null) { if (organizationNode != null) {
queryResult.addEntry(
fieldLabelToOutputFieldLabel.get("organization"),
organizationNode.toString());
return organizationNode.toString(); return organizationNode.toString();
}
RDFNode organizationLabelNode = solution
.get(fieldLabelToOutputFieldLabel.get("organizationLabel"));
if (organizationLabelNode != null) {
queryResult.addEntry(
fieldLabelToOutputFieldLabel.get("organizationLabel"),
organizationLabelNode.toString());
}
RDFNode numberOfChildrenNode = solution.getLiteral("numOfChildren");
if (numberOfChildrenNode != null) {
queryResult.addEntry("numOfChildren", String
.valueOf(numberOfChildrenNode.asLiteral().getInt()));
} }
} }

View file

@ -10,6 +10,11 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.visualization.model.OrganizationPeopleMap; import edu.cornell.mannlib.vitro.webapp.visualization.model.OrganizationPeopleMap;
import edu.cornell.mannlib.vitro.webapp.visualization.utilities.CounterUtils; import edu.cornell.mannlib.vitro.webapp.visualization.utilities.CounterUtils;
@ -19,7 +24,6 @@ import org.apache.commons.lang3.StringEscapeUtils;
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 com.google.gson.Gson;
import org.apache.jena.query.Dataset; import org.apache.jena.query.Dataset;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
@ -77,7 +81,7 @@ public class TemporalGrantVisualizationRequestHandler implements
@Override @Override
public Map<String, String> generateDataVisualization(VitroRequest vitroRequest, Log log, Dataset dataset) public Map<String, String> generateDataVisualization(VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException, JsonProcessingException {
String entityURI = vitroRequest.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY); String entityURI = vitroRequest.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
@ -137,7 +141,7 @@ public class TemporalGrantVisualizationRequestHandler implements
private Map<String, String> getSubjectEntityAndGenerateDataResponse( private Map<String, String> getSubjectEntityAndGenerateDataResponse(
VitroRequest vitroRequest, Log log, Dataset dataset, VitroRequest vitroRequest, Log log, Dataset dataset,
String subjectEntityURI, VisConstants.DataVisMode visMode) String subjectEntityURI, VisConstants.DataVisMode visMode)
throws MalformedQueryParametersException { throws MalformedQueryParametersException, JsonProcessingException {
RDFService rdfService = vitroRequest.getRDFService(); RDFService rdfService = vitroRequest.getRDFService();
@ -184,7 +188,6 @@ public class TemporalGrantVisualizationRequestHandler implements
Map<String, String> fileData = new HashMap<String, String>(); Map<String, String> fileData = new HashMap<String, String>();
if (VisConstants.DataVisMode.JSON.equals(visMode)) { if (VisConstants.DataVisMode.JSON.equals(visMode)) {
Gson json = new Gson();
Set subEntitiesJson = new HashSet(); Set subEntitiesJson = new HashSet();
// For each suborganisation // For each suborganisation
@ -234,8 +237,10 @@ public class TemporalGrantVisualizationRequestHandler implements
subEntitiesJson.add(subjectEntityJSON); subEntitiesJson.add(subjectEntityJSON);
ObjectMapper mapper = new ObjectMapper();
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY, "application/octet-stream"); fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY, "application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY, json.toJson(subEntitiesJson)); fileData.put(DataVisualizationController.FILE_CONTENT_KEY, mapper.writeValueAsString(subEntitiesJson));
} else { } else {
String entityLabel = orgLabelMap.get(subjectEntityURI); String entityLabel = orgLabelMap.get(subjectEntityURI);

View file

@ -10,6 +10,11 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.visualization.model.OrganizationPeopleMap; import edu.cornell.mannlib.vitro.webapp.visualization.model.OrganizationPeopleMap;
import edu.cornell.mannlib.vitro.webapp.visualization.utilities.CounterUtils; import edu.cornell.mannlib.vitro.webapp.visualization.utilities.CounterUtils;
@ -19,7 +24,6 @@ import org.apache.commons.lang3.StringEscapeUtils;
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 com.google.gson.Gson;
import org.apache.jena.query.Dataset; import org.apache.jena.query.Dataset;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
@ -74,7 +78,7 @@ public class TemporalPublicationVisualizationRequestHandler implements
private Map<String, String> getSubjectEntityAndGenerateDataResponse( private Map<String, String> getSubjectEntityAndGenerateDataResponse(
VitroRequest vitroRequest, Log log, Dataset dataset, VitroRequest vitroRequest, Log log, Dataset dataset,
String subjectEntityURI, VisConstants.DataVisMode visMode) String subjectEntityURI, VisConstants.DataVisMode visMode)
throws MalformedQueryParametersException { throws MalformedQueryParametersException, JsonProcessingException {
RDFService rdfService = vitroRequest.getRDFService(); RDFService rdfService = vitroRequest.getRDFService();
@ -121,7 +125,6 @@ public class TemporalPublicationVisualizationRequestHandler implements
Map<String, String> fileData = new HashMap<String, String>(); Map<String, String> fileData = new HashMap<String, String>();
if (VisConstants.DataVisMode.JSON.equals(visMode)) { if (VisConstants.DataVisMode.JSON.equals(visMode)) {
Gson json = new Gson();
Set subEntitiesJson = new HashSet(); Set subEntitiesJson = new HashSet();
// For each suborganisation // For each suborganisation
@ -171,8 +174,10 @@ public class TemporalPublicationVisualizationRequestHandler implements
subEntitiesJson.add(subjectEntityJSON); subEntitiesJson.add(subjectEntityJSON);
ObjectMapper mapper = new ObjectMapper();
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY, "application/octet-stream"); fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY, "application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY, json.toJson(subEntitiesJson)); fileData.put(DataVisualizationController.FILE_CONTENT_KEY, mapper.writeValueAsString(subEntitiesJson));
} else { } else {
String entityLabel = orgLabelMap.get(subjectEntityURI); String entityLabel = orgLabelMap.get(subjectEntityURI);
@ -240,7 +245,7 @@ public class TemporalPublicationVisualizationRequestHandler implements
@Override @Override
public Map<String, String> generateDataVisualization(VitroRequest vitroRequest, Log log, Dataset dataset) public Map<String, String> generateDataVisualization(VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException, JsonProcessingException {
String entityURI = vitroRequest.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY); String entityURI = vitroRequest.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
@ -308,4 +313,4 @@ public class TemporalPublicationVisualizationRequestHandler implements
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
} }

View file

@ -5,7 +5,11 @@ package edu.cornell.mannlib.vitro.webapp.visualization.utilities;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.cornell.mannlib.vitro.webapp.rdfservice.ResultSetConsumer; import edu.cornell.mannlib.vitro.webapp.rdfservice.ResultSetConsumer;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -14,7 +18,6 @@ import org.apache.jena.iri.IRIFactory;
import org.apache.jena.iri.Violation; import org.apache.jena.iri.Violation;
import org.vivoweb.webapp.util.ModelUtils; import org.vivoweb.webapp.util.ModelUtils;
import com.google.gson.Gson;
import org.apache.jena.query.Dataset; import org.apache.jena.query.Dataset;
import org.apache.jena.query.QuerySolution; import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.ResultSet; import org.apache.jena.query.ResultSet;
@ -34,7 +37,6 @@ import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryP
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.GenericQueryMap; import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.GenericQueryMap;
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.AllPropertiesQueryRunner; import edu.cornell.mannlib.vitro.webapp.visualization.visutils.AllPropertiesQueryRunner;
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.GenericQueryRunner; import edu.cornell.mannlib.vitro.webapp.visualization.visutils.GenericQueryRunner;
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.QueryRunner;
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions; 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;
@ -52,8 +54,8 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
public Object generateAjaxVisualization(VitroRequest vitroRequest, public Object generateAjaxVisualization(VitroRequest vitroRequest,
Log log, Log log,
Dataset dataset) Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException, JsonProcessingException {
String individualURI = vitroRequest.getParameter( String individualURI = vitroRequest.getParameter(
VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY); VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
@ -81,11 +83,11 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
GenericQueryMap profilePropertiesToValues = GenericQueryMap profilePropertiesToValues =
profileQueryHandler.getQueryResult(); profileQueryHandler.getQueryResult();
Gson profileInformation = new Gson(); ObjectMapper mapper = new ObjectMapper();
return profileInformation.toJson(profilePropertiesToValues); return mapper.writeValueAsString(profilePropertiesToValues);
} else if (VisualizationFrameworkConstants.IMAGE_UTILS_VIS_MODE } else if (VisualizationFrameworkConstants.IMAGE_UTILS_VIS_MODE
.equalsIgnoreCase(visMode)) { .equalsIgnoreCase(visMode)) {
@ -139,13 +141,14 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
whereClause, whereClause,
groupOrderClause, groupOrderClause,
dataset); dataset);
Gson publicationsInformation = new Gson();
NumPubsForIndividualConsumer consumer = new NumPubsForIndividualConsumer(); NumPubsForIndividualConsumer consumer = new NumPubsForIndividualConsumer();
numberOfPublicationsQueryHandler.sparqlSelectQuery(vitroRequest.getRDFService(), consumer); numberOfPublicationsQueryHandler.sparqlSelectQuery(vitroRequest.getRDFService(), consumer);
return publicationsInformation.toJson(consumer.getMap());
ObjectMapper mapper = new ObjectMapper();
return mapper.writeValueAsString(consumer.getMap());
} else if (VisualizationFrameworkConstants.ARE_GRANTS_AVAILABLE_UTILS_VIS_MODE } else if (VisualizationFrameworkConstants.ARE_GRANTS_AVAILABLE_UTILS_VIS_MODE
.equalsIgnoreCase(visMode)) { .equalsIgnoreCase(visMode)) {
@ -181,12 +184,11 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
"", "",
dataset); dataset);
Gson grantsInformation = new Gson();
NumGrantsForIndividualConsumer consumer = new NumGrantsForIndividualConsumer(); NumGrantsForIndividualConsumer consumer = new NumGrantsForIndividualConsumer();
numberOfGrantsQueryHandler.sparqlSelectQuery(vitroRequest.getRDFService(), consumer); numberOfGrantsQueryHandler.sparqlSelectQuery(vitroRequest.getRDFService(), consumer);
return grantsInformation.toJson(consumer.getMap()); ObjectMapper mapper = new ObjectMapper();
return mapper.writeValueAsString(consumer.getMap());
} else if (VisualizationFrameworkConstants.COAUTHOR_UTILS_VIS_MODE } else if (VisualizationFrameworkConstants.COAUTHOR_UTILS_VIS_MODE
.equalsIgnoreCase(visMode)) { .equalsIgnoreCase(visMode)) {
@ -352,7 +354,6 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
private VitroRequest vitroRequest; private VitroRequest vitroRequest;
private Map<String, String> fieldLabelToOutputFieldLabel; private Map<String, String> fieldLabelToOutputFieldLabel;
private String topLevelURL = null; private String topLevelURL = null;
private GenericQueryMap queryResult = new GenericQueryMap();
HighetTopLevelOrgTemporalGraphURLConsumer(VitroRequest vitroRequest, Map<String, String> fieldLabelToOutputFieldLabel) { HighetTopLevelOrgTemporalGraphURLConsumer(VitroRequest vitroRequest, Map<String, String> fieldLabelToOutputFieldLabel) {
this.vitroRequest = vitroRequest; this.vitroRequest = vitroRequest;
@ -368,8 +369,6 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
RDFNode organizationNode = qs.get(fieldLabelToOutputFieldLabel.get("organization")); RDFNode organizationNode = qs.get(fieldLabelToOutputFieldLabel.get("organization"));
if (organizationNode != null) { if (organizationNode != null) {
queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organization"), organizationNode.toString());
String individualLocalName = UtilityFunctions.getIndividualLocalName(organizationNode.toString(), vitroRequest); String individualLocalName = UtilityFunctions.getIndividualLocalName(organizationNode.toString(), vitroRequest);
if (StringUtils.isNotBlank(individualLocalName)) { if (StringUtils.isNotBlank(individualLocalName)) {
@ -390,19 +389,6 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
highestLevelOrganizationTemporalGraphVisURLParams); highestLevelOrganizationTemporalGraphVisURLParams);
} }
} else {
RDFNode organizationLabelNode = qs.get(fieldLabelToOutputFieldLabel.get("organizationLabel"));
if (organizationLabelNode != null) {
queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organizationLabel"), organizationLabelNode.toString());
}
RDFNode numberOfChildrenNode = qs.getLiteral("numOfChildren");
if (numberOfChildrenNode != null) {
queryResult.addEntry("numOfChildren",
String.valueOf(numberOfChildrenNode.asLiteral().getInt()));
}
} }
} }

View file

@ -8,7 +8,6 @@ import org.apache.jena.query.QuerySolution;
import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Literal;
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.RDFNode;
import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.Resource;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.rdfservice.ResultSetConsumer; import edu.cornell.mannlib.vitro.webapp.rdfservice.ResultSetConsumer;

View file

@ -1,6 +1,9 @@
/* $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.valueobjects.json; package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.json;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -11,13 +14,24 @@ import java.util.Set;
* @author bkoniden * @author bkoniden
* Deepak Konidena * Deepak Konidena
*/ */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class JsonObject { public class JsonObject {
@JsonProperty
private String label; private String label;
@JsonProperty
private String lastCachedAtDateTime; private String lastCachedAtDateTime;
@JsonProperty
private List<List<Integer>> data = new ArrayList<List<Integer>>(); private List<List<Integer>> data = new ArrayList<List<Integer>>();
@JsonProperty
private String entityURI; private String entityURI;
@JsonProperty
private String visMode; private String visMode;
@JsonProperty
private List<String> organizationType = new ArrayList<String>(); private List<String> organizationType = new ArrayList<String>();
public List<String> getOrganizationTypes() { public List<String> getOrganizationTypes() {
@ -29,9 +43,7 @@ public class JsonObject {
} }
public void setOrganizationTypes(Set<String> givenOrganizationType) { public void setOrganizationTypes(Set<String> givenOrganizationType) {
for (String type : givenOrganizationType) { this.organizationType.addAll(givenOrganizationType);
this.organizationType.add(type);
}
} }
public String getEntityURI() { public String getEntityURI() {

View file

@ -1,21 +1,41 @@
/* $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.valueobjects.json; package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.json;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class MapOfScience { public class MapOfScience {
@JsonProperty
private String uri; private String uri;
@JsonProperty
private String label; private String label;
@JsonProperty
private String type; private String type;
@JsonProperty
private int pubsMapped; private int pubsMapped;
@JsonProperty
private int pubsWithNoJournals; private int pubsWithNoJournals;
@JsonProperty
private int pubsWithInvalidJournals; private int pubsWithInvalidJournals;
@JsonProperty
private String lastCachedAtDateTime; private String lastCachedAtDateTime;
@JsonProperty
private Map<Integer, Float> subdisciplineActivity = new HashMap<Integer, Float>(); private Map<Integer, Float> subdisciplineActivity = new HashMap<Integer, Float>();
@JsonProperty
private Set<SubEntityInfo> subEntities = new HashSet<SubEntityInfo>(); private Set<SubEntityInfo> subEntities = new HashSet<SubEntityInfo>();
public MapOfScience(String uri) { public MapOfScience(String uri) {
@ -84,11 +104,18 @@ public class MapOfScience {
return subEntities; return subEntities;
} }
@JsonInclude(JsonInclude.Include.NON_NULL)
private class SubEntityInfo { private class SubEntityInfo {
@JsonProperty
private String uri; private String uri;
@JsonProperty
private String label; private String label;
@JsonProperty
private String type; private String type;
@JsonProperty
private int pubs; private int pubs;
public SubEntityInfo(String uri, String label, String type, int pubs) { public SubEntityInfo(String uri, String label, String type, int pubs) {
@ -129,7 +156,5 @@ public class MapOfScience {
public void setPubs(int pubs) { public void setPubs(int pubs) {
this.pubs = pubs; this.pubs = pubs;
} }
} }
} }

View file

@ -5,12 +5,19 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Individual; import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Individual;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SubjectEntityJSON { public class SubjectEntityJSON {
@JsonProperty
private String subjectEntityLabel; private String subjectEntityLabel;
@JsonProperty
private String subjectEntityURI; private String subjectEntityURI;
@JsonProperty
private Map<String, String> parentURIToLabel = new HashMap<String, String>(); private Map<String, String> parentURIToLabel = new HashMap<String, String>();
public SubjectEntityJSON(String subjectEntityURI, String label, public SubjectEntityJSON(String subjectEntityURI, String label,

View file

@ -12,13 +12,7 @@ import org.apache.jena.iri.IRI;
import org.apache.jena.iri.IRIFactory; import org.apache.jena.iri.IRIFactory;
import org.apache.jena.iri.Violation; import org.apache.jena.iri.Violation;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryExecutionFactory;
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.Syntax; import org.apache.jena.query.Syntax;
import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.rdf.model.RDFNode;
@ -78,7 +72,7 @@ public class AllPropertiesQueryRunner implements QueryRunner<GenericQueryMap> {
+ filterClause + filterClause
+ "}"; + "}";
log.debug("sparqlQuery = " + sparqlQuery.toString()); log.debug("sparqlQuery = " + sparqlQuery);
return sparqlQuery; return sparqlQuery;
} }

View file

@ -102,12 +102,6 @@ public class CollaborationDataViewHelper {
// Now add the person that is the focus to the start of the list // Now add the person that is the focus to the start of the list
collaborators.add(0, data.getEgoCollaborator()); collaborators.add(0, data.getEgoCollaborator());
// Generate a list of collaborator IDs for use in filling the matrix
List<Integer> collabIDs = new ArrayList<Integer>(collaborators.size());
for (Collaborator collaborator : collaborators) {
collabIDs.add(collaborator.getCollaboratorID());
}
// If we only want to visualize collaborations between the main focus and others, set this to false // If we only want to visualize collaborations between the main focus and others, set this to false
boolean fullMatrix = true; boolean fullMatrix = true;

View file

@ -76,12 +76,11 @@ public class GenericQueryRunner implements QueryRunner<ResultSet> {
for (Map.Entry<String, String> currentfieldLabelToOutputFieldLabel for (Map.Entry<String, String> currentfieldLabelToOutputFieldLabel
: this.fieldLabelToOutputFieldLabel.entrySet()) { : this.fieldLabelToOutputFieldLabel.entrySet()) {
sparqlQuery.append("\t(str(?" + currentfieldLabelToOutputFieldLabel.getKey() + ") as ?" sparqlQuery.append("\t(str(?").append(currentfieldLabelToOutputFieldLabel.getKey()).append(") as ?").append(currentfieldLabelToOutputFieldLabel.getValue()).append(")\n");
+ currentfieldLabelToOutputFieldLabel.getValue() + ")\n");
} }
sparqlQuery.append("\n" + this.aggregationRules + "\n"); sparqlQuery.append("\n").append(this.aggregationRules).append("\n");
sparqlQuery.append("WHERE {\n"); sparqlQuery.append("WHERE {\n");

Some files were not shown because too many files have changed in this diff Show more