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();
|
Map<String, List<Literal>> literalsInScope = editConfig.getLiteralsInScope();
|
||||||
List<String> stringValues = new ArrayList<String>();
|
List<String> stringValues = new ArrayList<String>();
|
||||||
List<Literal> literalValues = literalsInScope.get(fieldName);
|
List<Literal> literalValues = literalsInScope.get(fieldName);
|
||||||
for(Literal l: literalValues) {
|
//TODO: Check whether it's correct that literal values would be null?
|
||||||
//Could do additional processing here if required, for example if date etc. if need be
|
if(literalValues != null) {
|
||||||
stringValues.add(l.getValue().toString());
|
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;
|
return stringValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +232,10 @@ public class EditConfigurationUtils {
|
||||||
Configuration fmConfig = FreemarkerConfigurationLoader.getConfig(vreq, vreq.getSession().getServletContext());
|
Configuration fmConfig = FreemarkerConfigurationLoader.getConfig(vreq, vreq.getSession().getServletContext());
|
||||||
|
|
||||||
FieldVTwo field = editConfig == null ? null : editConfig.getField(fieldName);
|
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 ){
|
if( field != null && field.getEditElement() != null ){
|
||||||
html = field.getEditElement().draw(fieldName, editConfig, editSub, fmConfig);
|
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){
|
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
|
//make the multivalue literal string
|
||||||
List<String> n3Values = new ArrayList<String>(values.size());
|
List<String> n3Values = new ArrayList<String>(values.size());
|
||||||
|
|
|
@ -903,7 +903,8 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
|
||||||
//Get edit mode
|
//Get edit mode
|
||||||
private EditMode getEditMode(VitroRequest vreq) {
|
private EditMode getEditMode(VitroRequest vreq) {
|
||||||
String roleToActivityPredicate = getRoleToActivityPredicate(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;
|
return mode;
|
||||||
//(mode == EditMode.ADD || mode == EditMode.REPAIR) ? "\"nonempty\"
|
//(mode == EditMode.ADD || mode == EditMode.REPAIR) ? "\"nonempty\"
|
||||||
}
|
}
|
||||||
|
@ -969,7 +970,7 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat
|
||||||
//Form specific data
|
//Form specific data
|
||||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
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
|
//Fields that will need select lists generated
|
||||||
//Store field names
|
//Store field names
|
||||||
List<String> objectSelect = new ArrayList<String>();
|
List<String> objectSelect = new ArrayList<String>();
|
||||||
|
|
|
@ -73,7 +73,8 @@ public class PostEditCleanupController extends FreemarkerHttpServlet{
|
||||||
if(configuration == null)
|
if(configuration == null)
|
||||||
throw new Error("No edit configuration found.");
|
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);
|
MultiValueEditSubmission submission = new MultiValueEditSubmission(vreq.getParameterMap(), configuration);
|
||||||
String entityToReturnTo = ProcessRdfForm.processEntityToReturnTo(configuration, submission, vreq);
|
String entityToReturnTo = ProcessRdfForm.processEntityToReturnTo(configuration, submission, vreq);
|
||||||
return doPostEdit(vreq, entityToReturnTo);
|
return doPostEdit(vreq, entityToReturnTo);
|
||||||
|
@ -88,7 +89,7 @@ public class PostEditCleanupController extends FreemarkerHttpServlet{
|
||||||
EditConfigurationVTwo editConfig = EditConfigurationVTwo.getConfigFromSession(session,vreq);
|
EditConfigurationVTwo editConfig = EditConfigurationVTwo.getConfigFromSession(session,vreq);
|
||||||
//In order to support back button resubmissions, don't remove the editConfig from session.
|
//In order to support back button resubmissions, don't remove the editConfig from session.
|
||||||
//EditConfiguration.clearEditConfigurationInSession(session, editConfig);
|
//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);
|
MultiValueEditSubmission editSub = EditSubmissionUtils.getEditSubmissionFromSession(session,editConfig);
|
||||||
EditSubmissionUtils.clearEditSubmissionInSession(session, editSub);
|
EditSubmissionUtils.clearEditSubmissionInSession(session, editSub);
|
||||||
|
|
||||||
|
|
|
@ -32,28 +32,34 @@ public class FrontEndEditingUtils {
|
||||||
|
|
||||||
/* Determine whether a property editing form is in add, edit, or repair mode. */
|
/* Determine whether a property editing form is in add, edit, or repair mode. */
|
||||||
public static EditMode getEditMode(HttpServletRequest request, String relatedPropertyUri) {
|
public static EditMode getEditMode(HttpServletRequest request, String relatedPropertyUri) {
|
||||||
EditMode mode = EditMode.ADD;
|
|
||||||
Individual obj = (Individual)request.getAttribute("object");
|
Individual obj = (Individual)request.getAttribute("object");
|
||||||
if( obj != null){
|
return getEditMode(request, obj, relatedPropertyUri);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,26 @@
|
||||||
<#--Assign property-specific variables here-->
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
<#--Two stage form for clinical role-->
|
||||||
|
|
||||||
|
<#--
|
||||||
|
Required Values to be set for each form that includes addRoleToPersonTwoStage.ftl are:
|
||||||
|
roleDescriptor.
|
||||||
|
The other required values (roleType, optionsType, objectClassUri, and literalOptions are
|
||||||
|
set in the JAVA class corresponding to the form, e.g. AddClinicalRoleToPersonGenerator.java.
|
||||||
|
|
||||||
|
Optional values can be set, but each of these has default values
|
||||||
|
set in addRoleToPersonTwoStage.ftl:
|
||||||
|
|
||||||
|
buttonText
|
||||||
|
typeSelectorLabel
|
||||||
|
numDateFields
|
||||||
|
showRoleLAbelField
|
||||||
|
roleExamples-->
|
||||||
|
|
||||||
|
|
||||||
|
<#--Variable assignments for Add Clinical Role To Person-->
|
||||||
<#assign roleDescriptor = "clinical activity" />
|
<#assign roleDescriptor = "clinical activity" />
|
||||||
<#assign typeSelectorLabel = "clinical activity type" />
|
<#assign typeSelectorLabel = "clinical activity type" />
|
||||||
|
|
||||||
<#--Can Also set buttonText for a given form->
|
|
||||||
<#--Each of the two stage forms will include the form below-->
|
<#--Each of the two stage forms will include the form below-->
|
||||||
<#include "addRoleToPersonTwoStage.ftl">
|
<#include "addRoleToPersonTwoStage.ftl">
|
|
@ -6,7 +6,6 @@
|
||||||
<#assign uriValues = editConfiguration.existingUriValues />
|
<#assign uriValues = editConfiguration.existingUriValues />
|
||||||
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
|
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
|
||||||
|
|
||||||
Edit Mode is ${editMode}
|
|
||||||
<#--Freemarker variables with default values that can be overridden by specific forms-->
|
<#--Freemarker variables with default values that can be overridden by specific forms-->
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +39,7 @@ Edit Mode is ${editMode}
|
||||||
<#assign titleVerb = "Create"/>
|
<#assign titleVerb = "Create"/>
|
||||||
<#assign submitButtonText>${buttonText}</#assign>
|
<#assign submitButtonText>${buttonText}</#assign>
|
||||||
<#assign disabledVal = ""/>
|
<#assign disabledVal = ""/>
|
||||||
<#--The original jsp sets editMode to add, why?-->
|
<#assign editMode = "add" />
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#--Get existing value for specific data literals and uris-->
|
<#--Get existing value for specific data literals and uris-->
|
||||||
|
@ -48,25 +47,23 @@ Edit Mode is ${editMode}
|
||||||
|
|
||||||
<#--Get selected activity type value if it exists, this is alternative to below-->
|
<#--Get selected activity type value if it exists, this is alternative to below-->
|
||||||
<#assign activityTypeValue = ""/>
|
<#assign activityTypeValue = ""/>
|
||||||
<#if uriValues?keys?seq_contains("activityType") && uriValues.activityType?size > 0>
|
<#if uriValues?keys?seq_contains("roleActivityType") && (uriValues.roleActivityType?size > 0)>
|
||||||
<#assign activityTypeValue = uriValues.activityType[0] />
|
<#assign activityTypeValue = uriValues.roleActivityType[0] />
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#--Get activity label value-->
|
<#--Get activity label value-->
|
||||||
<#assign activityLabelValue = "" />
|
<#assign activityLabelValue = "" />
|
||||||
<#if literalValues?keys?seq_contains("activityLabel") && literalValues.activityLabel?size > 0>
|
<#if literalValues?keys?seq_contains("activityLabel") && (literalValues.activityLabel?size > 0)>
|
||||||
<#assign activityLabelValue = literalValues.activityLabel[0] />
|
<#assign activityLabelValue = literalValues.activityLabel[0] />
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#--Get role label-->
|
<#--Get role label-->
|
||||||
<#assign roleLabel = "" />
|
<#assign roleLabel = "" />
|
||||||
<#if literalValues?keys?seq_contains("roleLabel") && literalValues.roleLabel?size > 0 >
|
<#if literalValues?keys?seq_contains("roleLabel") && (literalValues.roleLabel?size > 0) >
|
||||||
<#assign roleLabel = literalValues.roleLabel[0] />
|
<#assign roleLabel = literalValues.roleLabel[0] />
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
|
|
||||||
ActivityLabel:${activityLabelValue}
|
|
||||||
Activity type: ${activityTypeValue}
|
|
||||||
|
|
||||||
<h2>${titleVerb} ${roleDescriptor} entry for ${editConfiguration.subjectName}</h2>
|
<h2>${titleVerb} ${roleDescriptor} entry for ${editConfiguration.subjectName}</h2>
|
||||||
|
|
||||||
|
@ -94,15 +91,20 @@ Activity type: ${activityTypeValue}
|
||||||
<p class="inline"><label for="typeSelector">${roleDescriptor?capitalize} Type <span class='requiredHint'> *</span></label>
|
<p class="inline"><label for="typeSelector">${roleDescriptor?capitalize} Type <span class='requiredHint'> *</span></label>
|
||||||
<select id="typeSelector" name="roleActivityType"
|
<select id="typeSelector" name="roleActivityType"
|
||||||
<#if disabledVal?has_content>
|
<#if disabledVal?has_content>
|
||||||
disabled = ${disabledVal}
|
disabled = "${disabledVal}"
|
||||||
</#if>
|
</#if>
|
||||||
>
|
>
|
||||||
|
<#--Code below allows for selection of first 'select one' option if no activity type selected-->
|
||||||
|
<#if activityTypeValue?has_content>
|
||||||
|
<#assign selectedActivityType = activityTypeValue />
|
||||||
|
<#else>
|
||||||
|
<#assign selectedActivityType = "" />
|
||||||
|
</#if>
|
||||||
<#assign roleActivityTypeSelect = editConfiguration.pageData.roleActivityType />
|
<#assign roleActivityTypeSelect = editConfiguration.pageData.roleActivityType />
|
||||||
<#assign roleActivityTypeKeys = roleActivityTypeSelect?keys />
|
<#assign roleActivityTypeKeys = roleActivityTypeSelect?keys />
|
||||||
<#list roleActivityTypeKeys as key>
|
<#list roleActivityTypeKeys as key>
|
||||||
<option value="${key}"
|
<option value="${key}"
|
||||||
<#if activityTypeValue?has_content
|
<#if selectedActivityType = key>selected</#if>
|
||||||
&& activityTypeValue = key>selected</#if>
|
|
||||||
>
|
>
|
||||||
${roleActivityTypeSelect[key]}
|
${roleActivityTypeSelect[key]}
|
||||||
</option>
|
</option>
|
||||||
|
@ -123,8 +125,8 @@ Activity type: ${activityTypeValue}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<#if editMode = "edit">
|
<#if editMode = "edit">
|
||||||
<input type="hidden" id="roleActivityType" name="roleActivityType" value/>
|
<input type="hidden" id="roleActivityType" name="roleActivityType" value="${activityTypeValue}"/>
|
||||||
<input type="hidden" id="activityLabel" name="activityLabel"/>
|
<input type="hidden" id="activityLabel" name="activityLabel" value="${activityLabelValue}}"/>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<div class="acSelection">
|
<div class="acSelection">
|
||||||
|
@ -163,7 +165,7 @@ Activity type: ${activityTypeValue}
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" id="editKey" name="editKey" value="${editKey} />
|
<input type="hidden" id="editKey" name="editKey" value="${editKey} />
|
||||||
<p class="submit">
|
<p class="submit">
|
||||||
<input type="submit" id="submit" value="submitButtonText"/><span class="or"> or <a class="cancel" href="${cancelUrl}">Cancel</a>
|
<input type="submit" id="submit" value="${submitButtonText}"/><span class="or"> or <a class="cancel" href="${cancelUrl}">Cancel</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p id="requiredLegend" class="requiredHint">* required fields</p>
|
<p id="requiredLegend" class="requiredHint">* required fields</p>
|
||||||
|
@ -182,7 +184,7 @@ Activity type: ${activityTypeValue}
|
||||||
|
|
||||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
|
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
|
||||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
|
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
|
||||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.cs" />')}
|
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')}
|
||||||
|
|
||||||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>')}
|
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>')}
|
||||||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>')}
|
${scripts.add('<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>')}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue