Updates to allow edit submission to return map of string to strings (instead of literals) for literal values for proper presentation on the form
This commit is contained in:
parent
25c96774ca
commit
74f9626b18
2 changed files with 28 additions and 18 deletions
|
@ -207,35 +207,43 @@ public class EditConfigurationUtils {
|
||||||
return dataHash;
|
return dataHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
//Copied from the original input element formatting tag
|
//Copied from the original input element formatting tag
|
||||||
//Allows the retrieval of the string values for the literals
|
//Allows the retrieval of the string values for the literals
|
||||||
//Useful for cases with date/time and other mechanisms
|
//Useful for cases with date/time and other mechanisms
|
||||||
public static Map<String, List<String>> getExistingLiteralValues(VitroRequest vreq, EditConfigurationVTwo editConfig) {
|
public static Map<String, List<String>> getExistingLiteralValues(VitroRequest vreq, EditConfigurationVTwo editConfig) {
|
||||||
Map<String, List<String>> literalsInScopeStringValues = new HashMap<String, List<String>>();
|
Map<String, List<String>> literalsInScopeStringValues = transformLiteralMap(editConfig.getLiteralsInScope());
|
||||||
Map<String, List<Literal>> literalsInScope = editConfig.getLiteralsInScope();
|
|
||||||
|
|
||||||
for(String key: literalsInScope.keySet() ) {
|
|
||||||
List<String> stringValues = processLiteral(editConfig, key);
|
|
||||||
literalsInScopeStringValues.put(key, stringValues);
|
|
||||||
}
|
|
||||||
return literalsInScopeStringValues;
|
return literalsInScopeStringValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Copied from input element formatting tag
|
private static List<String> transformLiteralListToStringList(List<Literal> literalValues){
|
||||||
private static List<String> processLiteral(EditConfigurationVTwo editConfig, String fieldName) {
|
|
||||||
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);
|
|
||||||
//TODO: Check whether it's correct that literal values would be null?
|
|
||||||
if(literalValues != null) {
|
if(literalValues != null) {
|
||||||
for(Literal l: literalValues) {
|
for(Literal l: literalValues) {
|
||||||
//Could do additional processing here if required, for example if date etc. if need be
|
//Could do additional processing here if required, for example if date etc. if need be
|
||||||
|
if(l != null) {
|
||||||
stringValues.add(l.getValue().toString());
|
stringValues.add(l.getValue().toString());
|
||||||
}
|
}
|
||||||
|
//else {
|
||||||
|
//TODO: //Do we keep null as a value for this key?
|
||||||
|
//stringValues.add(null);
|
||||||
|
//}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return stringValues;
|
return stringValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Map<String, List<String>> transformLiteralMap(Map<String, List<Literal>> map) {
|
||||||
|
Map<String, List<String>> literalMapStringValues = new HashMap<String, List<String>>();
|
||||||
|
|
||||||
|
for(String key: map.keySet() ) {
|
||||||
|
List<String> stringValues = transformLiteralListToStringList(map.get(key));
|
||||||
|
literalMapStringValues.put(key, stringValues);
|
||||||
|
}
|
||||||
|
return literalMapStringValues;
|
||||||
|
}
|
||||||
|
|
||||||
public static Map<String, List<String>> getExistingUriValues(EditConfigurationVTwo editConfig) {
|
public static Map<String, List<String>> getExistingUriValues(EditConfigurationVTwo editConfig) {
|
||||||
return editConfig.getUrisInScope();
|
return editConfig.getUrisInScope();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
|
||||||
|
|
||||||
public class MultiValueEditSubmissionTemplateModel {
|
public class MultiValueEditSubmissionTemplateModel {
|
||||||
|
@ -16,10 +17,11 @@ public class MultiValueEditSubmissionTemplateModel {
|
||||||
this.editSub = editSub;
|
this.editSub = editSub;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, List<Literal>> getLiteralsFromForm() {
|
public Map<String, List<String>> getLiteralsFromForm() {
|
||||||
if(editSub == null)
|
if(editSub == null)
|
||||||
return null;
|
return null;
|
||||||
return editSub.getLiteralsFromForm();
|
//Transforms from string to list of literals TO string to list of strings
|
||||||
|
return EditConfigurationUtils.transformLiteralMap(editSub.getLiteralsFromForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue