Merge branch 'develop' of https://github.com/vivo-project/Vitro into develop

This commit is contained in:
brianjlowe 2013-06-20 12:45:14 -04:00
commit d2177ab3ce
6 changed files with 21 additions and 205 deletions

View file

@ -2,11 +2,14 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils;
import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.List;
import java.util.Map;
import javax.servlet.ServletContext;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -18,20 +21,13 @@ import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Resource;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache; import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
import javax.servlet.ServletContext;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JSONSerializer;
//Returns the appropriate n3 based on data getter //Returns the appropriate n3 based on data getter
public class ProcessClassGroupDataGetterN3 extends ProcessDataGetterAbstract { public class ProcessClassGroupDataGetterN3 extends ProcessDataGetterAbstract {
private static String classType = "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData"; private static String classType = "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData";

View file

@ -2,27 +2,14 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils;
import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Literal;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
import net.sf.json.JSONObject;
import net.sf.json.JSONSerializer;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.rdf.model.Literal;
//Returns the appropriate n3 based on data getter //Returns the appropriate n3 based on data getter
public abstract class ProcessDataGetterAbstract implements ProcessDataGetterN3 { public abstract class ProcessDataGetterAbstract implements ProcessDataGetterN3 {
public static String classTypeVarBase = "classType"; public static String classTypeVarBase = "classType";

View file

@ -2,11 +2,7 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller;
import static edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils.getPredicateUri;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -16,39 +12,13 @@ import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.vocabulary.RDFS;
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.DirectRedirectResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.json.GetDataForPage;
import edu.cornell.mannlib.vitro.webapp.controller.json.GetEntitiesByVClass;
import edu.cornell.mannlib.vitro.webapp.controller.json.GetEntitiesByVClassContinuation;
import edu.cornell.mannlib.vitro.webapp.controller.json.GetRenderedSolrIndividualsByVClass;
import edu.cornell.mannlib.vitro.webapp.controller.json.GetSolrIndividualsByVClass;
import edu.cornell.mannlib.vitro.webapp.controller.json.GetSolrIndividualsByVClasses;
import edu.cornell.mannlib.vitro.webapp.controller.json.GetVClassesForVClassGroup;
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.EditConfigurationUtils;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditSubmissionUtils;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.EditConfigurationAJAXGenerator; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.EditConfigurationAJAXGenerator;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.EditConfigurationGenerator;
import edu.cornell.mannlib.vitro.webapp.utils.log.LogUtils; import edu.cornell.mannlib.vitro.webapp.utils.log.LogUtils;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.edit.EditConfigurationTemplateModel;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.edit.MultiValueEditSubmissionTemplateModel;
/** /**
* This servlet is intended to handle all requests to create a form for use * This servlet is intended to handle all requests to create a form for use

View file

@ -20,6 +20,7 @@ import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec; import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.query.Dataset; import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory;
@ -30,6 +31,7 @@ import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess; import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
import edu.cornell.mannlib.vitro.webapp.dao.filtering.WebappDaoFactoryFiltering; import edu.cornell.mannlib.vitro.webapp.dao.filtering.WebappDaoFactoryFiltering;
@ -126,7 +128,6 @@ public class RequestModelsPrep implements Filter {
private void setUpTheRequestModels(RDFService rawRdfService, private void setUpTheRequestModels(RDFService rawRdfService,
HttpServletRequest req) { HttpServletRequest req) {
HttpSession session = req.getSession();
VitroRequest vreq = new VitroRequest(req); VitroRequest vreq = new VitroRequest(req);
vreq.setUnfilteredRDFService(rawRdfService); vreq.setUnfilteredRDFService(rawRdfService);
@ -153,12 +154,10 @@ public class RequestModelsPrep implements Filter {
WebappDaoFactory wadf = new WebappDaoFactorySDB(rdfService, oms, config); WebappDaoFactory wadf = new WebappDaoFactorySDB(rdfService, oms, config);
vreq.setUnfilteredWebappDaoFactory(wadf); vreq.setUnfilteredWebappDaoFactory(wadf);
addLanguageAwarenessToRequestModel(req, ModelID.DISPLAY);
addLanguageAwarenessToRequestModel(req, ModelID.APPLICATION_METADATA);
wadf = new WebappDaoFactorySDB(rdfService, ModelAccess.on(vreq).getUnionOntModelSelector(), config); wadf = new WebappDaoFactorySDB(rdfService, ModelAccess.on(vreq).getUnionOntModelSelector(), config);
if (isLanguageAwarenessEnabled()) {
ModelAccess.on(vreq).setDisplayModel(
LanguageFilteringUtils.wrapOntModelInALanguageFilter(
ModelAccess.on(session).getDisplayModel(), req));
}
// Do model switching and replace the WebappDaoFactory with // Do model switching and replace the WebappDaoFactory with
// a different version if requested by parameters // a different version if requested by parameters
@ -202,6 +201,15 @@ public class RequestModelsPrep implements Filter {
} }
} }
private void addLanguageAwarenessToRequestModel(HttpServletRequest req, ModelID id) {
if (isLanguageAwarenessEnabled()) {
OntModel unaware = ModelAccess.on(req.getSession()).getOntModel(id);
OntModel aware = LanguageFilteringUtils
.wrapOntModelInALanguageFilter(unaware, req);
ModelAccess.on(req).setOntModel(id, aware);
}
}
@Override @Override
public void destroy() { public void destroy() {
// Nothing to destroy // Nothing to destroy

View file

@ -1,110 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.utils;
import java.util.StringTokenizer;
/**
*
*
following text from http://search.cpan.org/dist/Text-Capitalize/Capitalize.pm
This web page:
http://www.continentallocating.com/World.Literature/General2/LiteraryTitles2.htm
presents some admirably clear rules for capitalizing titles:
ALL words in EVERY title are capitalized except
(1) a, an, and the,
(2) two and three letter conjunctions (and, or, nor, for, but, so, yet),
(3) prepositions.
Exceptions: The first word is always capitalized even
if it is among the above three groups. For the last word, we can specify the
option to always capitalize it or to treat it like a medial word. The original
method always capitalized the final word, so to support the old method calls
we have defined another method to provide this as default behavior.
But consider the case:
"It Waits Underneath the Sea"
Should the word "underneath" be downcased because it's a preposition? Most English speakers
would be surprised to see it that way. Consequently, the default list of exceptions to
capitalization in this module only includes the shortest of the common prepositions
(to of by at for but in).
The default entries on the exception list are:
a an the
and or nor for but so yet
to of by at for but in with has
de von
The observant may note that the last row is not composed of English words. The honorary
"de" has been included in honor of "Honore' de Balzac". And "von" was added for the sake
of equal time.
*/
public class TitleCase {
static String ignore[] = {"a","an","the","and","or","nor","for","but","so","yet",
"to","of","by","at","for","but","in","with","has","de","von"};
public static String toTitleCase(String in) {
// Support old behavior without modifying method calls
return toTitleCase(in, true);
}
public static String toTitleCase(String in, boolean alwaysCapitalizeLast){
if( in == null || in.length() ==0 )
return in;
in = in.toLowerCase();
StringTokenizer st = new StringTokenizer(in);
StringBuilder out = new StringBuilder();
int count = 1;
int last = st.countTokens();
while(st.hasMoreTokens()){
String token = st.nextToken();
// always capitalize first
if ( count == 1 ||
// always capitalize last, unless we've asked not to
( alwaysCapitalizeLast && count == last ) ) {
out.append(capitalizeWord(token));
} else {
//check if on ignored list
boolean ignoreToken = false;
for(String ign:ignore){
if( token.equals(ign) )
ignoreToken = true;
}
if( ignoreToken )
out.append(token);
else
out.append(capitalizeWord(token));
}
if(st.hasMoreTokens())
out.append(' ');
count++;
}
return out.toString();
}
private static String capitalizeWord(String in){
if( in == null || in.length() == 0 )
return in;
if( in.length() == 1 )
return in.toUpperCase();
//not trying too hard to deal with dashes.
int dash = in.indexOf('-') ;
if(dash > 0 && in.length() > dash+2 )
in = in.substring(0, dash)
+ '-'
+ in.substring(dash+1,dash+2).toUpperCase()
+ in.substring(dash+2);
return in.substring(0, 1).toUpperCase() + in.substring(1);
}
}

View file

@ -1,54 +1,19 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */ /* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.utils.dataGetter; package edu.cornell.mannlib.vitro.webapp.utils.dataGetter;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.ServletContext;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.json.JSONObject;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.QuerySolutionMap;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.shared.Lock;
import com.hp.hpl.jena.vocabulary.OWL;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController.PageRecord;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.controller.json.JsonServlet;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
public class ExecuteDataRetrieval { public class ExecuteDataRetrieval {