page management related updates
This commit is contained in:
parent
7da1f47b62
commit
f327e91a3c
12 changed files with 266 additions and 80 deletions
|
@ -138,4 +138,26 @@ public class FieldVTwo {
|
|||
public String toString(){
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
|
||||
}
|
||||
|
||||
//Check that two fields are the same
|
||||
//Not sure how to compare EditElement and FieldOptions
|
||||
public boolean isEqualTo(FieldVTwo inputField) {
|
||||
//Name required
|
||||
boolean nameEqual = this.name.equals(inputField.getName());
|
||||
//Validators initialized so can check
|
||||
boolean validatorsEqual = this.validators.equals(inputField.getValidators());
|
||||
//other fields optional and may be null
|
||||
boolean rangeDatatypeEqual = ((this.rangeDatatypeUri == null && inputField.getRangeDatatypeUri() == null) ||
|
||||
(this.rangeDatatypeUri != null && inputField.getRangeDatatypeUri() != null
|
||||
&& this.rangeDatatypeUri.equals(inputField.getRangeDatatypeUri())));
|
||||
boolean rangeLangEqual = ((this.rangeLang == null && inputField.getRangeLang() == null) ||
|
||||
(this.rangeLang != null && inputField.getRangeLang() != null
|
||||
&& this.rangeLang.equals(inputField.getRangeLang())));
|
||||
|
||||
return (nameEqual &&
|
||||
validatorsEqual &&
|
||||
rangeDatatypeEqual &&
|
||||
rangeLangEqual);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,19 +4,19 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocess
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
import net.sf.json.JSONSerializer;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||
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.EditConfigurationUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||
|
@ -26,11 +26,6 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfigu
|
|||
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.ProcessDataGetterN3Utils;
|
||||
import net.sf.json.JSON;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
import net.sf.json.JSONSerializer;
|
||||
import net.sf.json.util.JSONUtils;
|
||||
public class ManagePagePreprocessor extends
|
||||
BaseEditSubmissionPreprocessorVTwo {
|
||||
|
||||
|
@ -103,6 +98,7 @@ public class ManagePagePreprocessor extends
|
|||
|
||||
//if submission already has value for this, then leave be
|
||||
//otherwise replace with blank value sentinel
|
||||
boolean haslv = submission.hasLiteralValue(literalName);
|
||||
if(!submission.hasLiteralValue(literalName)) {
|
||||
submission.addLiteralToForm(editConfiguration,
|
||||
editConfiguration.getField(literalName),
|
||||
|
@ -114,9 +110,9 @@ public class ManagePagePreprocessor extends
|
|||
for(String uriName: uriKeys) {
|
||||
//these values should never be overwritten or deleted
|
||||
if(uriName != "page" && uriName != "menuItem" && !uriName.startsWith("dataGetter")) {
|
||||
boolean hasuv = submission.hasUriValue(uriName);
|
||||
if(!submission.hasUriValue(uriName)) {
|
||||
submission.addLiteralToForm(editConfiguration,
|
||||
editConfiguration.getField(uriName),
|
||||
submission.addUriToForm(editConfiguration,
|
||||
uriName,
|
||||
(new String[] {EditConfigurationConstants.BLANK_SENTINEL}));
|
||||
}
|
||||
|
@ -133,8 +129,11 @@ public class ManagePagePreprocessor extends
|
|||
for(JSONObject jsonObject:pageContentUnitsJSON) {
|
||||
String dataGetterClass = getDataGetterClass(jsonObject);
|
||||
ProcessDataGetterN3 pn = ProcessDataGetterN3Utils.getDataGetterProcessorN3(dataGetterClass, jsonObject);
|
||||
//Removing n3 required b/c retracts in edit case depend on both n3 required and n3 optional
|
||||
//To not muddle up logic, we will just add ALL required and optional statements
|
||||
//from data getters directly to N3 optional
|
||||
//Add n3 required
|
||||
addN3Required(pn, counter);
|
||||
//addN3Required(pn, counter);
|
||||
//Add N3 Optional as well
|
||||
addN3Optional(pn, counter);
|
||||
// Add URIs on Form and Add Literals On Form
|
||||
|
@ -273,7 +272,22 @@ public class ManagePagePreprocessor extends
|
|||
|
||||
private void addFields(ProcessDataGetterN3 pn, int counter) {
|
||||
List<FieldVTwo> fields = pn.retrieveFields(counter);
|
||||
editConfiguration.addFields(fields);
|
||||
//Check if fields don't already exist in case of editing
|
||||
Map<String, FieldVTwo> existingFields = editConfiguration.getFields();
|
||||
for(FieldVTwo newField: fields) {
|
||||
String newFieldName = newField.getName();
|
||||
//if not already in list and about the same
|
||||
if(existingFields.containsKey(newFieldName)) {
|
||||
FieldVTwo existingField = existingFields.get(newFieldName);
|
||||
if(existingField.isEqualTo(newField)) {
|
||||
log.debug("This field already exists and so will not be added:" + newFieldName);
|
||||
} else {
|
||||
log.error("The field with the same name is different and will not be added as a different field exists which is different:" + newFieldName);
|
||||
}
|
||||
} else {
|
||||
editConfiguration.addField(newField);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -291,7 +305,9 @@ public class ManagePagePreprocessor extends
|
|||
/*
|
||||
* ?subject ?predicate ?conceptNode .
|
||||
*/
|
||||
//NOT Using this right now
|
||||
//This will overwrite the original with the set of new n3 required
|
||||
/*
|
||||
private void addN3Required(ProcessDataGetterN3 pn, int counter) {
|
||||
//Use the process utils to figure out what class required to retrieve the N3 required
|
||||
List<String> requiredList = pn.retrieveN3Required(counter);
|
||||
|
@ -300,7 +316,7 @@ public class ManagePagePreprocessor extends
|
|||
if(requiredList != null) {
|
||||
editConfiguration.addN3Required(requiredList);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
private List<String> getPageToDataGetterN3(
|
||||
ProcessDataGetterN3 pn, int counter) {
|
||||
String dataGetterVar = pn.getDataGetterVar(counter);
|
||||
|
@ -313,32 +329,26 @@ public class ManagePagePreprocessor extends
|
|||
//Add n3 optional
|
||||
|
||||
private void addN3Optional(ProcessDataGetterN3 pn, int counter) {
|
||||
List<String> addList = new ArrayList<String>();
|
||||
//Get required list
|
||||
List<String> requiredList = pn.retrieveN3Required(counter);
|
||||
//Add connection between data getter and page
|
||||
requiredList.addAll(getPageToDataGetterN3(pn, counter));
|
||||
//get optional n3
|
||||
List<String> optionalList = pn.retrieveN3Optional(counter);
|
||||
if(requiredList != null) {
|
||||
addList.addAll(requiredList);
|
||||
}
|
||||
|
||||
if(optionalList != null) {
|
||||
editConfiguration.addN3Optional(optionalList);
|
||||
}
|
||||
addList.addAll(optionalList);
|
||||
}
|
||||
|
||||
private String[] convertDelimitedStringToArray(String inputString) {
|
||||
String[] inputArray = new String[1];
|
||||
if (inputString.indexOf(",") != -1) {
|
||||
inputArray = inputString.split(",");
|
||||
} else {
|
||||
inputArray[0] = inputString;
|
||||
}
|
||||
return inputArray;
|
||||
editConfiguration.addN3Optional(addList);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private Object getFirstElement(List inputList) {
|
||||
if(inputList == null || inputList.size() == 0)
|
||||
return null;
|
||||
return inputList.get(0);
|
||||
}
|
||||
|
||||
//Each JSON Object will indicate the type of the data getter within it
|
||||
private String getDataGetterClass(JSONObject jsonObject) {
|
||||
String javaURI = jsonObject.getString("dataGetterClass");
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.hp.hpl.jena.query.QueryFactory;
|
|||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||
|
@ -28,7 +29,7 @@ import net.sf.json.JSONSerializer;
|
|||
//Returns the appropriate n3 based on data getter
|
||||
public class ProcessClassGroupDataGetterN3 extends ProcessDataGetterAbstract {
|
||||
private static String classType = "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData";
|
||||
private static String classGroupVarBase = "classGroup";
|
||||
public static String classGroupVarBase = "classGroup";
|
||||
private Log log = LogFactory.getLog(ProcessClassGroupDataGetterN3.class);
|
||||
|
||||
public ProcessClassGroupDataGetterN3(){
|
||||
|
@ -106,10 +107,10 @@ public class ProcessClassGroupDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
//TODO: Update
|
||||
public void populateExistingValues(String dataGetterURI, int counter, OntModel queryModel) {
|
||||
//First, put dataGetterURI within scope as well
|
||||
existingUriValues.put(this.getDataGetterVar(counter), new ArrayList<String>(Arrays.asList(dataGetterURI)));
|
||||
this.populateExistingDataGetterURI(dataGetterURI, counter);
|
||||
//Sparql queries for values to be executed
|
||||
//And then placed in the correct place/literal or uri
|
||||
String querystr = getExistingValuesSparqlQuery(dataGetterURI);
|
||||
String querystr = getExistingValuesClassGroup(dataGetterURI);
|
||||
QueryExecution qe = null;
|
||||
try{
|
||||
Query query = QueryFactory.create(querystr);
|
||||
|
@ -117,11 +118,10 @@ public class ProcessClassGroupDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
ResultSet results = qe.execSelect();
|
||||
while( results.hasNext()){
|
||||
QuerySolution qs = results.nextSolution();
|
||||
Literal saveToVarLiteral = qs.getLiteral("saveToVar");
|
||||
Literal htmlValueLiteral = qs.getLiteral("htmlValue");
|
||||
Resource classGroupResource = qs.getResource("classGroup");
|
||||
//Put both literals in existing literals
|
||||
existingLiteralValues.put(this.getVarName("saveToVar", counter),
|
||||
new ArrayList<Literal>(Arrays.asList(saveToVarLiteral, htmlValueLiteral)));
|
||||
existingUriValues.put(this.getVarName(classGroupVarBase, counter),
|
||||
new ArrayList<String>(Arrays.asList(classGroupResource.getURI())));
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
|
||||
|
@ -132,17 +132,32 @@ public class ProcessClassGroupDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
|
||||
|
||||
//?dataGetter a FixedHTMLDataGetter ; display:saveToVar ?saveToVar; display:htmlValue ?htmlValue .
|
||||
protected String getExistingValuesSparqlQuery(String dataGetterURI) {
|
||||
String query = this.getSparqlPrefix() + "SELECT ?saveToVar ?htmlValue WHERE {" +
|
||||
"<" + dataGetterURI + "> display:saveToVar ?saveToVar . \n" +
|
||||
"<" + dataGetterURI + "> display:htmlValue ?htmlValue . \n" +
|
||||
protected String getExistingValuesClassGroup(String dataGetterURI) {
|
||||
String query = this.getSparqlPrefix() + "SELECT ?classGroup WHERE {" +
|
||||
"<" + dataGetterURI + "> <" + DisplayVocabulary.FOR_CLASSGROUP + "> ?classGroup . \n" +
|
||||
"}";
|
||||
return query;
|
||||
}
|
||||
|
||||
public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel) {
|
||||
JSONObject jo = new JSONObject();
|
||||
return jo;
|
||||
JSONObject jObject = new JSONObject();
|
||||
jObject.element("dataGetterClass", classType);
|
||||
String querystr = getExistingValuesClassGroup(dataGetterURI);
|
||||
QueryExecution qe = null;
|
||||
try{
|
||||
Query query = QueryFactory.create(querystr);
|
||||
qe = QueryExecutionFactory.create(query, queryModel);
|
||||
ResultSet results = qe.execSelect();
|
||||
while( results.hasNext()){
|
||||
QuerySolution qs = results.nextSolution();
|
||||
Resource classGroupResource = qs.getResource("classGroup");
|
||||
//Put both literals in existing literals
|
||||
jObject.element(classGroupVarBase, classGroupResource.getURI());
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
|
||||
}
|
||||
return jObject;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,15 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
|||
|
||||
import net.sf.json.JSONObject;
|
||||
import net.sf.json.JSONSerializer;
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.query.Query;
|
||||
import com.hp.hpl.jena.query.QueryExecution;
|
||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||
import com.hp.hpl.jena.query.QueryFactory;
|
||||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
|
||||
//Returns the appropriate n3 based on data getter
|
||||
public abstract class ProcessDataGetterAbstract implements ProcessDataGetterN3 {
|
||||
|
||||
|
@ -64,6 +73,14 @@ public abstract class ProcessDataGetterAbstract implements ProcessDataGetterN3 {
|
|||
return existingUriValues;
|
||||
}
|
||||
|
||||
//Data getter var needs to be included in uris in scope
|
||||
public void populateExistingDataGetterURI(String dataGetterURI, int counter) {
|
||||
existingUriValues.put(this.getVarName("dataGetter", counter), new ArrayList<String>(Arrays.asList(dataGetterURI)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ public class ProcessFixedHTMLN3 extends ProcessDataGetterAbstract {
|
|||
//Execute populate before retrieval
|
||||
public void populateExistingValues(String dataGetterURI, int counter, OntModel queryModel) {
|
||||
//First, put dataGetterURI within scope as well
|
||||
existingUriValues.put(this.getDataGetterVar(counter), new ArrayList<String>(Arrays.asList(dataGetterURI)));
|
||||
this.populateExistingDataGetterURI(dataGetterURI, counter);
|
||||
//Sparql queries for values to be executed
|
||||
//And then placed in the correct place/literal or uri
|
||||
String querystr = getExistingValuesSparqlQuery(dataGetterURI);
|
||||
|
|
|
@ -20,6 +20,7 @@ import com.hp.hpl.jena.query.QueryFactory;
|
|||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||
|
@ -150,23 +151,33 @@ public class ProcessIndividualsForClassesDataGetterN3 extends ProcessClassGroup
|
|||
|
||||
public void populateExistingValues(String dataGetterURI, int counter, OntModel queryModel) {
|
||||
//First, put dataGetterURI within scope as well
|
||||
existingUriValues.put(this.getDataGetterVar(counter), new ArrayList<String>(Arrays.asList(dataGetterURI)));
|
||||
this.populateExistingDataGetterURI(dataGetterURI, counter);
|
||||
//Sparql queries for values to be executed
|
||||
//And then placed in the correct place/literal or uri
|
||||
String querystr = getExistingValuesSparqlQuery(dataGetterURI);
|
||||
String querystr = getExistingValuesIndividualsForClasses(dataGetterURI);
|
||||
QueryExecution qe = null;
|
||||
try{
|
||||
Query query = QueryFactory.create(querystr);
|
||||
qe = QueryExecutionFactory.create(query, queryModel);
|
||||
ResultSet results = qe.execSelect();
|
||||
List<String> individualsForClasses = new ArrayList<String>();
|
||||
while( results.hasNext()){
|
||||
QuerySolution qs = results.nextSolution();
|
||||
Literal saveToVarLiteral = qs.getLiteral("saveToVar");
|
||||
Literal htmlValueLiteral = qs.getLiteral("htmlValue");
|
||||
Resource classGroupResource = qs.getResource("classGroup");
|
||||
String classGroupVarName = this.getVarName(classGroupVarBase, counter);
|
||||
if(!existingUriValues.containsKey(classGroupVarName)) {
|
||||
//Put both literals in existing literals
|
||||
existingLiteralValues.put(this.getVarName("saveToVar", counter),
|
||||
new ArrayList<Literal>(Arrays.asList(saveToVarLiteral, htmlValueLiteral)));
|
||||
existingUriValues.put(this.getVarName(classGroupVarBase, counter),
|
||||
new ArrayList<String>(Arrays.asList(classGroupResource.getURI())));
|
||||
}
|
||||
Resource individualForClassResource = qs.getResource("individualForClass");
|
||||
individualsForClasses.add(individualForClassResource.getURI());
|
||||
//Put both literals in existing literals
|
||||
|
||||
}
|
||||
|
||||
existingUriValues.put(this.getVarName(individualClassVarNameBase, counter),
|
||||
new ArrayList<String>(individualsForClasses));
|
||||
} catch(Exception ex) {
|
||||
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
|
||||
}
|
||||
|
@ -176,18 +187,45 @@ public class ProcessIndividualsForClassesDataGetterN3 extends ProcessClassGroup
|
|||
|
||||
|
||||
//?dataGetter a FixedHTMLDataGetter ; display:saveToVar ?saveToVar; display:htmlValue ?htmlValue .
|
||||
protected String getExistingValuesSparqlQuery(String dataGetterURI) {
|
||||
String query = this.getSparqlPrefix() + "SELECT ?saveToVar ?htmlValue WHERE {" +
|
||||
"<" + dataGetterURI + "> display:saveToVar ?saveToVar . \n" +
|
||||
"<" + dataGetterURI + "> display:htmlValue ?htmlValue . \n" +
|
||||
protected String getExistingValuesIndividualsForClasses(String dataGetterURI) {
|
||||
String query = this.getSparqlPrefix() + "SELECT ?classGroup ?individualForClass WHERE {" +
|
||||
"<" + dataGetterURI + "> <" + DisplayVocabulary.FOR_CLASSGROUP + "> ?classGroup . \n" +
|
||||
"<" + dataGetterURI + "> <" + DisplayVocabulary.GETINDIVIDUALS_FOR_CLASS + "> ?individualForClass . \n" +
|
||||
"}";
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel) {
|
||||
JSONObject jo = new JSONObject();
|
||||
return jo;
|
||||
JSONObject jObject = new JSONObject();
|
||||
jObject.element("dataGetterClass", classType);
|
||||
String querystr = getExistingValuesIndividualsForClasses(dataGetterURI);
|
||||
QueryExecution qe = null;
|
||||
try{
|
||||
Query query = QueryFactory.create(querystr);
|
||||
qe = QueryExecutionFactory.create(query, queryModel);
|
||||
ResultSet results = qe.execSelect();
|
||||
JSONArray individualsForClasses = new JSONArray();
|
||||
String classGroupURI = null;
|
||||
while( results.hasNext()){
|
||||
QuerySolution qs = results.nextSolution();
|
||||
if(classGroupURI == null) {
|
||||
Resource classGroupResource = qs.getResource("classGroup");
|
||||
classGroupURI = classGroupResource.getURI();
|
||||
}
|
||||
Resource individualForClassResource = qs.getResource("individualForClass");
|
||||
individualsForClasses.add(individualForClassResource.getURI());
|
||||
//Put both literals in existing literals
|
||||
|
||||
}
|
||||
|
||||
jObject.element("classGroup", classGroupURI);
|
||||
//this is a json array
|
||||
jObject.element("classesSelectedInClassGroup", individualsForClasses);
|
||||
} catch(Exception ex) {
|
||||
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
|
||||
}
|
||||
return jObject;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.hp.hpl.jena.query.QueryFactory;
|
|||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||
|
||||
|
@ -112,7 +113,7 @@ public class ProcessSparqlDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
|
||||
public void populateExistingValues(String dataGetterURI, int counter, OntModel queryModel) {
|
||||
//First, put dataGetterURI within scope as well
|
||||
existingUriValues.put(this.getDataGetterVar(counter), new ArrayList<String>(Arrays.asList(dataGetterURI)));
|
||||
this.populateExistingDataGetterURI(dataGetterURI, counter);
|
||||
//Sparql queries for values to be executed
|
||||
//And then placed in the correct place/literal or uri
|
||||
String querystr = getExistingValuesSparqlQuery(dataGetterURI);
|
||||
|
@ -124,10 +125,18 @@ public class ProcessSparqlDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
while( results.hasNext()){
|
||||
QuerySolution qs = results.nextSolution();
|
||||
Literal saveToVarLiteral = qs.getLiteral("saveToVar");
|
||||
Literal htmlValueLiteral = qs.getLiteral("htmlValue");
|
||||
//Put both literals in existing literals
|
||||
Literal queryLiteral = qs.getLiteral("query");
|
||||
Resource queryModelResource = qs.getResource("queryModel");
|
||||
existingLiteralValues.put(this.getVarName("saveToVar", counter),
|
||||
new ArrayList<Literal>(Arrays.asList(saveToVarLiteral, htmlValueLiteral)));
|
||||
new ArrayList<Literal>(Arrays.asList(saveToVarLiteral)));
|
||||
|
||||
existingLiteralValues.put(this.getVarName("query", counter),
|
||||
new ArrayList<Literal>(Arrays.asList(queryLiteral)));
|
||||
|
||||
existingUriValues.put(this.getVarName("queryModel", counter),
|
||||
new ArrayList<String>(Arrays.asList(queryModelResource.getURI())));
|
||||
|
||||
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
|
||||
|
@ -137,11 +146,14 @@ public class ProcessSparqlDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
}
|
||||
|
||||
|
||||
//?dataGetter a FixedHTMLDataGetter ; display:saveToVar ?saveToVar; display:htmlValue ?htmlValue .
|
||||
|
||||
//?dataGetter a SparqlDataGetter ; display:saveToVar ?saveToVar; display:queryModel ?queryModel;
|
||||
//display:query ?query ..
|
||||
protected String getExistingValuesSparqlQuery(String dataGetterURI) {
|
||||
String query = this.getSparqlPrefix() + "SELECT ?saveToVar ?htmlValue WHERE {" +
|
||||
"<" + dataGetterURI + "> display:saveToVar ?saveToVar . \n" +
|
||||
"<" + dataGetterURI + "> display:htmlValue ?htmlValue . \n" +
|
||||
String query = this.getSparqlPrefix() + "SELECT ?saveToVar ?query ?queryModel WHERE {" +
|
||||
"<" + dataGetterURI + "> display:query ?query . \n" +
|
||||
"OPTIONAL {<" + dataGetterURI + "> display:saveToVar ?saveToVar .} \n" +
|
||||
"OPTIONAL {<" + dataGetterURI + "> display:queryModel ?queryModel . }\n" +
|
||||
"}";
|
||||
return query;
|
||||
}
|
||||
|
@ -149,8 +161,33 @@ public class ProcessSparqlDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
|
||||
|
||||
public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel) {
|
||||
JSONObject jo = new JSONObject();
|
||||
return jo;
|
||||
JSONObject jObject = new JSONObject();
|
||||
jObject.element("dataGetterClass", classType);
|
||||
String querystr = getExistingValuesSparqlQuery(dataGetterURI);
|
||||
QueryExecution qe = null;
|
||||
try{
|
||||
Query query = QueryFactory.create(querystr);
|
||||
qe = QueryExecutionFactory.create(query, queryModel);
|
||||
ResultSet results = qe.execSelect();
|
||||
while( results.hasNext()){
|
||||
QuerySolution qs = results.nextSolution();
|
||||
Literal saveToVarLiteral = qs.getLiteral("saveToVar");
|
||||
Literal queryLiteral = qs.getLiteral("query");
|
||||
Resource queryModelResource = qs.getResource("queryModel");
|
||||
jObject.element("saveToVar", saveToVarLiteral.getString());
|
||||
jObject.element("query", queryLiteral.getString());
|
||||
if(queryModelResource != null) {
|
||||
jObject.element("queryModel", queryModelResource.getURI());
|
||||
} else {
|
||||
jObject.element("queryModel", "");
|
||||
|
||||
}
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
|
||||
}
|
||||
|
||||
return jObject;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,19 @@ var processClassGroupDataGetterContent = {
|
|||
//query model should also be an input, ensure class group URI is saved as URI and not string
|
||||
var returnObject = {classGroup:classGroup, dataGetterClass:this.dataGetterClass};
|
||||
return returnObject;
|
||||
},
|
||||
//For an existing set of content where form is already set, fill in the values
|
||||
populatePageContentSection:function(existingContentObject, pageContentSection) {
|
||||
var classGroupValue = existingContentObject["classGroup"];
|
||||
pageContentSection.find("select[name='selectClassGroup']").val(classGroupValue);
|
||||
},
|
||||
//For the label of the content section for editing, need to add additional value
|
||||
retrieveAdditionalLabelText:function(existingContentObject) {
|
||||
//Right now return empty but can hook this into a hashmap with labels and uris
|
||||
//set up in browse class group
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -19,6 +19,24 @@ var processIndividualsForClassesDataGetterContent = {
|
|||
});
|
||||
var returnObject = {classGroup:classGroup, classesSelectedInClassGroup:classesSelected, dataGetterClass:this.dataGetterClass};
|
||||
return returnObject;
|
||||
},
|
||||
//For an existing set of content where form is already set, fill in the values
|
||||
populatePageContentSection:function(existingContentObject, pageContentSection) {
|
||||
var classGroupValue = existingContentObject["classGroup"];
|
||||
var classesSelected = existingContenetObject["classesSelectedInClassGroup"];
|
||||
var numberSelected = classesSelected.length;
|
||||
var i;
|
||||
for(i = 0; i < numberSelected; i++) {
|
||||
var classSelected = classesSelected[i];
|
||||
pageContentSection.find("input[name='classInClassGroup'][value='" + classSelected + "']").attr("checked", "checked");
|
||||
}
|
||||
pageContentSection.find("select[name='selectClassGroup']").val(classGroupValue);
|
||||
},
|
||||
//For the label of the content section for editing, need to add additional value
|
||||
retrieveAdditionalLabelText:function(existingContentObject) {
|
||||
//Right now return empty but can hook this into a hashmap with labels and uris
|
||||
//set up in browse class group
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
|
@ -17,6 +17,21 @@ var processSparqlDataGetterContent = {
|
|||
//set query model to query model here - vitro:contentDisplayModel
|
||||
var returnObject = {saveToVar:variableValue, query:queryValue, dataGetterClass:this.dataGetterClass, queryModel:queryModel};
|
||||
return returnObject;
|
||||
},
|
||||
//For an existing set of content where form is already set, fill in the values
|
||||
populatePageContentSection:function(existingContentObject, pageContentSection) {
|
||||
var saveToVarValue = existingContentObject["saveToVar"];
|
||||
var queryValue = existingContentObject["query"];
|
||||
var queryModelValue = existingContentObject["queryModel"];
|
||||
//Now find and set value
|
||||
pageContentSection.find("input[name='saveToVar']").val(saveToVarValue);
|
||||
pageContentSection.find("textarea[name='query']").val(queryValue);
|
||||
pageContentSection.find("input[name='queryModel']").val(queryModelValue);
|
||||
},
|
||||
//For the label of the content section for editing, need to add additional value
|
||||
retrieveAdditionalLabelText:function(existingContentObject) {
|
||||
var saveToVarValue = existingContentObject["saveToVar"];
|
||||
return saveToVarValue;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
<#-- Scripts for class group browsing -->
|
||||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/menupage/processClassGroupDataGetterContent.js"></script>')}
|
||||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/menupage/processIndividualsForClassesDataGetterContent.js"></script>')}
|
||||
<#--Setting up script with class group URIs and labels for editing purposes-->
|
|
@ -16,7 +16,7 @@
|
|||
<#--Existing Values For Editing condition-->
|
||||
<#assign literalValues = editConfiguration.existingLiteralValues />
|
||||
<#assign uriValues = editConfiguration.existingUriValues />
|
||||
<#if menuAction == "Edit">
|
||||
<#if menuAction = "Edit">
|
||||
<#assign pageName = lvf.getFormFieldValue(editSubmission, editConfiguration, "pageName")/>
|
||||
<#assign prettyUrl = lvf.getFormFieldValue(editSubmission, editConfiguration, "prettyUrl")/>
|
||||
<#assign menuItem = lvf.getFormFieldValue(editSubmission, editConfiguration, "menuItem")/>
|
||||
|
@ -76,10 +76,10 @@
|
|||
<input type="text" name="prettyUrl" value="${prettyUrl!''}" role="input" />
|
||||
<p class="note">Must begin with a leading forward slash: / (e.g., /people)</p>
|
||||
<p style="margin-top:8px;margin-bottom:2px">Template<span class="requiredHint"> *</span></p>
|
||||
<input type="radio" class="default-template" name="selectedTemplate" value="default" <#if selectedTemplateType = "default">checked</#if> role="radio" />
|
||||
<input type="radio" class="default-template" name="selectedTemplate" value="default" <#if selectedTemplateType = "default">checked="checked"</#if> role="radio" />
|
||||
<label class="inline" for="default"> Default</label>
|
||||
<br />
|
||||
<input type="radio" name="selectedTemplate" class="custom-template" value="custom" <#if selectedTemplateType = "custom">checked</#if> role="input" />
|
||||
<input type="radio" name="selectedTemplate" class="custom-template" value="custom" <#if selectedTemplateType = "custom">checked="checked"</#if> role="input" />
|
||||
<label class="inline" for="custom"> Custom template</label>
|
||||
<section id="custom-template" <#if selectedTemplateType != 'custom'>class="hidden" </#if>role="region">
|
||||
<input type="text" name="customTemplate" value="${customTemplate!''}" size="40" role="input" /><span class="requiredHint"> *</span>
|
||||
|
@ -87,6 +87,7 @@
|
|||
<p style="margin-top:10px;margin-bottom:0px"><input id="menuCheckbox" type="checkbox" name="menuCheckbox"> This is a menu page</p>
|
||||
<section id="menu" role="region" style="margin-top:10px">
|
||||
<label for="default">Menu Item Name</label>
|
||||
<input type="hidden" id="menuItem" name="menuItem" value="${menuItem!''}" />
|
||||
<input type="text" id="menuLinkText" name="menuLinkText" value="${menuLinkText!''}" size="28" role="input" />
|
||||
<input type="text" id="menuPosition" name="menuPosition" value="${menuPosition!''}" />
|
||||
<p class="note">If left blank, the page title will be used.</p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue