Updates for freemarker conversion, removing 2 stage role forms from vitro since they belong in vivo
This commit is contained in:
parent
85b9c04850
commit
23329bd5fc
6 changed files with 398 additions and 266 deletions
|
@ -0,0 +1,337 @@
|
|||
/* $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.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||
import com.hp.hpl.jena.vocabulary.XSD;
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
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.dao.DisplayVocabulary;
|
||||
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.EditConfigurationVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditN3GeneratorVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.SelectListGeneratorVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
|
||||
|
||||
/**
|
||||
* Generates the edit configuration for a default property form.
|
||||
*
|
||||
*/
|
||||
public class NewIndividualFormGenerator implements EditConfigurationGenerator {
|
||||
|
||||
private Log log = LogFactory.getLog(NewIndividualFormGenerator.class);
|
||||
private boolean isObjectPropForm = false;
|
||||
private String subjectUri = null;
|
||||
private String predicateUri = null;
|
||||
private String objectUri = null;
|
||||
private String datapropKeyStr= null;
|
||||
private int dataHash = 0;
|
||||
private DataPropertyStatement dps = null;
|
||||
private String dataLiteral = null;
|
||||
private String template = "newIndividualForm.ftl";
|
||||
private static HashMap<String,String> defaultsForXSDtypes ;
|
||||
static {
|
||||
defaultsForXSDtypes = new HashMap<String,String>();
|
||||
//defaultsForXSDtypes.put("http://www.w3.org/2001/XMLSchema#dateTime","2001-01-01T12:00:00");
|
||||
defaultsForXSDtypes.put("http://www.w3.org/2001/XMLSchema#dateTime","#Unparseable datetime defaults to now");
|
||||
}
|
||||
@Override
|
||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
|
||||
EditConfigurationVTwo editConfiguration = new EditConfigurationVTwo();
|
||||
//Set n3 generator
|
||||
editConfiguration.setN3Generator(new EditN3GeneratorVTwo(editConfiguration));
|
||||
|
||||
//process subject, predicate, object parameters
|
||||
this.initProcessParameters(vreq, session, editConfiguration);
|
||||
|
||||
//Assumes this is a simple case of subject predicate var
|
||||
editConfiguration.setN3Required(this.generateN3Required(vreq));
|
||||
|
||||
//n3 optional
|
||||
editConfiguration.setN3Optional(this.generateN3Optional());
|
||||
|
||||
//Todo: what do new resources depend on here?
|
||||
//In original form, these variables start off empty
|
||||
editConfiguration.setNewResources(this.generateNewResources(vreq));
|
||||
//In scope
|
||||
this.setUrisAndLiteralsInScope(editConfiguration);
|
||||
|
||||
//on Form
|
||||
this.setUrisAndLiteralsOnForm(editConfiguration, vreq);
|
||||
|
||||
editConfiguration.setFilesOnForm(new ArrayList<String>());
|
||||
|
||||
//Sparql queries
|
||||
this.setSparqlQueries(editConfiguration);
|
||||
|
||||
//set fields
|
||||
setFields(editConfiguration, vreq, EditConfigurationUtils.getPredicateUri(vreq));
|
||||
|
||||
// No need to put in session here b/c put in session within edit request dispatch controller instead
|
||||
//placing in session depends on having edit key which is handled in edit request dispatch controller
|
||||
// editConfiguration.putConfigInSession(editConfiguration, session);
|
||||
|
||||
prepareForUpdate(vreq, session, editConfiguration);
|
||||
|
||||
|
||||
//Form title and submit label now moved to edit configuration template
|
||||
//TODO: check if edit configuration template correct place to set those or whether
|
||||
//additional methods here should be used and reference instead, e.g. edit configuration template could call
|
||||
//default obj property form.populateTemplate or some such method
|
||||
//Select from existing also set within template itself
|
||||
setTemplate(editConfiguration, vreq);
|
||||
//Set edit key
|
||||
setEditKey(editConfiguration, vreq);
|
||||
addFormSpecificData(editConfiguration, vreq);
|
||||
|
||||
return editConfiguration;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private Map<String, String> generateNewResources(VitroRequest vreq) {
|
||||
HashMap<String, String> newResources = new HashMap<String, String>();
|
||||
//TODO: Get default namespace
|
||||
String defaultNamespace = vreq.getWebappDaoFactory().getDefaultNamespace();
|
||||
newResources.put("newInd", defaultNamespace + "individual");
|
||||
return newResources;
|
||||
}
|
||||
|
||||
private void setEditKey(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
String editKey = EditConfigurationUtils.getEditKey(vreq);
|
||||
editConfiguration.setEditKey(editKey);
|
||||
}
|
||||
|
||||
private void setTemplate(EditConfigurationVTwo editConfiguration,
|
||||
VitroRequest vreq) {
|
||||
editConfiguration.setTemplate(template);
|
||||
|
||||
}
|
||||
|
||||
//Initialize setup: process parameters
|
||||
private void initProcessParameters(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
||||
String formUrl = EditConfigurationUtils.getFormUrl(vreq);
|
||||
|
||||
subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
|
||||
predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||
|
||||
editConfiguration.setFormUrl(formUrl);
|
||||
|
||||
editConfiguration.setUrlPatternToReturnTo("/individual");
|
||||
|
||||
editConfiguration.setVarNameForSubject("subjectNotUsed");
|
||||
editConfiguration.setSubjectUri(subjectUri);
|
||||
editConfiguration.setEntityToReturnTo("?newInd");
|
||||
editConfiguration.setVarNameForPredicate("predicateNotUsed");
|
||||
editConfiguration.setPredicateUri(predicateUri);
|
||||
|
||||
//not concerned about remainder, can move into default obj prop form if required
|
||||
this.isObjectPropForm = true;
|
||||
this.initObjectParameters(vreq);
|
||||
this.processObjectPropForm(vreq, editConfiguration);
|
||||
}
|
||||
|
||||
|
||||
private void initObjectParameters(VitroRequest vreq) {
|
||||
//in case of object property
|
||||
objectUri = EditConfigurationUtils.getObjectUri(vreq);
|
||||
}
|
||||
|
||||
private void processObjectPropForm(VitroRequest vreq, EditConfigurationVTwo editConfiguration) {
|
||||
editConfiguration.setVarNameForObject("objectNotUsed");
|
||||
editConfiguration.setObject(objectUri);
|
||||
//this needs to be set for the editing to be triggered properly, otherwise the 'prepare' method
|
||||
//pretends this is a data property editing statement and throws an error
|
||||
//TODO: Check if null in case no object uri exists but this is still an object property
|
||||
if(objectUri != null) {
|
||||
editConfiguration.setObjectResource(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void processDataPropForm(VitroRequest vreq, EditConfigurationVTwo editConfiguration) {
|
||||
editConfiguration.setObjectResource(false);
|
||||
//set data prop value, data prop key str,
|
||||
editConfiguration.setDatapropKey((datapropKeyStr==null)?"":datapropKeyStr);
|
||||
editConfiguration.setVarNameForObject(dataLiteral);
|
||||
//original set datapropValue, which in this case would be empty string but no way here
|
||||
editConfiguration.setDatapropValue("");
|
||||
editConfiguration.setUrlPatternToReturnTo("/entity");
|
||||
}
|
||||
|
||||
//Get N3 required
|
||||
//Handles both object and data property
|
||||
private List<String> generateN3Required(VitroRequest vreq) {
|
||||
List<String> n3ForEdit = new ArrayList<String>();
|
||||
String editString = "?newInd <" + VitroVocabulary.RDF_TYPE + "> <" + getTypeOfNew(vreq) + "> .";
|
||||
n3ForEdit.add(editString);
|
||||
return n3ForEdit;
|
||||
}
|
||||
|
||||
private List<String> generateN3Optional() {
|
||||
List<String> n3Optional = new ArrayList<String>();
|
||||
String editString = "?newInd <" + RDFS.label.getURI() + "> ?label .";
|
||||
n3Optional.add(editString);
|
||||
return n3Optional;
|
||||
|
||||
}
|
||||
|
||||
//Set queries
|
||||
private String retrieveQueryForInverse () {
|
||||
String queryForInverse = "PREFIX owl: <http://www.w3.org/2002/07/owl#>"
|
||||
+ " SELECT ?inverse_property "
|
||||
+ " WHERE { ?inverse_property owl:inverseOf ?predicate } ";
|
||||
return queryForInverse;
|
||||
}
|
||||
|
||||
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration) {
|
||||
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
||||
//note that at this point the subject, predicate, and object var parameters have already been processed
|
||||
urisInScope.put(editConfiguration.getVarNameForSubject(),
|
||||
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
|
||||
urisInScope.put(editConfiguration.getVarNameForPredicate(),
|
||||
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
|
||||
editConfiguration.setUrisInScope(urisInScope);
|
||||
//Uris in scope include subject, predicate, and object var
|
||||
|
||||
editConfiguration.setLiteralsInScope(new HashMap<String, List<Literal>>());
|
||||
}
|
||||
|
||||
//n3 should look as follows
|
||||
//?subject ?predicate ?objectVar
|
||||
|
||||
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
List<String> urisOnForm = new ArrayList<String>();
|
||||
List<String> literalsOnForm = new ArrayList<String>();
|
||||
literalsOnForm.add("label");
|
||||
literalsOnForm.add("firstName");
|
||||
literalsOnForm.add("lastName");
|
||||
editConfiguration.setUrisOnform(urisOnForm);
|
||||
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
||||
}
|
||||
|
||||
private String getDataLiteral(VitroRequest vreq) {
|
||||
DataProperty prop = EditConfigurationUtils.getDataProperty(vreq);
|
||||
return prop.getLocalName() + "Edited";
|
||||
}
|
||||
|
||||
//This is for various items
|
||||
private void setSparqlQueries(EditConfigurationVTwo editConfiguration) {
|
||||
//Sparql queries defining retrieval of literals etc.
|
||||
editConfiguration.setSparqlForAdditionalLiteralsInScope(new HashMap<String, String>());
|
||||
|
||||
Map<String, String> urisInScope = new HashMap<String, String>();
|
||||
editConfiguration.setSparqlForAdditionalUrisInScope(urisInScope);
|
||||
|
||||
editConfiguration.setSparqlForExistingLiterals(generateSparqlForExistingLiterals());
|
||||
editConfiguration.setSparqlForExistingUris(generateSparqlForExistingUris());
|
||||
}
|
||||
|
||||
|
||||
//Get page uri for object
|
||||
private HashMap<String, String> generateSparqlForExistingUris() {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
return map;
|
||||
}
|
||||
|
||||
private HashMap<String, String> generateSparqlForExistingLiterals() {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
private void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
|
||||
Map<String, FieldVTwo> fields = new HashMap<String, FieldVTwo>();
|
||||
getLabelField(editConfiguration, vreq, fields);
|
||||
|
||||
}
|
||||
|
||||
private void getLabelField(EditConfigurationVTwo editConfiguration,
|
||||
VitroRequest vreq, Map<String, FieldVTwo> fields) {
|
||||
FieldVTwo field = new FieldVTwo();
|
||||
field.setName("label");
|
||||
field.setNewResource(false);
|
||||
//queryForExisting is not being used anywhere in Field
|
||||
String stringDatatypeUri = XSD.xstring.toString();
|
||||
|
||||
|
||||
List<String> validators = new ArrayList<String>();
|
||||
validators.add("nonempty");
|
||||
field.setValidators(validators);
|
||||
|
||||
//subjectUri and subjectClassUri are not being used in Field
|
||||
|
||||
field.setOptionsType("UNDEFINED");
|
||||
//why isn't predicate uri set for data properties?
|
||||
field.setPredicateUri(null);
|
||||
field.setObjectClassUri(null);
|
||||
field.setRangeDatatypeUri(stringDatatypeUri);
|
||||
|
||||
field.setLiteralOptions(new ArrayList<List<String>>());
|
||||
|
||||
//set assertions
|
||||
List<String> assertions = new ArrayList<String>();
|
||||
field.setAssertions(assertions);
|
||||
fields.put(field.getName(), field);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void prepareForUpdate(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
||||
//Here, retrieve model from
|
||||
Model model = (Model) session.getServletContext().getAttribute("jenaOntModel");
|
||||
//This form is always doing a non-update
|
||||
editConfiguration.prepareForNonUpdate( model );
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Get parameter
|
||||
private String getTypeOfNew(VitroRequest vreq) {
|
||||
return vreq.getParameter("typeOfNew");
|
||||
}
|
||||
|
||||
//Form specific data
|
||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||
formSpecificData.put("typeName", getTypeName(vreq));
|
||||
//Put in the fact that we require field
|
||||
editConfiguration.setFormSpecificData(formSpecificData);
|
||||
}
|
||||
|
||||
private String getTypeName(VitroRequest vreq) {
|
||||
String typeOfNew = getTypeOfNew(vreq);
|
||||
VClass type = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(typeOfNew);
|
||||
return type.getName();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -120,8 +120,10 @@ public class ProcessRdfFormController extends FreemarkerHttpServlet{
|
|||
private void applyEditSubmissionPreprocessors(
|
||||
EditConfigurationVTwo configuration, MultiValueEditSubmission submission) {
|
||||
List<EditSubmissionVTwoPreprocessor> preprocessors = configuration.getEditSubmissionPreprocessors();
|
||||
for(EditSubmissionVTwoPreprocessor p: preprocessors) {
|
||||
p.preprocess(submission);
|
||||
if(preprocessors != null) {
|
||||
for(EditSubmissionVTwoPreprocessor p: preprocessors) {
|
||||
p.preprocess(submission);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,18 +93,20 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
|||
//Based on certain pre-set fields/variables, look for what
|
||||
//drop-downs need to be populated
|
||||
private void populateDropdowns() {
|
||||
if(EditConfigurationUtils.isObjectProperty(editConfig.getPredicateUri(), vreq)) {
|
||||
setRangeOptions();
|
||||
}
|
||||
if(pageData.containsKey("objectSelect")) {
|
||||
List<String> fieldNames = (List<String>)pageData.get("objectSelect");
|
||||
for(String field:fieldNames) {
|
||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||
Map<String,String> optionsMap = SelectListGeneratorVTwo.getOptions(editConfig, field , wdf);
|
||||
pageData.put(field, optionsMap);
|
||||
}
|
||||
}
|
||||
|
||||
String predicateUri = editConfig.getPredicateUri();
|
||||
if(predicateUri != null) {
|
||||
if(EditConfigurationUtils.isObjectProperty(editConfig.getPredicateUri(), vreq)) {
|
||||
setRangeOptions();
|
||||
}
|
||||
if(pageData.containsKey("objectSelect")) {
|
||||
List<String> fieldNames = (List<String>)pageData.get("objectSelect");
|
||||
for(String field:fieldNames) {
|
||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||
Map<String,String> optionsMap = SelectListGeneratorVTwo.getOptions(editConfig, field , wdf);
|
||||
pageData.put(field, optionsMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Check if this should return a list instead
|
||||
|
@ -127,11 +129,13 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
|||
}
|
||||
|
||||
private void setFormTitle() {
|
||||
//if(editConfig.isObjectResource()) {
|
||||
if(EditConfigurationUtils.isObjectProperty(editConfig.getPredicateUri(), vreq)) {
|
||||
setObjectFormTitle();
|
||||
} else {
|
||||
setDataFormTitle();
|
||||
String predicateUri = editConfig.getPredicateUri();
|
||||
if(predicateUri != null) {
|
||||
if(EditConfigurationUtils.isObjectProperty(editConfig.getPredicateUri(), vreq)) {
|
||||
setObjectFormTitle();
|
||||
} else {
|
||||
setDataFormTitle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,32 +200,36 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
|||
|
||||
private void setSubmitLabel() {
|
||||
String submitLabel = null;
|
||||
if(EditConfigurationUtils.isObjectProperty(editConfig.getPredicateUri(), vreq)) {
|
||||
Individual objectIndividual = EditConfigurationUtils.getObjectIndividual(vreq);
|
||||
ObjectProperty prop = EditConfigurationUtils.getObjectProperty(vreq);
|
||||
|
||||
if(objectIndividual != null) {
|
||||
submitLabel = "Save change";
|
||||
} else {
|
||||
if ( prop.getOfferCreateNewOption() ) {
|
||||
submitLabel = "Select existing";
|
||||
} else {
|
||||
submitLabel = "Save entry";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(editConfig.isDataPropertyUpdate()) {
|
||||
submitLabel = "Save change";
|
||||
String predicateUri = editConfig.getPredicateUri();
|
||||
if(predicateUri != null) {
|
||||
if(EditConfigurationUtils.isObjectProperty(editConfig.getPredicateUri(), vreq)) {
|
||||
Individual objectIndividual = EditConfigurationUtils.getObjectIndividual(vreq);
|
||||
ObjectProperty prop = EditConfigurationUtils.getObjectProperty(vreq);
|
||||
|
||||
if(objectIndividual != null) {
|
||||
submitLabel = "Save change";
|
||||
} else {
|
||||
if ( prop.getOfferCreateNewOption() ) {
|
||||
submitLabel = "Select existing";
|
||||
} else {
|
||||
submitLabel = "Save entry";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
submitLabel = "Save entry";
|
||||
if(editConfig.isDataPropertyUpdate()) {
|
||||
submitLabel = "Save change";
|
||||
} else {
|
||||
submitLabel = "Save entry";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pageData.put("submitLabel", submitLabel);
|
||||
|
||||
}
|
||||
|
||||
private void setRangeOptions() {
|
||||
ObjectProperty prop = EditConfigurationUtils.getObjectProperty(vreq);
|
||||
if( prop.getSelectFromExisting() ){
|
||||
if( prop != null && prop.getSelectFromExisting() ){
|
||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||
//TODO: Change this to varname for object from object property?
|
||||
String fieldName = editConfig.getVarNameForObject();
|
||||
|
@ -320,11 +328,14 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
|||
public Property getPredicateProperty() {
|
||||
String predicateUri = getPredicateUri();
|
||||
//If predicate uri corresponds to object property, return that
|
||||
if(EditConfigurationUtils.isObjectProperty(predicateUri, vreq)){
|
||||
return EditConfigurationUtils.getObjectPropertyForPredicate(this.vreq, predicateUri);
|
||||
if(predicateUri != null) {
|
||||
if(EditConfigurationUtils.isObjectProperty(predicateUri, vreq)){
|
||||
return EditConfigurationUtils.getObjectPropertyForPredicate(this.vreq, predicateUri);
|
||||
}
|
||||
//otherwise return Data property
|
||||
return EditConfigurationUtils.getDataPropertyForPredicate(this.vreq, predicateUri);
|
||||
}
|
||||
//otherwise return Data property
|
||||
return EditConfigurationUtils.getDataPropertyForPredicate(this.vreq, predicateUri);
|
||||
return null;
|
||||
}
|
||||
|
||||
public ObjectProperty getObjectPredicateProperty() {
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
<#-- $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 typeSelectorLabel = "clinical activity type" />
|
||||
|
||||
|
||||
<#--Each of the two stage forms will include the form below-->
|
||||
<#include "addRoleToPersonTwoStage.ftl">
|
|
@ -1,194 +0,0 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#--Retrieve certain edit configuration information-->
|
||||
<#assign editMode = editConfiguration.pageData.editMode />
|
||||
<#assign literalValues = editConfiguration.existingLiteralValues />
|
||||
<#assign uriValues = editConfiguration.existingUriValues />
|
||||
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
|
||||
|
||||
<#--Freemarker variables with default values that can be overridden by specific forms-->
|
||||
|
||||
|
||||
<#--buttonText, typeSelectorLabel, numDateFields, showRoleLabelField, roleExamples-->
|
||||
<#if !buttonText?has_content>
|
||||
<#assign buttonText = roleDescriptor />
|
||||
</#if>
|
||||
<#if !typeSelectorLabel?has_content>
|
||||
<#assign typeSelectorLabel = roleDescriptor />
|
||||
</#if>
|
||||
<#if !numDateFields?has_content>
|
||||
<#assign numDateFields = 2 />
|
||||
</#if>
|
||||
<#if !showRoleLabelField?has_content>
|
||||
<#assign showRoleLabelField = true />
|
||||
</#if>
|
||||
<#if !roleExamples?has_content>
|
||||
<#assign roleExamples = "" />
|
||||
</#if>
|
||||
|
||||
<#--Setting values for titleVerb, submitButonText, and disabled Value-->
|
||||
<#if editConfiguration.objectUri?has_content>
|
||||
<#assign titleVerb = "Edit"/>
|
||||
<#assign submitButtonText>Edit ${buttonText}</#assign>
|
||||
<#if editMode = "repair">
|
||||
<#assign disabledVal = ""/>
|
||||
<#else>
|
||||
<#assign disabledVal = "disabled"/>
|
||||
</#if>
|
||||
<#else>
|
||||
<#assign titleVerb = "Create"/>
|
||||
<#assign submitButtonText>${buttonText}</#assign>
|
||||
<#assign disabledVal = ""/>
|
||||
<#assign editMode = "add" />
|
||||
</#if>
|
||||
|
||||
<#--Get existing value for specific data literals and uris-->
|
||||
|
||||
|
||||
<#--Get selected activity type value if it exists, this is alternative to below-->
|
||||
<#assign activityTypeValue = ""/>
|
||||
<#if uriValues?keys?seq_contains("roleActivityType") && (uriValues.roleActivityType?size > 0)>
|
||||
<#assign activityTypeValue = uriValues.roleActivityType[0] />
|
||||
</#if>
|
||||
|
||||
<#--Get activity label value-->
|
||||
<#assign activityLabelValue = "" />
|
||||
<#if literalValues?keys?seq_contains("activityLabel") && (literalValues.activityLabel?size > 0)>
|
||||
<#assign activityLabelValue = literalValues.activityLabel[0] />
|
||||
</#if>
|
||||
|
||||
<#--Get role label-->
|
||||
<#assign roleLabel = "" />
|
||||
<#if literalValues?keys?seq_contains("roleLabel") && (literalValues.roleLabel?size > 0) >
|
||||
<#assign roleLabel = literalValues.roleLabel[0] />
|
||||
</#if>
|
||||
|
||||
|
||||
|
||||
<h2>${titleVerb} ${roleDescriptor} entry for ${editConfiguration.subjectName}</h2>
|
||||
|
||||
<#--Display error messages if any-->
|
||||
<#if errorNameFieldIsEmpty??>
|
||||
<#assign errorMessage = "Enter a name for the ." />
|
||||
</#if>
|
||||
|
||||
<#if errorRoleFieldIsEmpty??>
|
||||
<#assign errorMessage = "Specify a role for this ." />
|
||||
</#if>
|
||||
|
||||
<#if errorMessage?has_content>
|
||||
<section id="error-alert" role="alert">
|
||||
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
|
||||
<p>${errorMessage}</p>
|
||||
</section>
|
||||
</#if>
|
||||
|
||||
|
||||
<section id="add${roleDescriptor?capitalize}RoleToPersonTwoStage" role="region">
|
||||
|
||||
<form id="add${roleDescriptor?capitalize}RoleToPersonTwoStage" class="customForm noIE67" action="${submitUrl}" role="add/edit grant role">
|
||||
|
||||
<p class="inline"><label for="typeSelector">${roleDescriptor?capitalize} Type <span class='requiredHint'> *</span></label>
|
||||
<select id="typeSelector" name="roleActivityType"
|
||||
<#if disabledVal?has_content>
|
||||
disabled = "${disabledVal}"
|
||||
</#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 roleActivityTypeKeys = roleActivityTypeSelect?keys />
|
||||
<#list roleActivityTypeKeys as key>
|
||||
<option value="${key}"
|
||||
<#if selectedActivityType = key>selected</#if>
|
||||
>
|
||||
${roleActivityTypeSelect[key]}
|
||||
</option>
|
||||
</#list>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<div class="fullViewOnly">
|
||||
<p>
|
||||
<label for="relatedIndLabel">${roleDescriptor?capitalize} Name <span class='requiredHint'> *</span></label>
|
||||
<input class="acSelector" size="50" type="text" id="relatedIndLabel" name="activityLabel" value="${activityLabelValue}"
|
||||
<#if disabledVal?has_content>
|
||||
disabled=${disabledVal}
|
||||
</#if>
|
||||
/>
|
||||
</p>
|
||||
|
||||
<#if editMode = "edit">
|
||||
<input type="hidden" id="roleActivityType" name="roleActivityType" value="${activityTypeValue}"/>
|
||||
<input type="hidden" id="activityLabel" name="activityLabel" value="${activityLabelValue}}"/>
|
||||
</#if>
|
||||
|
||||
<div class="acSelection">
|
||||
<p class="inline">
|
||||
<label>Selected ${roleDescriptor?capitalize}:</label>
|
||||
<span class="acSelectionInfo"></span>
|
||||
<a href="/vivo/individual?uri=" class="verifyMatch">(Verify this match)</a>
|
||||
</p>
|
||||
<input class="acUriReceiver" type="hidden" id="roleActivityUri" name="roleActivity" value="" />
|
||||
<!-- Field value populated by JavaScript -->
|
||||
</div>
|
||||
|
||||
<#if showRoleLabelField = true>
|
||||
<p><label for="roleLabel">Role in ### <span class='requiredHint'> *</span> ${roleExamples}</label>
|
||||
<input size="50" type="text" id="roleLabel" name="roleLabel" value="${roleLabel}" />
|
||||
</p>
|
||||
</#if>
|
||||
|
||||
<#if numDateFields == 1 >
|
||||
<#--Generated html is a map with key name mapping to html string-->
|
||||
<#if htmlForElements?keys?seq_contains("startField")>
|
||||
<label for="startField">Start Year <span class='hint'>(YYYY)</span></label>
|
||||
${htmlForElements["startField"]}
|
||||
</#if>
|
||||
<#else>
|
||||
<h4>Years of Participation in ${roleDescriptor?capitalize}</h4>
|
||||
<#if htmlForElements?keys?seq_contains("startField")>
|
||||
<label for="startField">Start Year <span class='hint'>(YYYY)</span></label>
|
||||
${htmlForElements["startField"]}
|
||||
</#if>
|
||||
<#if htmlForElements?keys?seq_contains("endField")>
|
||||
<label for="endField">End Year <span class='hint'>(YYYY)</span></label>
|
||||
${htmlForElements["endField"]}
|
||||
</#if>
|
||||
</#if>
|
||||
</div>
|
||||
<input type="hidden" id="editKey" name="editKey" value="${editKey} />
|
||||
<p class="submit">
|
||||
<input type="submit" id="submit" value="${submitButtonText}"/><span class="or"> or <a class="cancel" href="${cancelUrl}">Cancel</a>
|
||||
</p>
|
||||
|
||||
<p id="requiredLegend" class="requiredHint">* required fields</p>
|
||||
</form>
|
||||
|
||||
<#--Specifying form-specific script and adding stylesheets and scripts-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var customFormData = {
|
||||
acUrl: '${urls.base}/autocomplete?tokenize=true',
|
||||
editMode: '${editMode}',
|
||||
submitButtonTextType: 'compound',
|
||||
defaultTypeName: 'activity' // used in repair mode, to generate button text and org name field label
|
||||
};
|
||||
</script>
|
||||
|
||||
${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/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/customFormUtils.js"></script>')}
|
||||
${scripts.add('<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')}
|
||||
|
||||
|
||||
</section>
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
<#-- Template for adding a new individual from the Site Admin page: VIVO version -->
|
||||
|
||||
<#--Retrieve certain edit configuration information-->
|
||||
<#assign typeName = editConfiguration.pageData.typeName />
|
||||
|
||||
<h2>Create a new ${subclassName}</h2>
|
||||
<h2>Create a new ${typeName}</h2>
|
||||
|
||||
<#if errorNameFieldIsEmpty??>
|
||||
<#assign errorMessage = "Enter a name." />
|
||||
|
@ -28,9 +30,9 @@
|
|||
</p>
|
||||
|
||||
<p class="submit">
|
||||
<input type="hidden" name = "editKey" value="${???}"/>
|
||||
<input type="submit" id="submit" value="editConfiguration.submitLabel"/>
|
||||
<span class="or"> or <a class="cancel" href="${editConfiguration.cancelUrl}">Cancel</a>
|
||||
<input type="hidden" name = "editKey" value="${editKey}"/>
|
||||
<input type="submit" id="submit" value="Create ${typeName}"/>
|
||||
<span class="or"> or <a class="cancel" href="${urls.base}/siteAdmin">Cancel</a>
|
||||
</p>
|
||||
|
||||
<p id="requiredLegend" class="requiredHint">* required fields</p>
|
||||
|
|
Loading…
Add table
Reference in a new issue