Changes to AddRoleToPersonTwoStage and subclasses
This commit is contained in:
parent
6836df4eac
commit
ec881de6a3
5 changed files with 61 additions and 19 deletions
|
@ -101,7 +101,7 @@ public class EditConfigurationVTwo {
|
||||||
String datapropKey;
|
String datapropKey;
|
||||||
String datapropValue;
|
String datapropValue;
|
||||||
|
|
||||||
String urlPatternToReturnTo;
|
String urlPatternToReturnTo = INDIVIDUAL_CONTROLLER ;
|
||||||
String entityToReturnTo;
|
String entityToReturnTo;
|
||||||
String formUrl;
|
String formUrl;
|
||||||
String editKey;
|
String editKey;
|
||||||
|
@ -948,4 +948,6 @@ public class EditConfigurationVTwo {
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
|
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String INDIVIDUAL_CONTROLLER = "/individual";
|
||||||
}
|
}
|
||||||
|
|
|
@ -462,14 +462,18 @@ public class ProcessRdfForm {
|
||||||
Map<String, List<String>> multiUris, List<String> ... n3StrLists) {
|
Map<String, List<String>> multiUris, List<String> ... n3StrLists) {
|
||||||
|
|
||||||
for( List<String> n3s : n3StrLists){
|
for( List<String> n3s : n3StrLists){
|
||||||
populator.subInMultiUris(multiUris, n3s);
|
if( n3s != null ){
|
||||||
|
populator.subInMultiUris(multiUris, n3s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void substituteInURIs(
|
private void substituteInURIs(
|
||||||
Map<String, String> uris, List<String> ... n3StrLists) {
|
Map<String, String> uris, List<String> ... n3StrLists) {
|
||||||
for( List<String> n3s : n3StrLists){
|
for( List<String> n3s : n3StrLists){
|
||||||
populator.subInUris(uris, n3s);
|
if( n3s != null ){
|
||||||
|
populator.subInUris(uris, n3s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
/* $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.edit.n3editing.configuration.generators;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditN3GeneratorVTwo;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration;
|
|
||||||
|
|
||||||
public abstract class BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
public abstract class BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
||||||
|
|
||||||
|
@ -50,4 +48,31 @@ public abstract class BaseEditConfigurationGenerator implements EditConfiguratio
|
||||||
editConfiguration.setObject( EditConfigurationUtils.getObjectUri(vreq) );
|
editConfiguration.setObject( EditConfigurationUtils.getObjectUri(vreq) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to turn Strings or multiple List<String> to List<String>.
|
||||||
|
* Only accepts String and List<String> as multi args.
|
||||||
|
*/
|
||||||
|
List<String> list( Object ... objs){
|
||||||
|
List<String> rv = new ArrayList<String>();
|
||||||
|
for( Object obj: objs){
|
||||||
|
if( obj instanceof String)
|
||||||
|
rv.add((String)obj);
|
||||||
|
else if( obj instanceof Iterable){
|
||||||
|
for( Object innerObj: (Iterable)obj){
|
||||||
|
if( innerObj instanceof String){
|
||||||
|
rv.add((String)innerObj);
|
||||||
|
}else{
|
||||||
|
throw new Error("list may only take String " +
|
||||||
|
"and List<String>. It does not accept List<"
|
||||||
|
+ innerObj.getClass().getName() + ">");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
throw new Error("list may only take String " +
|
||||||
|
"and List<String>. It does not accept "
|
||||||
|
+ obj.getClass().getName() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,27 +116,39 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
||||||
return EditSubmissionUtils.getEditSubmissionFromSession(vreq.getSession(), editConfig);
|
return EditSubmissionUtils.getEditSubmissionFromSession(vreq.getSession(), editConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: should more of what happens in this method
|
||||||
|
//happen in the generators?
|
||||||
private EditConfigurationVTwo setupEditConfiguration(String editConfGeneratorName,
|
private EditConfigurationVTwo setupEditConfiguration(String editConfGeneratorName,
|
||||||
VitroRequest vreq) {
|
VitroRequest vreq) {
|
||||||
|
|
||||||
HttpSession session = vreq.getSession();
|
HttpSession session = vreq.getSession();
|
||||||
EditConfigurationVTwo editConfig = makeEditConfigurationVTwo( editConfGeneratorName, vreq, session);
|
EditConfigurationVTwo editConfig =
|
||||||
//edit key should now always be set in the generator class
|
makeEditConfigurationVTwo( editConfGeneratorName, vreq, session);
|
||||||
//put edit configuration in session
|
|
||||||
|
//edit key is set here, NOT in the generator class
|
||||||
|
String editKey = EditConfigurationUtils.getEditKey(vreq);
|
||||||
|
editConfig.setEditKey(editKey);
|
||||||
|
|
||||||
|
//put edit configuration in session so it can be accessed on form submit.
|
||||||
EditConfigurationVTwo.putConfigInSession(editConfig, session);
|
EditConfigurationVTwo.putConfigInSession(editConfig, session);
|
||||||
|
|
||||||
Model model = (Model) getServletContext().getAttribute("jenaOntModel");
|
Model model = (Model) getServletContext().getAttribute("jenaOntModel");
|
||||||
|
|
||||||
|
if( editConfig.getSubjectUri() == null)
|
||||||
|
editConfig.setSubjectUri( EditConfigurationUtils.getSubjectUri(vreq));
|
||||||
|
if( editConfig.getPredicateUri() == null )
|
||||||
|
editConfig.setPredicateUri( EditConfigurationUtils.getPredicateUri(vreq));
|
||||||
|
|
||||||
String objectUri = EditConfigurationUtils.getObjectUri(vreq);
|
String objectUri = EditConfigurationUtils.getObjectUri(vreq);
|
||||||
String dataKey = EditConfigurationUtils.getDataPropKey(vreq);
|
String dataKey = EditConfigurationUtils.getDataPropKey(vreq);
|
||||||
if (objectUri != null) { // editing existing object
|
if (objectUri != null && ! objectUri.trim().isEmpty()) {
|
||||||
|
// editing existing object
|
||||||
|
if( editConfig.getObject() == null)
|
||||||
|
editConfig.setObject( EditConfigurationUtils.getObjectUri(vreq));
|
||||||
editConfig.prepareForObjPropUpdate(model);
|
editConfig.prepareForObjPropUpdate(model);
|
||||||
} else if( dataKey != null ) { // edit of a data prop
|
} else if( dataKey != null ) { // edit of a data prop
|
||||||
//do nothing since the data prop form generator must take care of it
|
//do nothing since the data prop form generator must take care of it
|
||||||
} else{
|
} else{
|
||||||
//this might be a create new or a form
|
//this might be a create new or a form
|
||||||
editConfig.prepareForNonUpdate(model);
|
editConfig.prepareForNonUpdate(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,7 @@ import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
|
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
|
||||||
|
|
||||||
public class ProcessRdfFormTest extends AbstractTestClass{
|
public class ProcessRdfFormTest extends AbstractTestClass{
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void basicNewStatementTest() throws Exception{
|
public void basicNewStatementTest() throws Exception{
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue