Simplification of default object property form (in the edit configuration template - i.e. leaving out the range options generation for all but the default forms) -
This commit is contained in:
parent
f5e1661f9a
commit
ad0ff55080
6 changed files with 35 additions and 37 deletions
|
@ -168,7 +168,11 @@ public class EditN3GeneratorVTwo {
|
|||
//make the multivalue literal string
|
||||
List<String> n3Values = new ArrayList<String>(values.size());
|
||||
for( Literal value : values){
|
||||
n3Values.add( formatLiteral(value) );
|
||||
if(value != null) {
|
||||
n3Values.add( formatLiteral(value) );
|
||||
} else {
|
||||
log.debug("value of literal for " + var + " was null");
|
||||
}
|
||||
}
|
||||
String valueString = org.apache.commons.lang.StringUtils.join(n3Values, ",");
|
||||
|
||||
|
|
|
@ -123,6 +123,8 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
|
|||
setTemplate(editConfiguration, vreq);
|
||||
//Set edit key
|
||||
setEditKey(editConfiguration, vreq);
|
||||
//Adding additional data, specifically edit mode
|
||||
addFormSpecificData(editConfiguration, vreq);
|
||||
return editConfiguration;
|
||||
}
|
||||
|
||||
|
@ -523,6 +525,18 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
|
|||
}
|
||||
}
|
||||
|
||||
//Form specific data
|
||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||
//range options need to be stored for object property
|
||||
//Store field names
|
||||
List<String> objectSelect = new ArrayList<String>();
|
||||
objectSelect.add(editConfiguration.getVarNameForObject());
|
||||
//TODO: Check if this is the proper way to do this?
|
||||
formSpecificData.put("objectSelect", objectSelect);
|
||||
editConfiguration.setFormSpecificData(formSpecificData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -96,9 +96,6 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
|||
private void populateDropdowns() {
|
||||
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) {
|
||||
|
@ -123,11 +120,6 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
|||
}
|
||||
return selectedValue;
|
||||
}
|
||||
|
||||
private boolean isRangeOptionsExist() {
|
||||
boolean rangeOptionsExist = (pageData.get("rangeOptionsExist") != null && (Boolean) pageData.get("rangeOptionsExist") == true);
|
||||
return rangeOptionsExist;
|
||||
}
|
||||
|
||||
private void setFormTitle() {
|
||||
String predicateUri = editConfig.getPredicateUri();
|
||||
|
@ -228,29 +220,6 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
|||
|
||||
}
|
||||
|
||||
private void setRangeOptions() {
|
||||
ObjectProperty prop = EditConfigurationUtils.getObjectProperty(vreq);
|
||||
if( prop != null && prop.getSelectFromExisting() ){
|
||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||
//TODO: Change this to varname for object from object property?
|
||||
String fieldName = editConfig.getVarNameForObject();
|
||||
//TODO: Check if this still works?
|
||||
Map<String,String> rangeOptions = SelectListGeneratorVTwo.getOptions(editConfig, fieldName , wdf);
|
||||
if( rangeOptions != null && rangeOptions.size() > 0 ) {
|
||||
pageData.put("rangeOptionsExist", true);
|
||||
pageData.put("rangeOptions", rangeOptions);
|
||||
} else {
|
||||
pageData.put("rangeOptionsExist",false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Get page data
|
||||
public boolean getRangeOptionsExist() {
|
||||
return isRangeOptionsExist();
|
||||
}
|
||||
|
||||
public String getFormTitle() {
|
||||
return (String) pageData.get("formTitle");
|
||||
|
|
|
@ -28,5 +28,9 @@ public class MultiValueEditSubmissionTemplateModel {
|
|||
public Map<String, List<String>> getUrisFromForm() {
|
||||
return editSub.getUrisFromForm();
|
||||
}
|
||||
|
||||
public boolean getSubmissionExists() {
|
||||
return (this.editSub != null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue