1. SPARQL query was illegally modified due to Refactor. This led to "foaf:Person" being changed to "foaf:Individual".

2. Changed the slugify logic so that only first 10 letters are considered for the file nam, else the filenames become very very big, especially for schools like CALS.
This commit is contained in:
cdtank 2010-06-23 02:34:29 +00:00
parent 4a74799a18
commit 9a6a7ce3fb
7 changed files with 16 additions and 14 deletions

View file

@ -36,7 +36,7 @@ public class TestJava {
System.out.println(sampleBlurns); System.out.println(sampleBlurns);
for (String blurb : sampleBlurns) { for (String blurb : sampleBlurns) {
System.out.println(blurb); System.out.println(blurb.substring(0, 10));
} }
Map<String, Integer> yearToPublicationCount = new TreeMap<String, Integer>(); Map<String, Integer> yearToPublicationCount = new TreeMap<String, Integer>();

View file

@ -276,7 +276,7 @@ public class QueryHandler {
String ontologyHandle) { String ontologyHandle) {
String sparqlQuery = " {?department " + ontologyHandle + " ?" + employeeHandle + " . " String sparqlQuery = " {?department " + ontologyHandle + " ?" + employeeHandle + " . "
+ "?" + employeeHandle + " rdf:type foaf:Individual; rdfs:label ?authorLabel. " + "?" + employeeHandle + " rdf:type foaf:Person; rdfs:label ?authorLabel. "
+ "OPTIONAL { ?" + employeeHandle + " vivo:authorOf ?document ." + + "OPTIONAL { ?" + employeeHandle + " vivo:authorOf ?document ." +
" ?document rdf:type bibo:Document ." + " ?document rdf:type bibo:Document ." +
" ?document rdfs:label ?documentLabel ." + " ?document rdfs:label ?documentLabel ." +

View file

@ -40,6 +40,8 @@ import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.VivoEmployee;
public class VisualizationRequestHandler { public class VisualizationRequestHandler {
private static final int MAX_NAME_TEXT_LENGTH = 10;
public static final String VIS_CONTAINER_URL_HANDLE = "container"; public static final String VIS_CONTAINER_URL_HANDLE = "container";
public static final String COLLEGE_URI_URL_HANDLE = "uri"; public static final String COLLEGE_URI_URL_HANDLE = "uri";
@ -348,7 +350,7 @@ public class VisualizationRequestHandler {
collegeName = ""; collegeName = "";
} }
String outputFileName = slugify(collegeName + "depts-pub-count") + ".csv"; String outputFileName = slugify(collegeName) + "depts-pub-count" + ".csv";
response.setContentType("application/octet-stream"); response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment;filename=" + outputFileName); response.setHeader("Content-Disposition","attachment;filename=" + outputFileName);
@ -379,7 +381,7 @@ public class VisualizationRequestHandler {
* @return * @return
*/ */
private String slugify(String textToBeSlugified) { private String slugify(String textToBeSlugified) {
return textToBeSlugified.toLowerCase().replaceAll("[^a-zA-Z0-9-]", "-"); return textToBeSlugified.toLowerCase().replaceAll("[^a-zA-Z0-9-]", "-").substring(0, MAX_NAME_TEXT_LENGTH);
} }
private void generateCsvFileBuffer( private void generateCsvFileBuffer(

View file

@ -166,7 +166,7 @@ public class QueryHandler {
+ SPARQL_QUERY_COMMON_SELECT_CLAUSE + SPARQL_QUERY_COMMON_SELECT_CLAUSE
+ "(str(<" + queryURI + ">) as ?authPersonLit) " + "(str(<" + queryURI + ">) as ?authPersonLit) "
+ "WHERE { " + "WHERE { "
+ "<" + queryURI + "> rdf:type foaf:Individual ; vivo:authorOf ?document ; rdfs:label ?authorLabel. " + "<" + queryURI + "> rdf:type foaf:Person ; vivo:authorOf ?document ; rdfs:label ?authorLabel. "
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE + SPARQL_QUERY_COMMON_WHERE_CLAUSE
+ "}"; + "}";
@ -179,7 +179,7 @@ public class QueryHandler {
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
if(this.queryParam == null || "".equals(queryParam)) { if(this.queryParam == null || "".equals(queryParam)) {
throw new MalformedQueryParametersException("URI parameter is either null or empty."); throw new MalformedQueryParametersException("URL parameter is either null or empty.");
} else { } else {
/* /*

View file

@ -35,6 +35,8 @@ import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Individual;
public class VisualizationRequestHandler { public class VisualizationRequestHandler {
private static final int MAX_NAME_TEXT_LENGTH = 10;
public static final String VIS_CONTAINER_URL_HANDLE = "container"; public static final String VIS_CONTAINER_URL_HANDLE = "container";
public static final String INDIVIDUAL_URI_URL_HANDLE = "uri"; public static final String INDIVIDUAL_URI_URL_HANDLE = "uri";
@ -205,8 +207,7 @@ public class VisualizationRequestHandler {
authorName = ""; authorName = "";
} }
String outputFileName = slugify(authorName + "report") String outputFileName = slugify(authorName) + "report" + ".pdf";
+ ".pdf";
response.setContentType("application/pdf"); response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment;filename=" + outputFileName); response.setHeader("Content-Disposition", "attachment;filename=" + outputFileName);
@ -262,8 +263,7 @@ public class VisualizationRequestHandler {
authorName = ""; authorName = "";
} }
String outputFileName = slugify(authorName + "pub-count-sparkline") String outputFileName = slugify(authorName) + "pub-count-sparkline" + ".csv";
+ ".csv";
response.setContentType("application/octet-stream"); response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment;filename=" + outputFileName); response.setHeader("Content-Disposition","attachment;filename=" + outputFileName);
@ -293,7 +293,7 @@ public class VisualizationRequestHandler {
* @return * @return
*/ */
private String slugify(String textToBeSlugified) { private String slugify(String textToBeSlugified) {
return textToBeSlugified.toLowerCase().replaceAll("[^a-zA-Z0-9-]", "-"); return textToBeSlugified.toLowerCase().replaceAll("[^a-zA-Z0-9-]", "-").substring(0, MAX_NAME_TEXT_LENGTH);
} }
private void generateCsvFileBuffer(Map<String, Integer> yearToPublicationCount, private void generateCsvFileBuffer(Map<String, Integer> yearToPublicationCount,

View file

@ -6,8 +6,8 @@ public class Individual {
private String individualURL; private String individualURL;
public Individual(String individualURL, String individualLabel) { public Individual(String individualURL, String individualLabel) {
this.individualLabel = individualLabel;
this.individualURL = individualURL; this.individualURL = individualURL;
this.individualLabel = individualLabel;
} }
public Individual(String individualURL) { public Individual(String individualURL) {

View file

@ -11,7 +11,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.VOConstants.E
* @author cdtank * @author cdtank
* *
*/ */
public class VivoEmployee extends Individual{ public class VivoEmployee extends Individual {
private EmployeeType employeeType; private EmployeeType employeeType;
private Set<VivoDepartmentOrDivision> parentDepartments = new HashSet<VivoDepartmentOrDivision>(); private Set<VivoDepartmentOrDivision> parentDepartments = new HashSet<VivoDepartmentOrDivision>();