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 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
There are several ways to contact the VIVO community.
Whatever your interest, we would be pleased to hear from you.
#### Contact form
### Contact form
http://vivoweb.org/support/user-feedback
#### Mailing lists
##### [vivo-all](https://groups.google.com/forum/#!forum/vivo-all)
### Mailing lists
#### [vivo-all](https://groups.google.com/forum/#!forum/vivo-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
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.
Developers and implementers frequent this list to get the latest on feature design,
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>
<artifactId>vivo-api</artifactId>
<version>1.10.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.vivoweb</groupId>
<artifactId>vivo-project</artifactId>
<version>1.10.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
@ -30,20 +30,25 @@
<type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>fluent-hc</artifactId>
<version>4.5.3</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.0.6</version>
<version>5.5.12</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>2.5.6</version>
<version>4.3.11.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>2.5.6</version>
<version>4.3.11.RELEASE</version>
</dependency>
<dependency>
@ -52,15 +57,15 @@
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.vivoweb.dependencies</groupId>
<groupId>org.vivoweb</groupId>
<artifactId>orcid-api-client</artifactId>
<version>0.2</version>
<version>0.6.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -71,7 +76,7 @@
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxrpc</artifactId>
<artifactId>jaxrpc-api</artifactId>
<version>1.1</version>
</dependency>
@ -88,4 +93,26 @@
<scope>test</scope>
</dependency>
</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>

View file

@ -58,9 +58,9 @@ public class AgrovocService implements ExternalConceptService {
protected final String dbpedia_endpoint = " http://dbpedia.org/sparql";
// 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 conceptSkosMosURL = conceptSkosMosBase + "/agrovoc/data?";
protected final String conceptSkosMosURL = conceptSkosMosBase + "data?";
@Override
public List<Concept> getConcepts(String term) throws Exception {
List<Concept> conceptList = new ArrayList<Concept>();
@ -190,7 +190,7 @@ public class AgrovocService implements ExternalConceptService {
}
protected String getAgrovocTermCode(String rdf) throws Exception {
String termcode = new String();
String termcode = "";
try {
Document doc = XMLUtils.parse(rdf);
NodeList nodes = doc.getElementsByTagName("hasCodeAgrovoc");
@ -199,13 +199,7 @@ public class AgrovocService implements ExternalConceptService {
termcode = node.getTextContent();
}
} catch (SAXException e) {
// e.printStackTrace();
throw e;
} catch (ParserConfigurationException e) {
// e.printStackTrace();
throw e;
} catch (IOException e) {
} catch (SAXException | IOException | ParserConfigurationException e) {
// e.printStackTrace();
throw e;
}
@ -213,7 +207,7 @@ public class AgrovocService implements ExternalConceptService {
}
protected String getConceptURIFromRDF(String rdf) {
String conceptUri = new String();
String conceptUri = "";
try {
Document doc = XMLUtils.parse(rdf);
NodeList nodes = doc.getElementsByTagName("skos:Concept");
@ -222,13 +216,7 @@ public class AgrovocService implements ExternalConceptService {
NamedNodeMap attrs = node.getAttributes();
Attr idAttr = (Attr) attrs.getNamedItem("rdf:about");
conceptUri = idAttr.getTextContent();
} catch (IOException e) {
e.printStackTrace();
System.err.println("rdf: " + rdf);
} catch (SAXException e) {
e.printStackTrace();
System.err.println("rdf: " + rdf);
} catch (ParserConfigurationException e) {
} catch (IOException | ParserConfigurationException | SAXException e) {
e.printStackTrace();
System.err.println("rdf: " + rdf);
}
@ -254,13 +242,7 @@ public class AgrovocService implements ExternalConceptService {
}
} catch (IOException e) {
e.printStackTrace();
System.err.println("rdf: " + rdf);
} catch (SAXException e) {
e.printStackTrace();
System.err.println("rdf: " + rdf);
} catch (ParserConfigurationException e) {
} catch (IOException | ParserConfigurationException | SAXException e) {
e.printStackTrace();
System.err.println("rdf: " + rdf);
}
@ -270,7 +252,7 @@ public class AgrovocService implements ExternalConceptService {
protected String getDbpediaDescription(String uri) throws Exception {
String descriptionSource = " (Source: DBpedia)";
String description = new String();
String description = "";
String qs = ""
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \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
*/
protected String stripConceptId(String uri) {
String conceptId = new String();
String conceptId = "";
int lastslash = uri.lastIndexOf('/');
conceptId = uri.substring(lastslash + 1, uri.length());
return conceptId;

View file

@ -150,7 +150,7 @@ public class GemetService implements ExternalConceptService {
if (obj.has(key)) {
return obj.get(key).asText();
} else {
return new String("");
return "";
}
}
@ -160,7 +160,7 @@ public class GemetService implements ExternalConceptService {
* @throws Exception
*/
protected String getAvailableLangs(String concept_uri) throws Exception {
String result = new String();
String result = "";
String serviceUrl = GemetWS_address + "getAvailableLanguages" +
"?concept_uri=" + concept_uri;
try {
@ -177,7 +177,7 @@ public class GemetService implements ExternalConceptService {
* @throws Exception
*/
protected String getConcept(String concept_uri) throws Exception {
String result = new String();
String result = "";
String serviceUrl = GemetWS_address + "getConcept" +
"?concept_uri=" + concept_uri +
"&language=en";
@ -196,20 +196,27 @@ public class GemetService implements ExternalConceptService {
* @throws Exception
*/
protected String getAllTranslationsForConcept(String concept_uri, String property) throws Exception {
String result = new String();
String property_uri = new String();
if (property.equals("definition")) {
String result = "";
String property_uri = "";
switch (property) {
case "definition":
property_uri = definitionUri;
} else if (property.equals("preferredLabel")) {
break;
case "preferredLabel":
property_uri = prefLabelUri;
} else if (property.equals("scopeNote")) {
break;
case "scopeNote":
property_uri = scopeNoteUri;
} else if (property.equals("nonPreferredLabels")) {
break;
case "nonPreferredLabels":
property_uri = altLabelUri;
} else if (property.equals("example")) {
break;
case "example":
property_uri = exampleUri;
} else if (property.equals("acronymLabel")) {
break;
case "acronymLabel":
property_uri = acronymLabelUri;
break;
}
String serviceUrl = GemetWS_address + "getAllTranslationsForConcept" +
@ -234,14 +241,18 @@ public class GemetService implements ExternalConceptService {
* @throws Exception
*/
protected String getRelatedConcepts(String concept_uri, String relation) throws Exception {
String result = new String();
String relation_uri = new String();
if (relation.equals("broader")) {
String result = "";
String relation_uri = "";
switch (relation) {
case "broader":
relation_uri = broaderUri;
} else if (relation.equals("narrower")) {
break;
case "narrower":
relation_uri = narrowerUri;
} else if (relation.equals("related")) {
break;
case "related":
relation_uri = relatedUri;
break;
}
String serviceUrl = GemetWS_address + "getRelatedConcepts" +
"?concept_uri=" + concept_uri +
@ -263,7 +274,7 @@ public class GemetService implements ExternalConceptService {
* @throws Exception
*/
protected String getConceptsMatchingKeyword(String keyword) throws Exception {
String result = new String();
String result = "";
String encodedKeyword = URLEncoder.encode(keyword, "UTF-8");
String serviceUrl = GemetWS_address + "getConceptsMatchingKeyword" +
"?keyword=" + encodedKeyword +
@ -283,7 +294,7 @@ public class GemetService implements ExternalConceptService {
* @param url URI
*/
protected String getGemetResults(String url) throws Exception {
String results = new String();
String results = "";
//System.out.println("url: "+url);
try {
@ -310,7 +321,7 @@ public class GemetService implements ExternalConceptService {
protected List<String> getRelatedUris(String json) {
List<String> uriList = new ArrayList<String>();
String uri = new String();
String uri = "";
ArrayNode jsonArray = (ArrayNode) JacksonUtils.parseJson(json);
if (jsonArray.size() == 0) {
return new ArrayList<String>();
@ -338,7 +349,7 @@ public class GemetService implements ExternalConceptService {
}
protected String stripConceptId(String uri) {
String conceptId = new String();
String conceptId = "";
int lastslash = uri.lastIndexOf('/');
conceptId = uri.substring(lastslash + 1, uri.length());
return conceptId;

View file

@ -176,7 +176,7 @@ public class LCSHService implements ExternalConceptService {
protected List<String> getConceptURIFromXML(String rdf) {
List<String> uris = new ArrayList<String>();
String conceptUri = new String();
String conceptUri = "";
try {
Document doc = XMLUtils.parse(rdf);
NodeList nodes = doc.getElementsByTagName("entry");
@ -202,13 +202,8 @@ public class LCSHService implements ExternalConceptService {
uris.add(conceptUri);
}
} catch (IOException e) {
} catch (IOException | ParserConfigurationException | SAXException 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;
@ -222,7 +217,7 @@ public class LCSHService implements ExternalConceptService {
* @param uri URI
*/
protected String stripConceptId(String uri) {
String conceptId = new String();
String conceptId = "";
int lastslash = uri.lastIndexOf('/');
conceptId = uri.substring(lastslash + 1, uri.length());
return conceptId;

View file

@ -2,13 +2,11 @@
package edu.cornell.mannlib.semservices.service.impl;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.net.URL;
import java.net.URLEncoder;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -20,6 +18,11 @@ import edu.cornell.mannlib.semservices.bo.Concept;
import edu.cornell.mannlib.semservices.exceptions.ConceptsNotFoundException;
import edu.cornell.mannlib.semservices.service.ExternalConceptService;
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
@ -27,37 +30,80 @@ import edu.cornell.mannlib.vitro.webapp.utils.json.JacksonUtils;
*/
public class UMLSService implements ExternalConceptService {
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";
private static String UTS_REST_API_URL = "https://uts-ws.nlm.nih.gov/rest";
private static String SEARCH_PATH = "/search/current";
private static String SEARCH_PARAMETER = "string";
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";
private static String ticketGrantingTicketURL = null;
private static long lastUpdate = -1;
private static String username = null;
private static String password = null;
private static String apikey = null;
private static String pageSize = "50";
private static String UMLS_AUTH_USER_URL = "https://utslogin.nlm.nih.gov/cas/v1/tickets";
private static String UMLS_AUTH_KEY_URL = "https://utslogin.nlm.nih.gov/cas/v1/api-key";
private static String UTS_SERVICE_URL = "http://umlsks.nlm.nih.gov";
{
if (username == null || apikey == null) {
final Properties properties = new Properties();
try (InputStream stream = getClass().getResourceAsStream("/umls.properties")) {
properties.load(stream);
username = properties.getProperty("username");
password = properties.getProperty("password");
apikey = properties.getProperty("apikey");
String exPageSize = properties.getProperty("pagesize");
try {
if (!StringUtils.isEmpty(exPageSize)) {
int iPageSize = Integer.parseInt(exPageSize, 10);
if (iPageSize > 5 && iPageSize < 200) {
pageSize = Integer.toString(iPageSize, 10);
}
}
} catch (Exception e) {
}
} catch (IOException e) {
}
}
}
public boolean isConfigured() {
return !(StringUtils.isEmpty(username) && StringUtils.isEmpty(apikey));
}
@Override
public List<Concept> getConcepts(String term) throws Exception {
String ticket = getSingleUseTicket();
List<Concept> conceptList = new ArrayList<Concept>();
String results = null;
String dataUrl = submissionUrl + "textToProcess="
+ URLEncoder.encode(term, "UTF-8")
+ "&format=json";
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);
StringWriter sw = new StringWriter();
URL rss = new URL(dataUrl);
results = Request.Get(b.build())
.connectTimeout(3000)
.socketTimeout(3000)
.execute().returnContent().asString();
BufferedReader in = new BufferedReader(new InputStreamReader(
rss.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
sw.write(inputLine);
}
in.close();
results = sw.toString();
//System.out.println("results before processing: "+results);
conceptList = processOutput(results);
return conceptList;
@ -68,39 +114,13 @@ public class UMLSService implements ExternalConceptService {
}
public List<Concept> processResults(String term) throws Exception {
String results = null;
String dataUrl = submissionUrl + "textToProcess="
+ URLEncoder.encode(term, "UTF-8") + "&format=json";
try {
StringWriter sw = new StringWriter();
URL rss = new URL(dataUrl);
BufferedReader in = new BufferedReader(new InputStreamReader(rss.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
sw.write(inputLine);
}
in.close();
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;
}
return getConcepts(term);
}
/**
* @param uri URI
*/
public List<Concept> getConceptsByURIWithSparql(String uri)
throws Exception {
public List<Concept> getConceptsByURIWithSparql(String uri) throws Exception {
// deprecating this method...just return an empty list
List<Concept> conceptList = new ArrayList<Concept>();
return conceptList;
@ -110,77 +130,37 @@ public class UMLSService implements ExternalConceptService {
* @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;
String bestMatchId = "";
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);
concept.setLabel(getJsonValue(o, "label"));
concept.setType(getJsonValue(o, "type"));
concept.setDefinition(getJsonValue(o, "definition"));
concept.setUri(baseUri + cui);
concept.setSchemeURI(schemeURI);
conceptList.add(concept);
}
}
if (json.has("All")) {
allFound = true;
ArrayNode allArray = (ArrayNode) json.get("All");
ArrayNode allArray = (ArrayNode) json.get("result").get("results");
int len = allArray.size();
//System.out.println("size of best match array: "+ len);
int i;
for (i = 0; i < len; 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.setType(getJsonValue(o, "type"));
concept.setDefinition(getJsonValue(o, "definition"));
concept.setUri(baseUri + cui);
concept.setSchemeURI(schemeURI);
// prevent duplicate concepts in list
if (! bestMatchIdList.contains(cui)) {
Concept concept = new Concept();
concept.setDefinedBy(UTS_SERVICE_URL);
concept.setSchemeURI(UTS_SERVICE_URL);
concept.setType(RETURN_TYPE);
concept.setConceptId(getJsonValue(o, "ui"));
concept.setLabel(getJsonValue(o, "name"));
concept.setUri(getJsonValue(o, "uri"));
concept.setBestMatch("false");
conceptList.add(concept);
}
}
}
} catch (Exception ex ) {
} catch (Exception ex) {
ex.printStackTrace();
logger.error("Could not get concepts", ex);
throw ex;
}
if (! bestMatchFound && !allFound) {
// we did not get a bestMatch or All element
if (conceptList.size() == 0) {
throw new ConceptsNotFoundException();
}
@ -191,6 +171,7 @@ public class UMLSService implements ExternalConceptService {
/**
* 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
*/
@ -198,17 +179,51 @@ public class UMLSService implements ExternalConceptService {
if (obj.has(key)) {
return obj.get(key).asText();
} else {
return new String("");
return "";
}
}
protected String stripConceptId(String uri) {
String conceptId = new String();
String conceptId = "";
int lastslash = uri.lastIndexOf('/');
conceptId = uri.substring(lastslash + 1, uri.length());
return conceptId;
}
private synchronized void getTicketGrantingTicket() {
if (StringUtils.isEmpty(username) && StringUtils.isEmpty(apikey)) {
throw new IllegalStateException("Unable to read umls.properties");
}
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.TemplateResponseValues;
import javax.servlet.annotation.WebServlet;
@WebServlet(name = "AboutQrCodesController", urlPatterns = {"/qrcode/about"})
public class AboutQrCodesController extends FreemarkerHttpServlet {
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.IndividualRequestInfo;
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.template.DefaultObjectWrapper;
import javax.servlet.annotation.WebServlet;
@WebServlet(name = "ExportQrCodeController", urlPatterns = {"/qrcode"})
public class ExportQrCodeController extends FreemarkerHttpServlet {
private static final long serialVersionUID = 1L;

View file

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

View file

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

View file

@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.ajax;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletResponse;
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
* this point just the mapping of geographic locations.
*/
@WebServlet(name = "HomePageAjax", urlPatterns = {"/homePageAjax"} )
public class HomePageAjaxController extends VitroAjaxController {
private static final Log log = LogFactory
.getLog(HomePageAjaxController.class);

View file

@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.ajax;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletResponse;
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
* this point just the mapping of geographic locations.
*/
@WebServlet(name = "QrCodeAjax", urlPatterns = {"/qrCodeAjax"} )
public class QrCodeAjaxController extends VitroAjaxController {
private static final Log log = LogFactory
.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.LogFactory;
import org.json.JSONException;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.ResultSet;
@ -54,7 +53,7 @@ public class QrCodeDetails extends AbstractAjaxResponder {
}
@Override
public String prepareResponse() throws IOException, JSONException {
public String prepareResponse() throws IOException {
try {
Individual individual = getIndividualFromRequest(vreq);
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.Map;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletResponse;
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
* has been successfully refactored and integrated with menu management.
*/
@WebServlet(name = "InstitutionalInternalClassController", urlPatterns = {"/processInstitutionalInternalClass"} )
public class InstitutionalInternalClassController extends FreemarkerHttpServlet {
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.jena.QueryUtils;
import javax.servlet.annotation.WebServlet;
@WebServlet(name = "ManageGrantsForIndividualController", urlPatterns = {"/manageGrants"} )
public class ManageGrantsForIndividualController extends FreemarkerHttpServlet {
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.jena.QueryUtils;
import javax.servlet.annotation.WebServlet;
@WebServlet(name = "ManagePeopleForOrganizationController", urlPatterns = {"/managePeople"} )
public class ManagePeopleForOrganizationController extends FreemarkerHttpServlet {
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.jena.QueryUtils;
import javax.servlet.annotation.WebServlet;
@WebServlet(name = "ManagePublicationsForIndividualController", urlPatterns = {"/managePublications"} )
public class ManagePublicationsForIndividualController extends FreemarkerHttpServlet {
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.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser;
@ -221,24 +219,24 @@ class CsvFileHarvestJob implements FileHarvestJob {
try {
int rowNum = 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) {
rowNum++;
if (false) {
numberFields = cRecord.size();
errorMsg += "file header items: ";
errorMsg.append("file header items: ");
for(int i = 0; i < cRecord.size(); i++) {
errorMsg += cRecord.get(i) + ", ";
errorMsg.append(cRecord.get(i)).append(", ");
}
} else {
if (cRecord.size() > 0) {
if(cRecord.size() != numberFields) {
if (errorMsg != null) {
errorMsg += "template items: ";
errorMsg.append("template items: ");
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();
}

View file

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

View file

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

View file

@ -6,9 +6,11 @@ import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -32,6 +34,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequ
* @author cdtank
*/
@SuppressWarnings("serial")
@WebServlet(name = "AjaxVisualizationController", urlPatterns = {"/visualizationAjax"})
public class AjaxVisualizationController extends FreemarkerHttpServlet {
public static final String URL_ENCODING_SCHEME = "UTF-8";
@ -138,7 +141,7 @@ public class AjaxVisualizationController extends FreemarkerHttpServlet {
return visRequestHandler.generateAjaxVisualization(vitroRequest,
log,
dataset);
} catch (MalformedQueryParametersException e) {
} catch (JsonProcessingException|MalformedQueryParametersException e) {
return UtilityFunctions.handleMalformedParameters(
"Ajax Visualization Query Error - Individual Publication Count",
e.getMessage(),

View file

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

View file

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

View file

@ -3,6 +3,7 @@
package edu.cornell.mannlib.vitro.webapp.controller.visualization;
import javax.servlet.ServletContext;
import javax.servlet.annotation.WebServlet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -27,6 +28,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.VisualizationRequ
* @author cdtank
*/
@SuppressWarnings("serial")
@WebServlet(name = "StandardVisualizationController", urlPatterns = {"/visualizationfm","/visualization"})
public class StandardVisualizationController extends FreemarkerHttpServlet {
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$ */
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.Map;

View file

@ -6,7 +6,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

View file

@ -8,8 +8,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.jena.rdf.model.Literal;
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) {
Collections.sort(concepts, new AssociatedConceptInfoComparator());
concepts.sort(new AssociatedConceptInfoComparator());
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.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
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.ResultSet;
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.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.dao.jena.QueryUtils;
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.EditConfigurationVTwo;
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;
import java.util.HashMap;
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.FieldOptions;

View file

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

View file

@ -1,10 +1,6 @@
/* $This file is distributed under the terms of the license in LICENSE$ */
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 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.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.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.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;
/**
* 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.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
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.ResultSet;
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.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.dao.jena.QueryUtils;
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.EditConfigurationVTwo;
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;
import java.util.ArrayList;
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;
@ -17,12 +14,8 @@ 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.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.fields.ChildVClassesOptions;
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;
public class AddFullNameToPersonGenerator extends VivoBaseGenerator implements

View file

@ -3,7 +3,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.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesOptions;
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;
import java.util.ArrayList;
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 org.apache.commons.logging.Log;
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.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.fields.ChildVClassesOptions;
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;
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.DateTimeWithPrecisionVTwo;
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.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator implements

View file

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

View file

@ -3,7 +3,6 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

View file

@ -3,24 +3,15 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpSession;
import org.apache.jena.vocabulary.XSD;
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.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.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.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
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.dao.VitroVocabulary;
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.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.IndividualsViaVClassOptions;
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.generators.EditModeUtils;

View file

@ -18,6 +18,7 @@ import java.util.Map;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -296,12 +297,12 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
//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
//already exists in that language
if(languageName != "untyped" && !existingLabelsLanguageNames.contains(languageName)) {
if(!"untyped".equals(languageName) && !existingLabelsLanguageNames.contains(languageName)) {
availableLocales.add(localeInfo);
}
}
//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) {
String languageName1 = (String) h1.get("label");
String languageName2 = (String) h2.get("label");
@ -368,7 +369,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
for(Literal l: labels) {
String languageTag = l.getLanguage();
String languageName = "";
if(languageTag == "") {
if(StringUtils.isEmpty(languageTag)) {
languageName = "untyped";
}
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");
}
if(languageName != "") {
if(!StringUtils.isEmpty(languageName)) {
if(!labelsHash.containsKey(languageName)) {
labelsHash.put(languageName, new ArrayList<LabelInformation>());
}
@ -397,7 +398,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
LabelInformationComparator lic = new LabelInformationComparator();
for(String languageName: labelsHash.keySet()) {
List<LabelInformation> labelInfo = labelsHash.get(languageName);
Collections.sort(labelInfo, lic);
labelInfo.sort(lic);
}
return labelsHash;

View file

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

View file

@ -2,12 +2,9 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.ArrayList;
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;
@ -17,12 +14,8 @@ 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.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.fields.ChildVClassesOptions;
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;
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.HashMap;
import java.util.Map;
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.DateTimeWithPrecisionVTwo;
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.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
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.DateTimeWithPrecisionVTwo;
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.IndividualsViaVClassOptions;
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.generators.EditModeUtils;

View file

@ -2,12 +2,9 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.ArrayList;
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;
@ -17,12 +14,8 @@ 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.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.fields.ChildVClassesOptions;
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;
public class PersonHasPreferredTitleGenerator extends VivoBaseGenerator implements

View file

@ -11,15 +11,9 @@ import javax.servlet.http.HttpSession;
import org.apache.jena.vocabulary.XSD;
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.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.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.IndividualsViaVClassOptions;
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.generators.EditModeUtils;

View file

@ -2,12 +2,9 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.ArrayList;
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;
@ -17,12 +14,8 @@ 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.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.fields.ChildVClassesOptions;
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;
public class SubjectHasMailingAddressGenerator extends VivoBaseGenerator implements

View file

@ -2,18 +2,14 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.ArrayList;
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 org.apache.commons.logging.Log;
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.Model;
@ -22,12 +18,8 @@ import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.vocabulary.XSD;
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.fields.ChildVClassesOptions;
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;
public class SubjectHasPhoneFaxNumberGenerator extends VivoBaseGenerator implements

View file

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

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
//We will then update the submission to include this
private String getConceptSemanticTypeURIValues() {
String pseudoInputString = "";
StringBuilder pseudoInputString = new StringBuilder();
if(conceptSemanticTypeLabelValues != null && !conceptSemanticTypeLabelValues.isEmpty()) {
String[] conceptSemanticTypeLabels = convertDelimitedStringToArray(conceptSemanticTypeLabelValues);
//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) {
String label = conceptSemanticTypeLabels[0];
String uri = getURIForSemanticTypeLabel(label);
if(uri != "") {
if(!StringUtils.isEmpty(uri)) {
String[] urisToAdd = new String[1];
urisToAdd[0] = uri;
pseudoInputString = uri;
pseudoInputString = new StringBuilder(uri);
log.debug("uris to add" + uri);
submission.addUriToForm(this.editConfiguration, "conceptSemanticTypeURI", urisToAdd);
}
@ -801,7 +801,7 @@ public class AddAssociatedConceptsPreprocessor extends
//Make or retrieve URI for this label
//TODO: Do we create this string with empty inputs ?
String uri = getURIForSemanticTypeLabel(label);
if(uri != "") {
if(!StringUtils.isEmpty(uri)) {
//uri var shouldn't be repeated?
if(!this.conceptSemanticTypeURIVarToValueMap.containsKey(uriVar)) {
this.conceptSemanticTypeURIVarToValueMap.put(uriVar, new ArrayList<String>());
@ -809,21 +809,21 @@ public class AddAssociatedConceptsPreprocessor extends
}
}
if(i != 0) {
pseudoInputString += ",";
pseudoInputString.append(",");
}
pseudoInputString += uri;
pseudoInputString.append(uri);
}
//Add this string to the uris for the form
String[] urisToAdd = new String[1];
urisToAdd[0] = pseudoInputString;
urisToAdd[0] = pseudoInputString.toString();
log.debug("uris to add" + pseudoInputString);
submission.addUriToForm(this.editConfiguration, "conceptSemanticTypeURI", urisToAdd);
}
}
return pseudoInputString;
return pseudoInputString.toString();
}
private String getURIForSemanticTypeLabel(String label) {

View file

@ -3,27 +3,16 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
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.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.dao.VitroVocabulary;
/*
* 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.
*/
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.MultiValueEditSubmission;

View file

@ -4,40 +4,10 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocess
import java.util.Map;
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.edit.n3editing.VTwo.BaseEditSubmissionPreprocessorVTwo;
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.fields.FieldVTwo;
import org.vivoweb.webapp.util.ModelUtils;
public class RoleToActivityPredicatePreprocessor extends RoleToPredicatePreprocessor {
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.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.edit.n3editing.VTwo.BaseEditSubmissionPreprocessorVTwo;
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.fields.FieldVTwo;
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;
Iterator<String> itr = adjacentNodes.iterator();
while(itr.hasNext()){
adjacentNodesConcat.append(itr.next() + " ");
adjacentNodesConcat.append(itr.next()).append(" ");
}
info[0] = adjacentNodesConcat.toString();

View file

@ -353,13 +353,9 @@ public class LabelsAcrossContextNodes implements IndexingUriFinder,
String subjectUri = stmt.getSubject().getURI();
String predicateUri = stmt.getPredicate().getURI();
if (incomingPropertyUri.equals(predicateUri)
return incomingPropertyUri.equals(predicateUri)
&& (contextNodeClasses.isEmpty() || isAnyMatch(
contextNodeClasses, getTypes(subjectUri)))) {
return true;
} else {
return false;
}
contextNodeClasses, getTypes(subjectUri)));
}
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.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
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.utils.ConceptSearchService.ConceptSearchServiceUtils;
@WebServlet(name = "ConceptSearchService", urlPatterns = {"/conceptSearchService"} )
public class ConceptSearchServlet extends VitroHttpServlet {
private static final long serialVersionUID = 1L;

View file

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

View file

@ -2,7 +2,11 @@
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.jena.query.Dataset;
import org.apache.jena.query.QueryExecution;
@ -49,7 +53,7 @@ public class CapabilityMapRequestHandler implements VisualizationRequestHandler
}
@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());
ConceptPeopleMap conceptPeopleMap = VisualizationCaches.conceptToPeopleMap.getNoWait(vitroRequest.getRDFService());
OrganizationPeopleMap organizationPeopleMap = VisualizationCaches.organisationToPeopleMap.getNoWait(vitroRequest.getRDFService());
@ -67,8 +71,8 @@ public class CapabilityMapRequestHandler implements VisualizationRequestHandler
}
}
Gson gson = new Gson();
return gson.toJson(concepts);
ObjectMapper mapper = new ObjectMapper();
return mapper.writeValueAsString(concepts);
}
return "";
}
@ -96,13 +100,13 @@ public class CapabilityMapRequestHandler implements VisualizationRequestHandler
}
response.results.add(result);
Gson gson = new Gson();
ObjectMapper mapper = new ObjectMapper();
String callback = vitroRequest.getParameter("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");
@ -150,13 +154,12 @@ public class CapabilityMapRequestHandler implements VisualizationRequestHandler
response.results.add(result);
}
Gson gson = new Gson();
ObjectMapper mapper = new ObjectMapper();
String callback = vitroRequest.getParameter("callback");
if (!StringUtils.isEmpty(callback)) {
return callback + "(" + gson.toJson(response) + ");";
return callback + "(" + mapper.writeValueAsString(response) + ");";
}
return gson.toJson(response);
return mapper.writeValueAsString(response);
}
return "";

View file

@ -2,9 +2,14 @@
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.List;
@JsonInclude(JsonInclude.Include.NON_NULL)
class CapabilityMapResponse {
@JsonProperty
List<CapabilityMapResult> results = new ArrayList<CapabilityMapResult>();
}

View file

@ -2,67 +2,71 @@
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 {
@JsonProperty
String[] clusters;
@SerializedName("md_1")
@JsonProperty("md_1")
String profileId;
@SerializedName("md_2")
@JsonProperty("md_2")
String description;
@SerializedName("md_3")
@JsonProperty("md_3")
String thumbNail;
@SerializedName("md_4")
@JsonProperty("md_4")
String department;
@SerializedName("md_5")
@JsonProperty("md_5")
String overview;
@SerializedName("md_6")
@JsonProperty("md_6")
String geographicFocus;
@SerializedName("md_7")
@JsonProperty("md_7")
String geographicLocation;
@SerializedName("md_8")
@JsonProperty("md_8")
String[] grants;
@SerializedName("md_A")
@JsonProperty("md_A")
String firstName;
@SerializedName("md_B")
@JsonProperty("md_B")
String lastName;
@SerializedName("md_F")
@JsonProperty("md_F")
String fax;
@SerializedName("md_G")
@JsonProperty("md_G")
String email;
@SerializedName("md_H")
@JsonProperty("md_H")
String availableForSupervision;
@SerializedName("md_I")
@JsonProperty("md_I")
String homepage;
@SerializedName("md_L")
@JsonProperty("md_L")
String phoneNumber;
@SerializedName("md_U")
@JsonProperty("md_U")
String[] publications;
@SerializedName("md_X")
@JsonProperty("md_X")
String[] researchOverview;
@SerializedName("md_Y")
@JsonProperty("md_Y")
String[] subjectArea;
@SerializedName("md_Z")
@JsonProperty("md_Z")
String preferredTitle;
@JsonProperty
String query;
}

View file

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

View file

@ -285,7 +285,7 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
List<Collaborator> coAuthorNodes =
new ArrayList<Collaborator>(currentBiboDocumentEntry.getValue());
Collections.sort(coAuthorNodes, new CollaboratorComparator());
coAuthorNodes.sort(new CollaboratorComparator());
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.exceptions.MalformedQueryParametersException;
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.VisualizationRequestHandler;
@ -168,7 +167,7 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
String coAuthorSeparator = "; ";
for (Collaborator currCoAuthor : coAuthors) {
coAuthorsMerged.append(currCoAuthor.getCollaboratorName() + coAuthorSeparator);
coAuthorsMerged.append(currCoAuthor.getCollaboratorName()).append(coAuthorSeparator);
}
return StringUtils.removeEnd(coAuthorsMerged.toString(), coAuthorSeparator);

View file

@ -101,12 +101,9 @@ public class CoAuthorshipVisCodeGenerator {
if (yearToUniqueCoauthors.size() > 0) {
try {
minPublishedYear = Integer.parseInt(Collections.min(publishedYears));
} catch (NoSuchElementException e1) {
} catch (NoSuchElementException | NumberFormatException e1) {
log.debug("vis: " + e1.getMessage() + " error occurred for "
+ yearToUniqueCoauthors.toString());
} catch (NumberFormatException e2) {
log.debug("vis: " + e2.getMessage() + " error occurred for "
+ yearToUniqueCoauthors.toString());
}
}

View file

@ -52,8 +52,7 @@ public class QueryConstants {
StringBuilder prefixSection = new StringBuilder();
for (Map.Entry<String, String> prefixEntry : PREFIX_TO_NAMESPACE.entrySet()) {
prefixSection.append("PREFIX " + prefixEntry.getKey()
+ ": <" + prefixEntry.getValue() + ">\n");
prefixSection.append("PREFIX ").append(prefixEntry.getKey()).append(": <").append(prefixEntry.getValue()).append(">\n");
}
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.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.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;

View file

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

View file

@ -164,7 +164,7 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
String coPISeparator = ";";
for (Collaborator currentCoPI : coInvestigators) {
coPIsMerged.append(currentCoPI.getCollaboratorName() + coPISeparator);
coPIsMerged.append(currentCoPI.getCollaboratorName()).append(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.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
@ -83,11 +82,7 @@ public class CoPIGraphMLWriter {
transformer.transform(source, result);
graphMLContent.append(writer.toString());
} catch (TransformerConfigurationException e) {
throw new IllegalStateException("XML error generating GraphML", e);
} catch (TransformerException e) {
throw new IllegalStateException("XML error generating GraphML", e);
} catch (ParserConfigurationException e) {
} catch (ParserConfigurationException | TransformerException e) {
throw new IllegalStateException("XML error generating GraphML", e);
}
@ -121,7 +116,7 @@ public class CoPIGraphMLWriter {
Set<Collaboration> edges = coPIData.getCollaborations();
List<Collaboration> orderedEdges = new ArrayList<Collaboration>(edges);
Collections.sort(orderedEdges, new CollaborationComparator());
orderedEdges.sort(new CollaborationComparator());
for (Collaboration currentEdge : orderedEdges) {
/*
@ -218,7 +213,7 @@ public class CoPIGraphMLWriter {
List<Collaborator> orderedPINodes = new ArrayList<Collaborator>(piNodes);
orderedPINodes.remove(egoNode);
Collections.sort(orderedPINodes, new CollaboratorComparator());
orderedPINodes.sort(new CollaboratorComparator());
for (Collaborator currNode : orderedPINodes) {

View file

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

View file

@ -9,6 +9,11 @@ import java.util.HashSet;
import java.util.Map;
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 edu.cornell.mannlib.vitro.webapp.beans.Individual;
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.logging.Log;
import com.google.gson.Gson;
import org.apache.jena.query.Dataset;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
@ -164,7 +168,7 @@ public class MapOfScienceVisualizationRequestHandler implements VisualizationReq
private Map<String, String> getSubjectPersonEntityAndGenerateDataResponse(
VitroRequest vitroRequest, String subjectEntityURI, String entityLabel, VisConstants.DataVisMode dataOuputFormat)
throws MalformedQueryParametersException {
throws MalformedQueryParametersException, JsonProcessingException {
long startTime = System.currentTimeMillis();
try {
@ -191,7 +195,6 @@ public class MapOfScienceVisualizationRequestHandler implements VisualizationReq
Map<String, String> fileData = new HashMap<String, String>();
if (VisConstants.DataVisMode.JSON.equals(dataOuputFormat)) {
Gson json = new Gson();
Set jsonContent = new HashSet();
MapOfScience entityJson = new MapOfScience(subjectEntityURI);
@ -203,8 +206,10 @@ public class MapOfScienceVisualizationRequestHandler implements VisualizationReq
jsonContent.add(entityJson);
ObjectMapper mapper = new ObjectMapper();
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 {
if (StringUtils.isBlank(entityLabel)) {
entityLabel = "no-name";
@ -239,7 +244,7 @@ public class MapOfScienceVisualizationRequestHandler implements VisualizationReq
private Map<String, String> getSubjectEntityAndGenerateDataResponse(
VitroRequest vitroRequest, String subjectEntityURI, String entityLabel, VisConstants.DataVisMode dataOuputFormat)
throws MalformedQueryParametersException {
throws MalformedQueryParametersException, JsonProcessingException {
RDFService rdfService = vitroRequest.getRDFService();
@ -290,7 +295,6 @@ public class MapOfScienceVisualizationRequestHandler implements VisualizationReq
Map<String, String> fileData = new HashMap<String, String>();
if (VisConstants.DataVisMode.JSON.equals(dataOuputFormat)) {
Gson json = new Gson();
Set jsonContent = new HashSet();
MapOfScience entityJson = new MapOfScience(subjectEntityURI);
@ -312,8 +316,10 @@ public class MapOfScienceVisualizationRequestHandler implements VisualizationReq
jsonContent.add(entityJson);
ObjectMapper mapper = new ObjectMapper();
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 {
if (StringUtils.isBlank(entityLabel)) {
entityLabel = "no-organization";
@ -356,26 +362,25 @@ public class MapOfScienceVisualizationRequestHandler implements VisualizationReq
return fileData;
}
private Map<String, String> prepareStandaloneDataErrorResponse() {
private Map<String, String> prepareStandaloneDataErrorResponse() throws JsonProcessingException {
GenericQueryMap errorDataResponse = new GenericQueryMap();
errorDataResponse.addEntry("error", "No Publications for this Entity found in VIVO.");
Gson jsonErrorResponse = new Gson();
Map<String, String> fileData = new HashMap<String, String>();
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"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;
}
@Override
public Map<String, String> generateDataVisualization(VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException {
throws MalformedQueryParametersException, JsonProcessingException {
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.Set;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.cornell.mannlib.vitro.webapp.visualization.utilities.VisualizationCaches;
import org.apache.commons.logging.Log;
import com.google.gson.Gson;
import org.apache.jena.query.Dataset;
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
@ -35,7 +36,7 @@ public class ModelConstructorRequestHandler implements
@Override
public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log,
Dataset dataSource) throws MalformedQueryParametersException {
Dataset dataSource) throws MalformedQueryParametersException, JsonProcessingException {
return regenerateConstructedModels(vitroRequest, dataSource);
}
@ -82,7 +83,7 @@ public class ModelConstructorRequestHandler implements
}
private Map<String, String> regenerateConstructedModels(VitroRequest vitroRequest,
Dataset dataSource) {
Dataset dataSource) throws JsonProcessingException {
VisualizationCaches.rebuildAll(vitroRequest.getRDFService());
@ -103,10 +104,7 @@ public class ModelConstructorRequestHandler implements
parseModelIdentifier.getType(), vitroRequest.getRDFService());
refreshedModels.add(parseModelIdentifier);
} catch (IllegalConstructedModelIdentifierException e) {
e.printStackTrace();
} catch (MalformedQueryParametersException e) {
// TODO Auto-generated catch block
} catch (IllegalConstructedModelIdentifierException | MalformedQueryParametersException e) {
e.printStackTrace();
}
}
@ -116,10 +114,9 @@ public class ModelConstructorRequestHandler implements
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"application/octet-stream");
Gson json = new Gson();
ObjectMapper mapper = new ObjectMapper();
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
json.toJson(refreshedModels));
mapper.writeValueAsString(refreshedModels));
return fileData;
}

View file

@ -112,7 +112,7 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
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.

View file

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

View file

@ -5,7 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.visualization.personlevel;
import java.util.HashMap;
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.CoInvestigationData;
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.ModelFactory;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.rdf.model.Statement;
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.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.ResultSet;
import org.apache.jena.query.Syntax;
import org.apache.jena.rdf.model.RDFNode;
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.valueobjects.Activity;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Individual;
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.visualization.exceptions.MalformedQueryParametersException;
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.visutils.QueryRunner;
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UtilityFunctions;

View file

@ -103,12 +103,9 @@ public class PersonPublicationCountVisCodeGenerator {
if (yearToPublicationCount.size() > 0) {
try {
minPublishedYear = Integer.parseInt(Collections.min(publishedYears));
} catch (NoSuchElementException e1) {
} catch (NoSuchElementException | NumberFormatException e1) {
log.debug("vis: " + e1.getMessage() + " error occurred for "
+ yearToPublicationCount.toString());
} catch (NumberFormatException e2) {
log.debug("vis: " + e2.getMessage() + " error occurred for "
+ yearToPublicationCount.toString());
}
}

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.rdfservice.RDFService;
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.ServletContextEvent;

View file

@ -27,40 +27,14 @@ import edu.cornell.mannlib.vitro.webapp.visualization.visutils.QueryRunner;
public class OrganizationUtilityFunctions {
public static String getHighestLevelOrganizationURI(ResultSet resultSet,
Map<String, String> fieldLabelToOutputFieldLabel) {
GenericQueryMap queryResult = new GenericQueryMap();
public static String getHighestLevelOrganizationURI(ResultSet resultSet, Map<String, String> fieldLabelToOutputFieldLabel) {
while (resultSet.hasNext()) {
QuerySolution solution = resultSet.nextSolution();
RDFNode organizationNode = solution
.get(fieldLabelToOutputFieldLabel.get("organization"));
RDFNode organizationNode = solution.get(fieldLabelToOutputFieldLabel.get("organization"));
if (organizationNode != null) {
queryResult.addEntry(
fieldLabelToOutputFieldLabel.get("organization"),
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.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.visualization.model.OrganizationPeopleMap;
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.logging.Log;
import com.google.gson.Gson;
import org.apache.jena.query.Dataset;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
@ -77,7 +81,7 @@ public class TemporalGrantVisualizationRequestHandler implements
@Override
public Map<String, String> generateDataVisualization(VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException {
throws MalformedQueryParametersException, JsonProcessingException {
String entityURI = vitroRequest.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
@ -137,7 +141,7 @@ public class TemporalGrantVisualizationRequestHandler implements
private Map<String, String> getSubjectEntityAndGenerateDataResponse(
VitroRequest vitroRequest, Log log, Dataset dataset,
String subjectEntityURI, VisConstants.DataVisMode visMode)
throws MalformedQueryParametersException {
throws MalformedQueryParametersException, JsonProcessingException {
RDFService rdfService = vitroRequest.getRDFService();
@ -184,7 +188,6 @@ public class TemporalGrantVisualizationRequestHandler implements
Map<String, String> fileData = new HashMap<String, String>();
if (VisConstants.DataVisMode.JSON.equals(visMode)) {
Gson json = new Gson();
Set subEntitiesJson = new HashSet();
// For each suborganisation
@ -234,8 +237,10 @@ public class TemporalGrantVisualizationRequestHandler implements
subEntitiesJson.add(subjectEntityJSON);
ObjectMapper mapper = new ObjectMapper();
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 {
String entityLabel = orgLabelMap.get(subjectEntityURI);

View file

@ -10,6 +10,11 @@ import java.util.List;
import java.util.Map;
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.visualization.model.OrganizationPeopleMap;
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.logging.Log;
import com.google.gson.Gson;
import org.apache.jena.query.Dataset;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
@ -74,7 +78,7 @@ public class TemporalPublicationVisualizationRequestHandler implements
private Map<String, String> getSubjectEntityAndGenerateDataResponse(
VitroRequest vitroRequest, Log log, Dataset dataset,
String subjectEntityURI, VisConstants.DataVisMode visMode)
throws MalformedQueryParametersException {
throws MalformedQueryParametersException, JsonProcessingException {
RDFService rdfService = vitroRequest.getRDFService();
@ -121,7 +125,6 @@ public class TemporalPublicationVisualizationRequestHandler implements
Map<String, String> fileData = new HashMap<String, String>();
if (VisConstants.DataVisMode.JSON.equals(visMode)) {
Gson json = new Gson();
Set subEntitiesJson = new HashSet();
// For each suborganisation
@ -171,8 +174,10 @@ public class TemporalPublicationVisualizationRequestHandler implements
subEntitiesJson.add(subjectEntityJSON);
ObjectMapper mapper = new ObjectMapper();
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 {
String entityLabel = orgLabelMap.get(subjectEntityURI);
@ -240,7 +245,7 @@ public class TemporalPublicationVisualizationRequestHandler implements
@Override
public Map<String, String> generateDataVisualization(VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException {
throws MalformedQueryParametersException, JsonProcessingException {
String entityURI = vitroRequest.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);

View file

@ -5,7 +5,11 @@ package edu.cornell.mannlib.vitro.webapp.visualization.utilities;
import java.util.HashMap;
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 org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
@ -14,7 +18,6 @@ import org.apache.jena.iri.IRIFactory;
import org.apache.jena.iri.Violation;
import org.vivoweb.webapp.util.ModelUtils;
import com.google.gson.Gson;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.QuerySolution;
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.visutils.AllPropertiesQueryRunner;
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.VisualizationRequestHandler;
@ -53,7 +55,7 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
public Object generateAjaxVisualization(VitroRequest vitroRequest,
Log log,
Dataset dataset)
throws MalformedQueryParametersException {
throws MalformedQueryParametersException, JsonProcessingException {
String individualURI = vitroRequest.getParameter(
VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
@ -82,9 +84,9 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
GenericQueryMap profilePropertiesToValues =
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
@ -140,11 +142,12 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
groupOrderClause,
dataset);
Gson publicationsInformation = new Gson();
NumPubsForIndividualConsumer consumer = new NumPubsForIndividualConsumer();
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
.equalsIgnoreCase(visMode)) {
@ -181,12 +184,11 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
"",
dataset);
Gson grantsInformation = new Gson();
NumGrantsForIndividualConsumer consumer = new NumGrantsForIndividualConsumer();
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
.equalsIgnoreCase(visMode)) {
@ -352,7 +354,6 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
private VitroRequest vitroRequest;
private Map<String, String> fieldLabelToOutputFieldLabel;
private String topLevelURL = null;
private GenericQueryMap queryResult = new GenericQueryMap();
HighetTopLevelOrgTemporalGraphURLConsumer(VitroRequest vitroRequest, Map<String, String> fieldLabelToOutputFieldLabel) {
this.vitroRequest = vitroRequest;
@ -368,8 +369,6 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
RDFNode organizationNode = qs.get(fieldLabelToOutputFieldLabel.get("organization"));
if (organizationNode != null) {
queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organization"), organizationNode.toString());
String individualLocalName = UtilityFunctions.getIndividualLocalName(organizationNode.toString(), vitroRequest);
if (StringUtils.isNotBlank(individualLocalName)) {
@ -390,19 +389,6 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
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.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
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$ */
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.List;
import java.util.Set;
@ -11,13 +14,24 @@ import java.util.Set;
* @author bkoniden
* Deepak Konidena
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class JsonObject {
@JsonProperty
private String label;
@JsonProperty
private String lastCachedAtDateTime;
@JsonProperty
private List<List<Integer>> data = new ArrayList<List<Integer>>();
@JsonProperty
private String entityURI;
@JsonProperty
private String visMode;
@JsonProperty
private List<String> organizationType = new ArrayList<String>();
public List<String> getOrganizationTypes() {
@ -29,9 +43,7 @@ public class JsonObject {
}
public void setOrganizationTypes(Set<String> givenOrganizationType) {
for (String type : givenOrganizationType) {
this.organizationType.add(type);
}
this.organizationType.addAll(givenOrganizationType);
}
public String getEntityURI() {

View file

@ -1,21 +1,41 @@
/* $This file is distributed under the terms of the license in LICENSE$ */
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.HashSet;
import java.util.Map;
import java.util.Set;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class MapOfScience {
@JsonProperty
private String uri;
@JsonProperty
private String label;
@JsonProperty
private String type;
@JsonProperty
private int pubsMapped;
@JsonProperty
private int pubsWithNoJournals;
@JsonProperty
private int pubsWithInvalidJournals;
@JsonProperty
private String lastCachedAtDateTime;
@JsonProperty
private Map<Integer, Float> subdisciplineActivity = new HashMap<Integer, Float>();
@JsonProperty
private Set<SubEntityInfo> subEntities = new HashSet<SubEntityInfo>();
public MapOfScience(String uri) {
@ -84,11 +104,18 @@ public class MapOfScience {
return subEntities;
}
@JsonInclude(JsonInclude.Include.NON_NULL)
private class SubEntityInfo {
@JsonProperty
private String uri;
@JsonProperty
private String label;
@JsonProperty
private String type;
@JsonProperty
private int pubs;
public SubEntityInfo(String uri, String label, String type, int pubs) {
@ -129,7 +156,5 @@ public class MapOfScience {
public void setPubs(int pubs) {
this.pubs = pubs;
}
}
}

View file

@ -5,12 +5,19 @@ import java.util.HashMap;
import java.util.Map;
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;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SubjectEntityJSON {
@JsonProperty
private String subjectEntityLabel;
@JsonProperty
private String subjectEntityURI;
@JsonProperty
private Map<String, String> parentURIToLabel = new HashMap<String, String>();
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.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.ResultSet;
import org.apache.jena.query.Syntax;
import org.apache.jena.rdf.model.RDFNode;
@ -78,7 +72,7 @@ public class AllPropertiesQueryRunner implements QueryRunner<GenericQueryMap> {
+ filterClause
+ "}";
log.debug("sparqlQuery = " + sparqlQuery.toString());
log.debug("sparqlQuery = " + 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
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
boolean fullMatrix = true;

View file

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

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