updates for page management, allowing addition of sparql data getter
This commit is contained in:
parent
be80e6ef41
commit
e3c6cc1640
8 changed files with 123 additions and 57 deletions
|
@ -436,15 +436,15 @@ public class EditConfigurationVTwo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setN3Required(String ... n3RequiredStrs){
|
public void setN3Required(String ... n3RequiredStrs){
|
||||||
this.n3Required = Arrays.asList( n3RequiredStrs );
|
this.n3Required = new ArrayList<String>(Arrays.asList( n3RequiredStrs )); //using ArrayList to allow list to be resized
|
||||||
}
|
}
|
||||||
//these methods allow strings to be added to the n3 required list and not just for the list to be set
|
//these methods allow strings to be added to the n3 required list and not just for the list to be set
|
||||||
public void addN3Required(List<String> n3Required) {
|
public void addN3Required(List<String> n3RequiredInput) {
|
||||||
this.n3Required.addAll(n3Required);
|
this.n3Required.addAll(n3RequiredInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addN3Required(String ... n3RequiredStrs) {
|
public void addN3Required(String ... n3RequiredStrsInput) {
|
||||||
this.n3Required.addAll(Arrays.asList( n3RequiredStrs ));
|
this.n3Required.addAll(Arrays.asList( n3RequiredStrsInput ));
|
||||||
}
|
}
|
||||||
/** return a copy of the value so that the configuration is not modified by external code.
|
/** return a copy of the value so that the configuration is not modified by external code.
|
||||||
* @return
|
* @return
|
||||||
|
@ -458,7 +458,7 @@ public class EditConfigurationVTwo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setN3Optional(String ... n3Strs){
|
public void setN3Optional(String ... n3Strs){
|
||||||
this.n3Optional = Arrays.asList( n3Strs );
|
this.n3Optional = new ArrayList<String>(Arrays.asList( n3Strs )); //using ArrayList to allow list to be resized
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addN3Optional(List<String> n3Optional) {
|
public void addN3Optional(List<String> n3Optional) {
|
||||||
|
@ -501,7 +501,7 @@ public class EditConfigurationVTwo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUrisOnForm(String ... strs){
|
public void setUrisOnForm(String ... strs){
|
||||||
this.urisOnform = Arrays.asList( strs );
|
this.urisOnform = new ArrayList<String>(Arrays.asList( strs )); //using ArrayList to allow resizing
|
||||||
}
|
}
|
||||||
//This doesn't overwrite or set but adds to existing list
|
//This doesn't overwrite or set but adds to existing list
|
||||||
public void addUrisOnForm(List<String> urisOnform) {
|
public void addUrisOnForm(List<String> urisOnform) {
|
||||||
|
@ -530,7 +530,7 @@ public class EditConfigurationVTwo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLiteralsOnForm(String ... strs){
|
public void setLiteralsOnForm(String ... strs){
|
||||||
this.literalsOnForm = Arrays.asList( strs );
|
this.literalsOnForm = new ArrayList<String>(Arrays.asList( strs ));//using ArrayList to allow resizing
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLiteralsOnForm(List<String> literalsOnForm) {
|
public void addLiteralsOnForm(List<String> literalsOnForm) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import javax.servlet.http.HttpSession;
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
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.EditConfigurationVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||||
|
@ -27,7 +28,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.menuManagement.MenuManagementDataU
|
||||||
public class ManagePageGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator{
|
public class ManagePageGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator{
|
||||||
|
|
||||||
private String template = "pageManagement.ftl";
|
private String template = "pageManagement.ftl";
|
||||||
|
public static final String defaultDisplayNs = DisplayVocabulary.NAMESPACE.getURI() + "n";
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration( VitroRequest vreq, HttpSession session) {
|
public EditConfigurationVTwo getEditConfiguration( VitroRequest vreq, HttpSession session) {
|
||||||
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
EditConfigurationVTwo conf = new EditConfigurationVTwo();
|
||||||
|
@ -71,7 +72,7 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
||||||
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo conf,
|
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo conf,
|
||||||
VitroRequest vreq) {
|
VitroRequest vreq) {
|
||||||
conf.setUrisOnForm(new String[]{"page", "menuItem"}); //new resources: should this be on form for new - should be for existing
|
conf.setUrisOnForm(new String[]{"page", "menuItem"}); //new resources: should this be on form for new - should be for existing
|
||||||
conf.setLiteralsOnForm(new String[]{"pageTitle", "urlMapping", "linkText", "menuPosition", "menuLinkText", "bodyTemplate", "pageContentUnit"}); //page content unit = data getter JSON object
|
conf.setLiteralsOnForm(new String[]{"pageName", "prettyUrl", "menuPosition", "menuLinkText", "customTemplate", "pageContentUnit"}); //page content unit = data getter JSON object
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,12 +89,12 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
||||||
|
|
||||||
private void setN3Optional(EditConfigurationVTwo conf) {
|
private void setN3Optional(EditConfigurationVTwo conf) {
|
||||||
//body template is not required, and a given page may or may not be a menu item, but should linked to menu if menu item
|
//body template is not required, and a given page may or may not be a menu item, but should linked to menu if menu item
|
||||||
conf.setN3Optional(Arrays.asList(prefixes + pageBodyTemplateN3,
|
conf.setN3Optional(new ArrayList<String>(Arrays.asList(prefixes + pageBodyTemplateN3,
|
||||||
prefixes + menuItemN3 + menuN3));
|
prefixes + menuItemN3 + menuN3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setN3Required(EditConfigurationVTwo conf) {
|
private void setN3Required(EditConfigurationVTwo conf) {
|
||||||
conf.setN3Required(Arrays.asList(prefixes + pageN3));
|
conf.setN3Required(new ArrayList<String>(Arrays.asList(prefixes + pageN3)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,24 +104,31 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
||||||
//Optional fields for page include body template
|
//Optional fields for page include body template
|
||||||
|
|
||||||
//required, therefore nonempty
|
//required, therefore nonempty
|
||||||
FieldVTwo titleField = new FieldVTwo().setName("pageTitle").
|
FieldVTwo titleField = new FieldVTwo().setName("pageName").
|
||||||
setValidators(Arrays.asList("nonempty"));
|
setValidators(Arrays.asList("nonempty"));
|
||||||
conf.addField(titleField);
|
conf.addField(titleField);
|
||||||
|
|
||||||
FieldVTwo urlField = new FieldVTwo().setName("urlMapping").setValidators(Arrays.asList("nonempty"));
|
FieldVTwo urlField = new FieldVTwo().setName("prettyUrl").setValidators(Arrays.asList("nonempty"));
|
||||||
conf.addField(urlField);
|
conf.addField(urlField);
|
||||||
|
|
||||||
//optional: body template
|
//optional: body template
|
||||||
FieldVTwo bodyTemplateField = new FieldVTwo().setName("bodyTemplate");
|
FieldVTwo bodyTemplateField = new FieldVTwo().setName("customTemplate");
|
||||||
conf.addField(bodyTemplateField);
|
conf.addField(bodyTemplateField);
|
||||||
|
|
||||||
|
|
||||||
//For menu item, these are optional b/c they depend on menu item
|
//For menu item, these are optional b/c they depend on menu item
|
||||||
FieldVTwo menuItemLinkTextField = new FieldVTwo().setName("linkText");
|
FieldVTwo menuItemLinkTextField = new FieldVTwo().setName("menuLinkText");
|
||||||
conf.addField(menuItemLinkTextField);
|
conf.addField(menuItemLinkTextField);
|
||||||
|
|
||||||
FieldVTwo menuItemPositionField = new FieldVTwo().setName("menuPosition");
|
FieldVTwo menuItemPositionField = new FieldVTwo().setName("menuPosition");
|
||||||
conf.addField(menuItemPositionField);
|
conf.addField(menuItemPositionField);
|
||||||
|
|
||||||
|
//The actual page content information is stored in this field, and then
|
||||||
|
//interpreted using the preprocessor
|
||||||
|
FieldVTwo pageContentUnitField = new FieldVTwo().setName("pageContentUnit");
|
||||||
|
conf.addField(pageContentUnitField);
|
||||||
|
|
||||||
|
//For existing values, will need to include fields here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -152,7 +160,7 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//For the case of an existing page
|
//For the case of an existing page
|
||||||
//Page title pageTitle or page hasDataGetter dataGetter
|
//Page title pageName or page hasDataGetter dataGetter
|
||||||
editConfiguration.setUrlPatternToReturnTo("/individual");
|
editConfiguration.setUrlPatternToReturnTo("/individual");
|
||||||
editConfiguration.setEntityToReturnTo(subjectUri);
|
editConfiguration.setEntityToReturnTo(subjectUri);
|
||||||
}
|
}
|
||||||
|
@ -182,8 +190,8 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
||||||
//In the case where this is a new page, need to ensure page gets a new
|
//In the case where this is a new page, need to ensure page gets a new
|
||||||
private void setNewResources(EditConfigurationVTwo conf) {
|
private void setNewResources(EditConfigurationVTwo conf) {
|
||||||
//null makes default namespace be triggered
|
//null makes default namespace be triggered
|
||||||
conf.addNewResource("page", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("page", defaultDisplayNs);
|
||||||
conf.addNewResource("menuItem", DEFAULT_NS_FOR_NEW_RESOURCE);
|
conf.addNewResource("menuItem", defaultDisplayNs);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +263,7 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
||||||
data.put("menuAction", "Add");
|
data.put("menuAction", "Add");
|
||||||
//Generate empty values for fields
|
//Generate empty values for fields
|
||||||
data.put("menuItem", "");
|
data.put("menuItem", "");
|
||||||
data.put("menuName", "");
|
data.put("pageName", "");
|
||||||
data.put("prettyUrl", "");
|
data.put("prettyUrl", "");
|
||||||
data.put("associatedPage", "");
|
data.put("associatedPage", "");
|
||||||
data.put("associatedPageURI", "");
|
data.put("associatedPageURI", "");
|
||||||
|
@ -275,15 +283,15 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
||||||
"@prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#> . \n";
|
"@prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#> . \n";
|
||||||
|
|
||||||
final static String pageN3 = "?page a display:Page ; \n" +
|
final static String pageN3 = "?page a display:Page ; \n" +
|
||||||
"display:title ?pageTitle ;\n" +
|
"display:title ?pageName ;\n" +
|
||||||
"display:urlMapping ?urlMapping .";
|
"display:urlMapping ?prettyUrl .";
|
||||||
|
|
||||||
//"display:hasDataGetter ?pageDataGetter .";
|
//"display:hasDataGetter ?pageDataGetter .";
|
||||||
|
|
||||||
//A page may also require a body template so we can get that here as well
|
//A page may also require a body template so we can get that here as well
|
||||||
//That would be optional
|
//That would be optional
|
||||||
|
|
||||||
final static String pageBodyTemplateN3 = "?page display:requiresBodyTemplate ?bodyTemplate .";
|
final static String pageBodyTemplateN3 = "?page display:requiresBodyTemplate ?customTemplate .";
|
||||||
|
|
||||||
//Menu position is added dynamically at end by default and can be changed on reordering page
|
//Menu position is added dynamically at end by default and can be changed on reordering page
|
||||||
final static String menuItemN3 = "?menuItem a display:NavigationElement ; \n" +
|
final static String menuItemN3 = "?menuItem a display:NavigationElement ; \n" +
|
||||||
|
@ -297,8 +305,8 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
||||||
final static String menuN3 = "display:DefaultMenu display:hasElement ?menuItem .";
|
final static String menuN3 = "display:DefaultMenu display:hasElement ?menuItem .";
|
||||||
|
|
||||||
//These are public static methods that can be used in the preprocessor
|
//These are public static methods that can be used in the preprocessor
|
||||||
public final static String getDataGetterN3(int numberDataGetter) {
|
public final static String getDataGetterN3(String dataGetterVar) {
|
||||||
return prefixes + "?page display:hasDataGetter ?dataGetter" + numberDataGetter + ".";
|
return prefixes + "?page display:hasDataGetter " + dataGetterVar + ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -13,11 +15,14 @@ import org.apache.commons.logging.LogFactory;
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
import com.hp.hpl.jena.vocabulary.RDFS;
|
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||||
import com.hp.hpl.jena.vocabulary.XSD;
|
import com.hp.hpl.jena.vocabulary.XSD;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.BaseEditSubmissionPreprocessorVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.BaseEditSubmissionPreprocessorVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
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.EditConfigurationVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManagePageGenerator;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessDataGetterN3;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessDataGetterN3;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessDataGetterN3Utils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessDataGetterN3Utils;
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
|
@ -78,7 +83,7 @@ public class ManagePagePreprocessor extends
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for(JSONObject jsonObject:pageContentUnitsJSON) {
|
for(JSONObject jsonObject:pageContentUnitsJSON) {
|
||||||
String dataGetterClass = getDataGetterClass(jsonObject);
|
String dataGetterClass = getDataGetterClass(jsonObject);
|
||||||
ProcessDataGetterN3 pn = ProcessDataGetterN3Utils.getDataGetterProcessorN3(dataGetterClass, jsonObject);
|
ProcessDataGetterN3 pn = ProcessDataGetterN3Utils.getDataGetterProcessorN3(dataGetterClass);
|
||||||
//Add n3 required
|
//Add n3 required
|
||||||
addN3Required(pn, counter);
|
addN3Required(pn, counter);
|
||||||
//Add N3 Optional as well
|
//Add N3 Optional as well
|
||||||
|
@ -87,14 +92,23 @@ public class ManagePagePreprocessor extends
|
||||||
addLiteralsAndUrisOnForm(pn, counter);
|
addLiteralsAndUrisOnForm(pn, counter);
|
||||||
// Add fields
|
// Add fields
|
||||||
addFields(pn, counter);
|
addFields(pn, counter);
|
||||||
|
//Add new resources - data getters need to be new resources
|
||||||
|
addNewResources(pn, counter);
|
||||||
//Add input values to submission
|
//Add input values to submission
|
||||||
addInputsToSubmission(pn, counter, jsonObject);
|
addInputsToSubmission(pn, counter, jsonObject);
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void addNewResources(ProcessDataGetterN3 pn, int counter) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
List<String> newResources = pn.getNewResources(counter);
|
||||||
|
for(String newResource:newResources) {
|
||||||
|
editConfiguration.addNewResource(newResource, ManagePageGenerator.defaultDisplayNs);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void convertToJson() {
|
private void convertToJson() {
|
||||||
|
@ -193,13 +207,29 @@ public class ManagePagePreprocessor extends
|
||||||
//This will overwrite the original with the set of new n3 required
|
//This will overwrite the original with the set of new n3 required
|
||||||
private void addN3Required(ProcessDataGetterN3 pn, int counter) {
|
private void addN3Required(ProcessDataGetterN3 pn, int counter) {
|
||||||
//Use the process utils to figure out what class required to retrieve the N3 required
|
//Use the process utils to figure out what class required to retrieve the N3 required
|
||||||
editConfiguration.addN3Required(pn.retrieveN3Required(counter));
|
List<String> requiredList = pn.retrieveN3Required(counter);
|
||||||
|
//Add connection between data getter and page
|
||||||
|
requiredList.addAll(getPageToDataGetterN3(pn, counter));
|
||||||
|
if(requiredList != null) {
|
||||||
|
editConfiguration.addN3Required(requiredList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private List<String> getPageToDataGetterN3(
|
||||||
|
ProcessDataGetterN3 pn, int counter) {
|
||||||
|
String dataGetterVar = pn.getDataGetterVar(counter);
|
||||||
|
//Put this method in the generator but can be put elsewhere
|
||||||
|
String pageToDataGetterN3 = ManagePageGenerator.getDataGetterN3(dataGetterVar);
|
||||||
|
return Arrays.asList(pageToDataGetterN3);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add n3 optional
|
//Add n3 optional
|
||||||
|
|
||||||
private void addN3Optional(ProcessDataGetterN3 pn, int counter) {
|
private void addN3Optional(ProcessDataGetterN3 pn, int counter) {
|
||||||
editConfiguration.addN3Optional(pn.retrieveN3Optional(counter));
|
List<String> optionalList = pn.retrieveN3Optional(counter);
|
||||||
|
if(optionalList != null) {
|
||||||
|
editConfiguration.addN3Optional(optionalList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] convertDelimitedStringToArray(String inputString) {
|
private String[] convertDelimitedStringToArray(String inputString) {
|
||||||
|
@ -224,11 +254,21 @@ public class ManagePagePreprocessor extends
|
||||||
|
|
||||||
//Each JSON Object will indicate the type of the data getter within it
|
//Each JSON Object will indicate the type of the data getter within it
|
||||||
private String getDataGetterClass(JSONObject jsonObject) {
|
private String getDataGetterClass(JSONObject jsonObject) {
|
||||||
return jsonObject.getString("dataGetterClass");
|
String javaURI = jsonObject.getString("dataGetterClass");
|
||||||
|
return getQualifiedDataGetterName(javaURI);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Get rid of java: in front of class name
|
||||||
|
private String getQualifiedDataGetterName(String dataGetterTypeURI) {
|
||||||
|
String javaURI = "java:";
|
||||||
|
|
||||||
|
if(dataGetterTypeURI.startsWith(javaURI)) {
|
||||||
|
int beginIndex = javaURI.length();
|
||||||
|
return dataGetterTypeURI.substring(beginIndex);
|
||||||
|
}
|
||||||
|
return dataGetterTypeURI;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,5 +20,7 @@ public interface ProcessDataGetterN3 {
|
||||||
public List<String> getLiteralVarNamesBase();
|
public List<String> getLiteralVarNamesBase();
|
||||||
public List<String> getUriVarNamesBase();
|
public List<String> getUriVarNamesBase();
|
||||||
public String getVarName(String base, int counter);
|
public String getVarName(String base, int counter);
|
||||||
|
public String getDataGetterVar(int counter);
|
||||||
|
public List<String> getNewResources(int counter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,13 +32,15 @@ public class ProcessDataGetterN3Utils {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProcessDataGetterN3 getDataGetterProcessorN3(String dataGetterClass, JSONObject jsonObject) {
|
public static ProcessDataGetterN3 getDataGetterProcessorN3(String dataGetterClass) {
|
||||||
HashMap<String, String> map = getDataGetterTypeToProcessorMap();
|
HashMap<String, String> map = getDataGetterTypeToProcessorMap();
|
||||||
|
//
|
||||||
if(map.containsKey(dataGetterClass)) {
|
if(map.containsKey(dataGetterClass)) {
|
||||||
String processorClass = map.get(dataGetterClass);
|
String processorClass = map.get(dataGetterClass);
|
||||||
try {
|
try {
|
||||||
Class<?> clz = Class.forName(processorClass);
|
Class<?> clz = Class.forName(processorClass);
|
||||||
ProcessDataGetterN3 pn = (ProcessDataGetterN3) clz.getConstructor(JSONObject.class).newInstance(jsonObject);
|
//Don't actually need to pass in json object since that includes the actual submission values
|
||||||
|
ProcessDataGetterN3 pn = (ProcessDataGetterN3) clz.getConstructor().newInstance();
|
||||||
return pn;
|
return pn;
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
log.error("Exception occurred in trying to get processor class for n3 for " + dataGetterClass, ex);
|
log.error("Exception occurred in trying to get processor class for n3 for " + dataGetterClass, ex);
|
||||||
|
|
|
@ -15,31 +15,33 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
import net.sf.json.JSONSerializer;
|
import net.sf.json.JSONSerializer;
|
||||||
//Returns the appropriate n3 based on data getter
|
//Returns the appropriate n3 based on data getter
|
||||||
public class ProcessSparqlDataGetterN3 implements ProcessDataGetterN3 {
|
public class ProcessSparqlDataGetterN3 implements ProcessDataGetterN3 {
|
||||||
private static String classType = "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter";
|
private static String classType = "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter";
|
||||||
private JSONObject jsonObject = null;
|
|
||||||
|
|
||||||
public ProcessSparqlDataGetterN3(JSONObject inputJsonObject) {
|
public ProcessSparqlDataGetterN3(){
|
||||||
jsonObject = inputJsonObject;
|
|
||||||
}
|
}
|
||||||
//Pass in variable that represents the counter
|
//Pass in variable that represents the counter
|
||||||
|
|
||||||
//TODO: ensure correct model returned
|
//TODO: ensure correct model returned
|
||||||
|
//We shouldn't use the ACTUAL values here but generate the n3 required
|
||||||
public List<String> retrieveN3Required(int counter) {
|
public List<String> retrieveN3Required(int counter) {
|
||||||
String dataGetterVar = getDataGetterVar(counter);
|
String dataGetterVar = getDataGetterVar(counter);
|
||||||
String n3 = dataGetterVar + " a <" + classType + ">; \n" +
|
String n3 = dataGetterVar + " a <" + classType + ">; \n" +
|
||||||
"display:queryModel <" + jsonObject.getString("queryModel") + ">; \n" +
|
"display:queryModel " + getN3VarName("queryModel", counter) + "; \n" +
|
||||||
"display:saveToVar '" + jsonObject.getString("saveToVar") + "'; \n" +
|
"display:saveToVar " + getN3VarName("saveToVar", counter) + "; \n" +
|
||||||
"display:query \"\"\"" + jsonObject.getString("query") + "\"\"\" .";
|
"display:query " + getN3VarName("query", counter) + " .";
|
||||||
return Arrays.asList(getPrefixes() + n3);
|
List<String> requiredList = new ArrayList<String>();
|
||||||
|
requiredList.add(getPrefixes() + n3);
|
||||||
|
return requiredList;
|
||||||
|
|
||||||
}
|
}
|
||||||
public List<String> retrieveN3Optional(int counter) {
|
public List<String> retrieveN3Optional(int counter) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
//placeholder so need "?" in front of the variable
|
||||||
private String getDataGetterVar(int counter) {
|
public String getDataGetterVar(int counter) {
|
||||||
return "dataGetter" + counter;
|
return "?dataGetter" + counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPrefixes() {
|
private String getPrefixes() {
|
||||||
|
@ -85,7 +87,8 @@ public class ProcessSparqlDataGetterN3 implements ProcessDataGetterN3 {
|
||||||
for(String varName: allFieldsBase) {
|
for(String varName: allFieldsBase) {
|
||||||
fields.add(new FieldVTwo().setName(getVarName(varName, counter)));
|
fields.add(new FieldVTwo().setName(getVarName(varName, counter)));
|
||||||
} */
|
} */
|
||||||
|
//For existing data getters
|
||||||
|
//fields.add(new FieldVTwo().setName(getVarName("dataGetter", counter)));
|
||||||
fields.add(new FieldVTwo().setName(getVarName("queryModel", counter)));
|
fields.add(new FieldVTwo().setName(getVarName("queryModel", counter)));
|
||||||
fields.add(new FieldVTwo().setName(getVarName("saveToVar", counter)));
|
fields.add(new FieldVTwo().setName(getVarName("saveToVar", counter)));
|
||||||
fields.add(new FieldVTwo().setName(getVarName("query", counter)));
|
fields.add(new FieldVTwo().setName(getVarName("query", counter)));
|
||||||
|
@ -94,9 +97,10 @@ public class ProcessSparqlDataGetterN3 implements ProcessDataGetterN3 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getLiteralVarNamesBase() {
|
public List<String> getLiteralVarNamesBase() {
|
||||||
return Arrays.asList("savetoVar", "query");
|
return Arrays.asList("saveToVar", "query");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//these are for the fields ON the form
|
||||||
public List<String> getUriVarNamesBase() {
|
public List<String> getUriVarNamesBase() {
|
||||||
return Arrays.asList("queryModel");
|
return Arrays.asList("queryModel");
|
||||||
}
|
}
|
||||||
|
@ -105,6 +109,18 @@ public class ProcessSparqlDataGetterN3 implements ProcessDataGetterN3 {
|
||||||
return base + counter;
|
return base + counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//For use within n3 strings, need a "?"
|
||||||
|
public String getN3VarName(String base, int counter) {
|
||||||
|
return "?" + getVarName(base, counter);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Return name of new resources
|
||||||
|
public List<String> getNewResources(int counter) {
|
||||||
|
//Each data getter requires a new resource
|
||||||
|
List<String> newResources = new ArrayList<String>();
|
||||||
|
newResources.add("dataGetter" + counter);
|
||||||
|
return newResources;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ var pageManagementUtils = {
|
||||||
if (validationError == "") {
|
if (validationError == "") {
|
||||||
//Create the appropriate json objects
|
//Create the appropriate json objects
|
||||||
pageManagementUtils.createPageContentForSubmission();
|
pageManagementUtils.createPageContentForSubmission();
|
||||||
$(this).submit();
|
return true;
|
||||||
} else{
|
} else{
|
||||||
$('#error-alert').removeClass('hidden');
|
$('#error-alert').removeClass('hidden');
|
||||||
$('#error-alert p').html(validationError);
|
$('#error-alert p').html(validationError);
|
||||||
|
@ -433,7 +433,7 @@ var pageManagementUtils = {
|
||||||
var validationError = "";
|
var validationError = "";
|
||||||
|
|
||||||
// Check menu name
|
// Check menu name
|
||||||
if ($('input[type=text][name=menuName]').val() == "") {
|
if ($('input[type=text][name=pageName]').val() == "") {
|
||||||
validationError += "You must supply a name<br />";
|
validationError += "You must supply a name<br />";
|
||||||
}
|
}
|
||||||
// Check pretty url
|
// Check pretty url
|
||||||
|
|
|
@ -4,14 +4,12 @@
|
||||||
<#assign menuAction = pageData.menuAction />
|
<#assign menuAction = pageData.menuAction />
|
||||||
<#assign classGroup = pageData.classGroup />
|
<#assign classGroup = pageData.classGroup />
|
||||||
<#assign classGroups = pageData.classGroups />
|
<#assign classGroups = pageData.classGroups />
|
||||||
|
<#assign pageName = "" />
|
||||||
<#assign selectedTemplateType = "default" />
|
<#assign selectedTemplateType = "default" />
|
||||||
<#assign menuItem = ""/>
|
|
||||||
<#assign menuName = ""/>
|
|
||||||
<#assign prettyUrl = ""/>
|
<#assign prettyUrl = ""/>
|
||||||
<#assign associatedPage = ""/>
|
<#assign associatedPage = ""/>
|
||||||
<#assign associatedPageURI = ""/>
|
<#assign associatedPageURI = ""/>
|
||||||
|
<#assign menuItem = ""/>
|
||||||
<#assign isClassGroupPage = false/>
|
<#assign isClassGroupPage = false/>
|
||||||
<#assign includeAllClasses = false/>
|
<#assign includeAllClasses = false/>
|
||||||
|
|
||||||
|
@ -32,10 +30,10 @@
|
||||||
<#--class group section has associated page uri, but that depends on editing a current page or if one is selected later-->
|
<#--class group section has associated page uri, but that depends on editing a current page or if one is selected later-->
|
||||||
<section id="pageDetails">
|
<section id="pageDetails">
|
||||||
<#--form method="POST" action="${formUrls}" role="${menuAction} menu item"-->
|
<#--form method="POST" action="${formUrls}" role="${menuAction} menu item"-->
|
||||||
<form method="POST" action="/editRequestDispatch" role="add page">
|
<form method="POST" action="${submitUrl}" role="add page">
|
||||||
<input type="hidden" name="switchToDisplayModel" id="switchToDisplayModel" value="1" role="input" />
|
<input type="hidden" name="switchToDisplayModel" id="switchToDisplayModel" value="1" role="input" />
|
||||||
<input type="hidden" id="editKey" name="editKey" value="${editKey}" />
|
<input type="hidden" id="editKey" name="editKey" value="${editKey}" />
|
||||||
|
<input type="hidden" id="menuItem" name="menuItem" value="${menuItem}"/>
|
||||||
<h2>Add Page</h2>
|
<h2>Add Page</h2>
|
||||||
<section id="floatRight" style="margin-top:0px;float:right;background-color:#fff;width:580px;margin-right:-4px">
|
<section id="floatRight" style="margin-top:0px;float:right;background-color:#fff;width:580px;margin-right:-4px">
|
||||||
<div id="rightSide">
|
<div id="rightSide">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue