Updates for n3 editing and two stage role person form
This commit is contained in:
parent
d11c2cfe13
commit
c93cecb63c
7 changed files with 93 additions and 48 deletions
|
@ -212,10 +212,13 @@ public class EditConfigurationUtils {
|
|||
Map<String, List<Literal>> literalsInScope = editConfig.getLiteralsInScope();
|
||||
List<String> stringValues = new ArrayList<String>();
|
||||
List<Literal> literalValues = literalsInScope.get(fieldName);
|
||||
for(Literal l: literalValues) {
|
||||
//Could do additional processing here if required, for example if date etc. if need be
|
||||
stringValues.add(l.getValue().toString());
|
||||
}
|
||||
//TODO: Check whether it's correct that literal values would be null?
|
||||
if(literalValues != null) {
|
||||
for(Literal l: literalValues) {
|
||||
//Could do additional processing here if required, for example if date etc. if need be
|
||||
stringValues.add(l.getValue().toString());
|
||||
}
|
||||
}
|
||||
return stringValues;
|
||||
}
|
||||
|
||||
|
@ -229,7 +232,10 @@ public class EditConfigurationUtils {
|
|||
Configuration fmConfig = FreemarkerConfigurationLoader.getConfig(vreq, vreq.getSession().getServletContext());
|
||||
|
||||
FieldVTwo field = editConfig == null ? null : editConfig.getField(fieldName);
|
||||
MultiValueEditSubmission editSub = new MultiValueEditSubmission(vreq.getParameterMap(), editConfig);
|
||||
MultiValueEditSubmission editSub = EditSubmissionUtils.getEditSubmissionFromSession(vreq.getSession(), editConfig);
|
||||
//Should we create one if one doesn't exist?
|
||||
//TODO: Check if one needs to be created if it doesn't exist?
|
||||
//MultiValueEditSubmission editSub = new MultiValueEditSubmission(vreq.getParameterMap(), editConfig);
|
||||
if( field != null && field.getEditElement() != null ){
|
||||
html = field.getEditElement().draw(fieldName, editConfig, editSub, fmConfig);
|
||||
}
|
||||
|
|
|
@ -153,7 +153,17 @@ public class EditN3GeneratorVTwo {
|
|||
}
|
||||
|
||||
protected static String subInMultiLiterals(String var, List<Literal>values, String n3){
|
||||
String tmp = n3;
|
||||
if (n3==null ) {
|
||||
log.error("subInMultiLiterals was passed a null n3 String");
|
||||
return "blankBecauseTargetOrValueWasNull";
|
||||
}else if( var == null ){
|
||||
log.warn("subInMultiLiterals was passed a null var name");
|
||||
return n3;
|
||||
}else if( values == null ){
|
||||
log.debug("subInMultiLiterals was passed a null value for var '"+var+"'; returning target: '"+n3+"'");
|
||||
return n3;
|
||||
}
|
||||
String tmp = n3;
|
||||
|
||||
//make the multivalue literal string
|
||||
List<String> n3Values = new ArrayList<String>(values.size());
|
||||
|
|
|
@ -903,7 +903,8 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
|
|||
//Get edit mode
|
||||
private EditMode getEditMode(VitroRequest vreq) {
|
||||
String roleToActivityPredicate = getRoleToActivityPredicate(vreq);
|
||||
EditMode mode = FrontEndEditingUtils.getEditMode(vreq, roleToActivityPredicate);
|
||||
Individual object = EditConfigurationUtils.getObjectIndividual(vreq);
|
||||
EditMode mode = FrontEndEditingUtils.getEditMode(vreq, object, roleToActivityPredicate);
|
||||
return mode;
|
||||
//(mode == EditMode.ADD || mode == EditMode.REPAIR) ? "\"nonempty\"
|
||||
}
|
||||
|
@ -969,7 +970,7 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
|
|||
//Form specific data
|
||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||
formSpecificData.put("editMode", getEditMode(vreq).name());
|
||||
formSpecificData.put("editMode", getEditMode(vreq).name().toLowerCase());
|
||||
//Fields that will need select lists generated
|
||||
//Store field names
|
||||
List<String> objectSelect = new ArrayList<String>();
|
||||
|
|
|
@ -73,7 +73,8 @@ public class PostEditCleanupController extends FreemarkerHttpServlet{
|
|||
if(configuration == null)
|
||||
throw new Error("No edit configuration found.");
|
||||
|
||||
//get the EditSubmission
|
||||
//The submission for getting the entity to return to is not retrieved from the session but needs
|
||||
//to be created - as it is in processRdfForm3.jsp
|
||||
MultiValueEditSubmission submission = new MultiValueEditSubmission(vreq.getParameterMap(), configuration);
|
||||
String entityToReturnTo = ProcessRdfForm.processEntityToReturnTo(configuration, submission, vreq);
|
||||
return doPostEdit(vreq, entityToReturnTo);
|
||||
|
@ -88,7 +89,7 @@ public class PostEditCleanupController extends FreemarkerHttpServlet{
|
|||
EditConfigurationVTwo editConfig = EditConfigurationVTwo.getConfigFromSession(session,vreq);
|
||||
//In order to support back button resubmissions, don't remove the editConfig from session.
|
||||
//EditConfiguration.clearEditConfigurationInSession(session, editConfig);
|
||||
|
||||
//Here, edit submission is retrieved so it can be cleared out in case it exists
|
||||
MultiValueEditSubmission editSub = EditSubmissionUtils.getEditSubmissionFromSession(session,editConfig);
|
||||
EditSubmissionUtils.clearEditSubmissionInSession(session, editSub);
|
||||
|
||||
|
|
|
@ -32,28 +32,34 @@ public class FrontEndEditingUtils {
|
|||
|
||||
/* Determine whether a property editing form is in add, edit, or repair mode. */
|
||||
public static EditMode getEditMode(HttpServletRequest request, String relatedPropertyUri) {
|
||||
EditMode mode = EditMode.ADD;
|
||||
|
||||
Individual obj = (Individual)request.getAttribute("object");
|
||||
if( obj != null){
|
||||
List<ObjectPropertyStatement> stmts = obj.getObjectPropertyStatements(relatedPropertyUri);
|
||||
if( stmts != null){
|
||||
if( stmts.size() > 1 ){
|
||||
mode = EditMode.ERROR; // Multiple roleIn statements, yuck.
|
||||
log.debug("Multiple statements found for property " + relatedPropertyUri + ". Setting edit mode to ERROR.");
|
||||
}else if( stmts.size() == 0 ){
|
||||
mode = EditMode.REPAIR; // need to repair the role node
|
||||
log.debug("No statements found for property " + relatedPropertyUri + ". Setting edit mode to REPAIR.");
|
||||
}else if(stmts.size() == 1 ){
|
||||
mode = EditMode.EDIT; // editing single statement
|
||||
log.debug("Single statement found for property " + relatedPropertyUri + ". Setting edit mode to EDIT.");
|
||||
}
|
||||
} else {
|
||||
log.debug("Statements null for property " + relatedPropertyUri + " . Setting edit mode to ADD.");
|
||||
}
|
||||
} else {
|
||||
log.debug("No object. Setting edit mode to ADD.");
|
||||
}
|
||||
return mode;
|
||||
return getEditMode(request, obj, relatedPropertyUri);
|
||||
}
|
||||
|
||||
public static EditMode getEditMode(HttpServletRequest request, Individual obj, String relatedPropertyUri) {
|
||||
EditMode mode = EditMode.ADD;
|
||||
if( obj != null){
|
||||
List<ObjectPropertyStatement> stmts = obj.getObjectPropertyStatements(relatedPropertyUri);
|
||||
if( stmts != null){
|
||||
if( stmts.size() > 1 ){
|
||||
mode = EditMode.ERROR; // Multiple roleIn statements, yuck.
|
||||
log.debug("Multiple statements found for property " + relatedPropertyUri + ". Setting edit mode to ERROR.");
|
||||
}else if( stmts.size() == 0 ){
|
||||
mode = EditMode.REPAIR; // need to repair the role node
|
||||
log.debug("No statements found for property " + relatedPropertyUri + ". Setting edit mode to REPAIR.");
|
||||
}else if(stmts.size() == 1 ){
|
||||
mode = EditMode.EDIT; // editing single statement
|
||||
log.debug("Single statement found for property " + relatedPropertyUri + ". Setting edit mode to EDIT.");
|
||||
}
|
||||
} else {
|
||||
log.debug("Statements null for property " + relatedPropertyUri + " . Setting edit mode to ADD.");
|
||||
}
|
||||
} else {
|
||||
log.debug("No object. Setting edit mode to ADD.");
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue