Merge branch 'develop' of git+ssh://github.com/vivo-project/Vitro into develop
This commit is contained in:
commit
b0a5961f4d
6 changed files with 220 additions and 43 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -5,4 +5,4 @@
|
|||
/bin/
|
||||
/webapp/config/deploy.properties
|
||||
/webapp/config/debug.log4j.properties
|
||||
|
||||
.build
|
||||
|
|
|
@ -39,7 +39,17 @@ public class DateTimeIntervalFormGenerator extends
|
|||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||
HttpSession session) {
|
||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||
this.setupEditConfiguration(conf, vreq, session);
|
||||
//Prepare
|
||||
prepare(vreq, conf);
|
||||
return conf;
|
||||
|
||||
}
|
||||
|
||||
//Enables refactoring by other generators, as this code can be used to partially setup an
|
||||
//edit configuration object which can then be extended - prepare can then be called independently
|
||||
//enabling sparql queries to be evaluated using the final edit configuration object
|
||||
public void setupEditConfiguration(EditConfigurationVTwo conf, VitroRequest vreq, HttpSession session) {
|
||||
initBasics(conf, vreq);
|
||||
initPropertyParameters(vreq, session, conf);
|
||||
initObjectPropForm(conf, vreq);
|
||||
|
@ -48,11 +58,11 @@ public class DateTimeIntervalFormGenerator extends
|
|||
|
||||
conf.setVarNameForSubject("subject");
|
||||
conf.setVarNameForPredicate("toDateTimeInterval");
|
||||
conf.setVarNameForObject("intervalNode");
|
||||
conf.setVarNameForObject(getNodeVar());
|
||||
|
||||
conf.setN3Optional(Arrays.asList(n3ForStart, n3ForEnd));
|
||||
conf.setN3Optional(n3ForStart, n3ForEnd);
|
||||
|
||||
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource(getNodeVar(), DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
|
||||
|
@ -61,7 +71,7 @@ public class DateTimeIntervalFormGenerator extends
|
|||
conf.addSparqlForExistingLiteral(
|
||||
"endField-value", existingEndDateQuery);
|
||||
conf.addSparqlForExistingUris(
|
||||
"intervalNode", existingIntervalNodeQuery);
|
||||
getNodeVar(), existingIntervalNodeQuery);
|
||||
conf.addSparqlForExistingUris("startNode", existingStartNodeQuery);
|
||||
conf.addSparqlForExistingUris("endNode", existingEndNodeQuery);
|
||||
conf.addSparqlForExistingUris(
|
||||
|
@ -85,79 +95,87 @@ public class DateTimeIntervalFormGenerator extends
|
|||
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
|
||||
//Adding additional data, specifically edit mode
|
||||
addFormSpecificData(conf, vreq);
|
||||
//Prepare
|
||||
prepare(vreq, conf);
|
||||
return conf;
|
||||
|
||||
}
|
||||
|
||||
final static String n3ForStart =
|
||||
"?subject <" + toDateTimeInterval + "> ?intervalNode . \n" +
|
||||
"?intervalNode a <" + intervalType + "> . \n" +
|
||||
"?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||
final String n3ForStart =
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" +
|
||||
getNodeN3Var() + " a <" + intervalType + "> . \n" +
|
||||
getNodeN3Var() + " <" + intervalToStart + "> ?startNode . \n" +
|
||||
"?startNode a <" + dateTimeValueType + "> . \n" +
|
||||
"?startNode <" + dateTimeValue + "> ?startField-value . \n" +
|
||||
"?startNode <" + dateTimePrecision + "> ?startField-precision . \n";
|
||||
|
||||
final static String n3ForEnd =
|
||||
"?subject <" + toDateTimeInterval + "> ?intervalNode . \n" +
|
||||
"?intervalNode a <" + intervalType + "> . \n" +
|
||||
"?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
||||
final String n3ForEnd =
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" +
|
||||
getNodeN3Var() + " a <" + intervalType + "> . \n" +
|
||||
getNodeN3Var() + " <" + intervalToEnd + "> ?endNode . \n" +
|
||||
"?endNode a <" + dateTimeValueType + "> . \n" +
|
||||
"?endNode <" + dateTimeValue + "> ?endField-value . \n" +
|
||||
"?endNode <" + dateTimePrecision + "> ?endField-precision .";
|
||||
|
||||
final static String existingStartDateQuery =
|
||||
final String existingStartDateQuery =
|
||||
"SELECT ?existingDateStart WHERE { \n" +
|
||||
"?subject <" + toDateTimeInterval + "> ?existingIntervalNode . \n" +
|
||||
"?intervalNode a <" + intervalType + "> . \n" +
|
||||
"?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
|
||||
getNodeN3Var() + " a <" + intervalType + "> . \n" +
|
||||
getNodeN3Var() + " <" + intervalToStart + "> ?startNode . \n" +
|
||||
"?startNode a <" + dateTimeValueType + "> . \n" +
|
||||
"?startNode <" + dateTimeValue + "> ?existingDateStart }";
|
||||
|
||||
final static String existingEndDateQuery =
|
||||
final String existingEndDateQuery =
|
||||
"SELECT ?existingEndDate WHERE { \n" +
|
||||
"?subject <" + toDateTimeInterval + "> ?existingIntervalNode . \n" +
|
||||
"?intervalNode a <" + intervalType + "> . \n" +
|
||||
"?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
|
||||
getNodeN3Var() + " a <" + intervalType + "> . \n" +
|
||||
getNodeN3Var() + " <" + intervalToEnd + "> ?endNode . \n" +
|
||||
"?endNode a <" + dateTimeValueType + "> . \n " +
|
||||
"?endNode <" + dateTimeValue + "> ?existingEndDate . }";
|
||||
|
||||
final static String existingIntervalNodeQuery =
|
||||
final String existingIntervalNodeQuery =
|
||||
"SELECT ?existingIntervalNode WHERE { \n" +
|
||||
"?subject <" + toDateTimeInterval + "> ?existingIntervalNode . \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
|
||||
"?existingIntervalNode a <" + intervalType + "> . }";
|
||||
|
||||
final static String existingStartNodeQuery =
|
||||
final String existingStartNodeQuery =
|
||||
"SELECT ?existingStartNode WHERE { \n" +
|
||||
"?subject <" + toDateTimeInterval + "> ?existingIntervalNode . \n" +
|
||||
"?intervalNode a <" + intervalType + "> . \n" +
|
||||
"?intervalNode <" + intervalToStart + "> ?existingStartNode . \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
|
||||
getNodeN3Var() + " a <" + intervalType + "> . \n" +
|
||||
getNodeN3Var() + " <" + intervalToStart + "> ?existingStartNode . \n" +
|
||||
"?existingStartNode a <" + dateTimeValueType + "> .} ";
|
||||
|
||||
final static String existingEndNodeQuery =
|
||||
final String existingEndNodeQuery =
|
||||
"SELECT ?existingEndNode WHERE { \n" +
|
||||
"?subject <" + toDateTimeInterval + "> ?existingIntervalNode . \n" +
|
||||
"?intervalNode a <" + intervalType + "> . \n" +
|
||||
"?intervalNode <" + intervalToEnd + "> ?existingEndNode . \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
|
||||
getNodeN3Var() + " a <" + intervalType + "> . \n" +
|
||||
getNodeN3Var() + " <" + intervalToEnd + "> ?existingEndNode . \n" +
|
||||
"?existingEndNode a <" + dateTimeValueType + "> .} ";
|
||||
|
||||
final static String existingStartPrecisionQuery =
|
||||
final String existingStartPrecisionQuery =
|
||||
"SELECT ?existingStartPrecision WHERE { \n" +
|
||||
"?subject <" + toDateTimeInterval + "> ?existingIntervalNode . \n" +
|
||||
"?intervalNode a <" + intervalType + "> . \n" +
|
||||
"?intervalNode <" + intervalToStart + "> ?startNode . \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
|
||||
getNodeN3Var() + " a <" + intervalType + "> . \n" +
|
||||
getNodeN3Var() + " <" + intervalToStart + "> ?startNode . \n" +
|
||||
"?startNode a <" + dateTimeValueType + "> . \n" +
|
||||
"?startNode <" + dateTimePrecision + "> ?existingStartPrecision . }";
|
||||
|
||||
final static String existingEndPrecisionQuery =
|
||||
final String existingEndPrecisionQuery =
|
||||
"SELECT ?existingEndPrecision WHERE { \n" +
|
||||
"?subject <" + toDateTimeInterval + "> ?existingIntervalNode . \n" +
|
||||
"?intervalNode a <" + intervalType + "> . \n" +
|
||||
"?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
|
||||
getNodeN3Var() + " a <" + intervalType + "> . \n" +
|
||||
getNodeN3Var() + " <" + intervalToEnd + "> ?endNode . \n" +
|
||||
"?endNode a <" + dateTimeValueType + "> . \n" +
|
||||
"?endNode <" + dateTimePrecision + "> ?existingEndPrecision . }";
|
||||
|
||||
public String getToDateTimeIntervalPredicate() {
|
||||
return toDateTimeInterval;
|
||||
}
|
||||
|
||||
public String getNodeVar() {
|
||||
return "intervalNode";
|
||||
}
|
||||
|
||||
public String getNodeN3Var() {
|
||||
return "?" + getNodeVar();
|
||||
}
|
||||
|
||||
//Adding form specific data such as edit mode
|
||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||
|
|
|
@ -94,6 +94,14 @@ public class DateTimeValueFormGenerator extends BaseEditConfigurationGenerator
|
|||
"?subject <" + toDateTimeValue + "> ?existingNode . \n" +
|
||||
"?existingNode a <" + valueType + "> }";
|
||||
|
||||
|
||||
public static String getNodeVar() {
|
||||
return "valueNode";
|
||||
}
|
||||
|
||||
public static String getNodeN3Var() {
|
||||
return "?" + getNodeVar();
|
||||
}
|
||||
|
||||
//Adding form specific data such as edit mode
|
||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
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.EditConfigurationVTwo;
|
||||
|
||||
//For use with classes that explicitly modify configurations through AJAX requests
|
||||
public interface EditConfigurationAJAXGenerator {
|
||||
public void modifyEditConfiguration( EditConfigurationVTwo config, VitroRequest vreq ) throws Exception;
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
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.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
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.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.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.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.EditConfigurationGenerator;
|
||||
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
|
||||
* by the N3 editing system. It will examine the request parameters, determine
|
||||
* which form to use, execute a EditConfiguration setup, and evaluate the
|
||||
* view indicated by the EditConfiguration.
|
||||
*
|
||||
* Do not add code to this class to achieve some behavior in a
|
||||
* form. Try adding the behavior logic to the code that generates the
|
||||
* EditConfiguration for the form.
|
||||
*/
|
||||
public class EditRequestAJAXController extends VitroHttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static Log log = LogFactory.getLog(EditRequestDispatchController.class);
|
||||
|
||||
|
||||
protected Actions requiredActions(VitroRequest vreq) {
|
||||
return SimplePermission.DO_FRONT_END_EDITING.ACTIONS;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
super.doPost(req, resp);
|
||||
}
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
super.doGet(req, resp);
|
||||
log.debug(LogUtils.formatRequestProperties(log, "debug", req));
|
||||
|
||||
VitroRequest vreq = new VitroRequest(req);
|
||||
try {
|
||||
//Get edit configuration object based on editk key in request
|
||||
EditConfigurationVTwo config = getEditConfiguration(vreq);
|
||||
//Get the generator name also from the request parameter
|
||||
String generatorName = vreq.getParameter("generator");
|
||||
String javaGeneratorName = "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators." + generatorName;
|
||||
//TODO: Add this method to generators, but for now constructing a new class of generator specifically for AJAX requests
|
||||
EditConfigurationAJAXGenerator generator = getAJAXGenerator(javaGeneratorName, vreq, vreq.getSession());
|
||||
//run the modification
|
||||
generator.modifyEditConfiguration(config, vreq);
|
||||
} catch(Exception ex) {
|
||||
log.error("An error occurred in retrieving configuration and/or generator ", ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected EditConfigurationVTwo getEditConfiguration(VitroRequest vreq) {
|
||||
|
||||
EditConfigurationVTwo config = EditConfigurationVTwo.getConfigFromSession(vreq.getSession(), vreq);
|
||||
return config;
|
||||
}
|
||||
|
||||
private EditConfigurationAJAXGenerator getAJAXGenerator(
|
||||
String editConfGeneratorName, VitroRequest vreq, HttpSession session) throws Exception {
|
||||
|
||||
EditConfigurationAJAXGenerator EditConfigurationVTwoGenerator = null;
|
||||
|
||||
Object object = null;
|
||||
try {
|
||||
Class classDefinition = Class.forName(editConfGeneratorName);
|
||||
object = classDefinition.newInstance();
|
||||
EditConfigurationVTwoGenerator = (EditConfigurationAJAXGenerator) object;
|
||||
} catch (InstantiationException e) {
|
||||
System.out.println(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
System.out.println(e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
if(EditConfigurationVTwoGenerator == null){
|
||||
throw new Error("Could not find EditConfigurationVTwoGenerator " + editConfGeneratorName);
|
||||
} else {
|
||||
return EditConfigurationVTwoGenerator;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -370,6 +370,14 @@
|
|||
<url-pattern>/editRequestDispatch</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>EditRequestAJAX</servlet-name>
|
||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller.EditRequestAJAXController</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>EditRequestAJAX</servlet-name>
|
||||
<url-pattern>/editRequestAJAX</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>FlagUpdateController</servlet-name>
|
||||
|
|
Loading…
Add table
Reference in a new issue