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 datapropValue;
|
||||
|
||||
String urlPatternToReturnTo;
|
||||
String urlPatternToReturnTo = INDIVIDUAL_CONTROLLER ;
|
||||
String entityToReturnTo;
|
||||
String formUrl;
|
||||
String editKey;
|
||||
|
@ -948,4 +948,6 @@ public class EditConfigurationVTwo {
|
|||
public String toString(){
|
||||
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) {
|
||||
|
||||
for( List<String> n3s : n3StrLists){
|
||||
populator.subInMultiUris(multiUris, n3s);
|
||||
if( n3s != null ){
|
||||
populator.subInMultiUris(multiUris, n3s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void substituteInURIs(
|
||||
Map<String, String> uris, List<String> ... 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$ */
|
||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
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.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 {
|
||||
|
||||
|
@ -50,4 +48,31 @@ public abstract class BaseEditConfigurationGenerator implements EditConfiguratio
|
|||
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,22 +116,34 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
|||
return EditSubmissionUtils.getEditSubmissionFromSession(vreq.getSession(), editConfig);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//TODO: should more of what happens in this method
|
||||
//happen in the generators?
|
||||
private EditConfigurationVTwo setupEditConfiguration(String editConfGeneratorName,
|
||||
VitroRequest vreq) {
|
||||
|
||||
HttpSession session = vreq.getSession();
|
||||
EditConfigurationVTwo editConfig = makeEditConfigurationVTwo( editConfGeneratorName, vreq, session);
|
||||
//edit key should now always be set in the generator class
|
||||
//put edit configuration in session
|
||||
EditConfigurationVTwo editConfig =
|
||||
makeEditConfigurationVTwo( editConfGeneratorName, vreq, 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);
|
||||
|
||||
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 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);
|
||||
} else if( dataKey != null ) { // edit of a data prop
|
||||
//do nothing since the data prop form generator must take care of it
|
||||
|
|
|
@ -18,7 +18,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
|
|||
|
||||
public class ProcessRdfFormTest extends AbstractTestClass{
|
||||
|
||||
|
||||
@Test
|
||||
public void basicNewStatementTest() throws Exception{
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue