updates for page management - javascript, freemarker, and n3 editing/generator changes
This commit is contained in:
parent
bbd45d7851
commit
b713635c01
8 changed files with 807 additions and 22 deletions
|
@ -503,6 +503,15 @@ public class EditConfigurationVTwo {
|
|||
public void setUrisOnForm(String ... strs){
|
||||
this.urisOnform = Arrays.asList( strs );
|
||||
}
|
||||
//This doesn't overwrite or set but adds to existing list
|
||||
public void addUrisOnForm(List<String> urisOnform) {
|
||||
this.urisOnform.addAll(urisOnform);
|
||||
}
|
||||
|
||||
public void addUrisOnForm(String ... strs){
|
||||
this.urisOnform.addAll(Arrays.asList( strs ));
|
||||
}
|
||||
|
||||
|
||||
public void setFilesOnForm(List<String> filesOnForm){
|
||||
this.filesOnForm = filesOnForm;
|
||||
|
@ -1089,6 +1098,16 @@ public class EditConfigurationVTwo {
|
|||
fields.put( field.getName(), field);
|
||||
}
|
||||
|
||||
public void addFields(List<FieldVTwo> fields) {
|
||||
if( fields != null )
|
||||
{
|
||||
for(FieldVTwo f: fields) {
|
||||
this.addField(f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
|
||||
|
|
|
@ -16,6 +16,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.ManagePagePreprocessor;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.DataGetterUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.menuManagement.MenuManagementDataUtils;
|
||||
|
||||
|
@ -59,6 +60,8 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
|||
|
||||
//Adding additional data, specifically edit mode
|
||||
addFormSpecificData(conf, vreq);
|
||||
//Add preprocessor
|
||||
conf.addEditSubmissionPreprocessor(new ManagePagePreprocessor(conf));
|
||||
//Prepare
|
||||
prepare(vreq, conf);
|
||||
|
||||
|
|
|
@ -114,6 +114,27 @@ public class ManagePagePreprocessor extends
|
|||
private void addInputsToSubmission(ProcessDataGetterN3 pn, int counter, JSONObject jsonObject) {
|
||||
List<String> literalLabels = pn.getLiteralVarNamesBase();
|
||||
List<String> uriLabels = pn.getUriVarNamesBase();
|
||||
|
||||
for(String literalLabel:literalLabels) {
|
||||
//TODO: Deal with multiple submission values
|
||||
//This retrieves the value for this particular json object
|
||||
String literalValue = jsonObject.getString(literalLabel);
|
||||
//Var names will depend on which data getter object this is on the page, so depends on counter
|
||||
String submissionLiteralName = pn.getVarName(literalLabel, counter);
|
||||
//This adds literal, connecting the field with
|
||||
submission.addLiteralToForm(editConfiguration, editConfiguration.getField(submissionLiteralName), submissionLiteralName, new String[]{literalValue});
|
||||
}
|
||||
|
||||
for(String uriLabel:uriLabels) {
|
||||
//TODO: Deal with multiple submission values
|
||||
//This retrieves the value for this particular json object
|
||||
String uriValue = jsonObject.getString(uriLabel);
|
||||
//Var names will depend on which data getter object this is on the page, so depends on counter
|
||||
String submissionUriName = pn.getVarName(uriLabel, counter);
|
||||
//This adds literal, connecting the field with
|
||||
submission.addLiteralToForm(editConfiguration, editConfiguration.getField(submissionUriName), submissionUriName, new String[]{uriValue});
|
||||
|
||||
}
|
||||
//this needs to be different
|
||||
//Get the literals directly from the processor - which you can get based on counter
|
||||
//Problem then is we know what the connection is - some way to put that logic within the processor itself?
|
||||
|
@ -150,7 +171,8 @@ public class ManagePagePreprocessor extends
|
|||
|
||||
|
||||
private void addFields(ProcessDataGetterN3 pn, int counter) {
|
||||
|
||||
List<FieldVTwo> fields = pn.retrieveFields(counter);
|
||||
editConfiguration.addFields(fields);
|
||||
}
|
||||
|
||||
|
||||
|
@ -158,7 +180,10 @@ public class ManagePagePreprocessor extends
|
|||
//original literals on form: label, uris on form: conceptNode and conceptSource
|
||||
//This will overwrite the original values in the edit configuration
|
||||
private void addLiteralsAndUrisOnForm(ProcessDataGetterN3 pn, int counter) {
|
||||
|
||||
List<String> literalsOnForm = pn.retrieveLiteralsOnForm(counter);
|
||||
editConfiguration.addLiteralsOnForm(literalsOnForm);
|
||||
List<String> urisOnForm = pn.retrieveUrisOnForm(counter);
|
||||
editConfiguration.addUrisOnForm(urisOnForm);
|
||||
}
|
||||
|
||||
// N3 being reproduced
|
||||
|
@ -200,6 +225,8 @@ public class ManagePagePreprocessor extends
|
|||
//Each JSON Object will indicate the type of the data getter within it
|
||||
private String getDataGetterClass(JSONObject jsonObject) {
|
||||
return jsonObject.getString("dataGetterClass");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,9 +15,10 @@ public interface ProcessDataGetterN3 {
|
|||
public List<String >retrieveLiteralsOnForm(int counter);
|
||||
|
||||
|
||||
public List<String> retrieveUrissOnForm(int counter);
|
||||
public List<String> retrieveUrisOnForm(int counter);
|
||||
public List<FieldVTwo> retrieveFields(int counter);
|
||||
public List<String> getLiteralVarNamesBase();
|
||||
public List<String> getUriVarNamesBase();
|
||||
public String getVarName(String base, int counter);
|
||||
|
||||
}
|
||||
|
|
|
@ -58,26 +58,37 @@ public class ProcessSparqlDataGetterN3 implements ProcessDataGetterN3 {
|
|||
*/
|
||||
public List<String> retrieveLiteralsOnForm(int counter) {
|
||||
List<String> literalsOnForm = new ArrayList<String>();
|
||||
literalsOnForm.add("saveToVar" + counter);
|
||||
literalsOnForm.add("query" + counter);
|
||||
literalsOnForm.add(getVarName("saveToVar",counter));
|
||||
literalsOnForm.add(getVarName("query", counter));
|
||||
return literalsOnForm;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<String> retrieveUrissOnForm(int counter) {
|
||||
public List<String> retrieveUrisOnForm(int counter) {
|
||||
List<String> urisOnForm = new ArrayList<String>();
|
||||
//We have no uris as far as I know.. well query Model is a uri
|
||||
urisOnForm.add("queryModel" + counter);
|
||||
urisOnForm.add(getVarName("queryModel", counter));
|
||||
return urisOnForm;
|
||||
|
||||
}
|
||||
|
||||
public List<FieldVTwo> retrieveFields(int counter) {
|
||||
List<FieldVTwo> fields = new ArrayList<FieldVTwo>();
|
||||
fields.add(new FieldVTwo().setName("queryModel" + counter));
|
||||
fields.add(new FieldVTwo().setName("saveToVar" + counter));
|
||||
fields.add(new FieldVTwo().setName("query" + counter));
|
||||
|
||||
//An alternative way of doing this
|
||||
/*
|
||||
List<String> allFieldsBase = new ArrayList<String>();
|
||||
allFieldsBase.addAll(getLiteralVarNamesBase());
|
||||
allFieldsBase.addAll(getUriVarNamesBase());
|
||||
|
||||
for(String varName: allFieldsBase) {
|
||||
fields.add(new FieldVTwo().setName(getVarName(varName, counter)));
|
||||
} */
|
||||
|
||||
fields.add(new FieldVTwo().setName(getVarName("queryModel", counter)));
|
||||
fields.add(new FieldVTwo().setName(getVarName("saveToVar", counter)));
|
||||
fields.add(new FieldVTwo().setName(getVarName("query", counter)));
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
@ -90,6 +101,9 @@ public class ProcessSparqlDataGetterN3 implements ProcessDataGetterN3 {
|
|||
return Arrays.asList("queryModel");
|
||||
}
|
||||
|
||||
public String getVarName(String base, int counter) {
|
||||
return base + counter;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue