page management related updates
This commit is contained in:
parent
a103fdc486
commit
00338b05d9
2 changed files with 129 additions and 40 deletions
|
@ -8,6 +8,8 @@ var processInternalClassDataGetterContent = {
|
||||||
},
|
},
|
||||||
//Do we need a separate content type for each of the others?
|
//Do we need a separate content type for each of the others?
|
||||||
processPageContentSection:function(pageContentSection) {
|
processPageContentSection:function(pageContentSection) {
|
||||||
|
//get class group
|
||||||
|
var classGroup = pageContentSection.find("select[name='selectClassGroup']").val();
|
||||||
//Get classes selected
|
//Get classes selected
|
||||||
var classesSelected = [];
|
var classesSelected = [];
|
||||||
pageContentSection.find("input[name='classInClassGroup']:checked").each(function(){
|
pageContentSection.find("input[name='classInClassGroup']:checked").each(function(){
|
||||||
|
@ -15,16 +17,45 @@ var processInternalClassDataGetterContent = {
|
||||||
classesSelected.push($(this).val());
|
classesSelected.push($(this).val());
|
||||||
});
|
});
|
||||||
//If internal class selected, include here
|
//If internal class selected, include here
|
||||||
var isInternal=false;
|
var isInternal="false";
|
||||||
//if this checkbox is checked, then isInternal should be true
|
//if this checkbox is checked, then isInternal should be true
|
||||||
pageContentSection.find("input[name='display-internalClass']:checked").each(function() {
|
pageContentSection.find("input[name='display-internalClass']:checked").each(function() {
|
||||||
isInternal=true;
|
isInternal="true";
|
||||||
});
|
});
|
||||||
//Not returning class group although could if need be..
|
//JSON Object to be returned
|
||||||
var returnObject = { classesSelectedInClassGroup:classesSelected,
|
var returnObject = { classGroup: classGroup,
|
||||||
|
classesSelectedInClassGroup:classesSelected,
|
||||||
isInternal:isInternal,
|
isInternal:isInternal,
|
||||||
dataGetterClass:this.dataGetterClass};
|
dataGetterClass:this.dataGetterClass};
|
||||||
return returnObject;
|
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 = existingContentObject["classesSelectedInClassGroup"];
|
||||||
|
var isInternal = existingContentObject["isInternal"];
|
||||||
|
//Set class group
|
||||||
|
pageContentSection.find("select[name='selectClassGroup']").val(classGroupValue);
|
||||||
|
//Set classes selected within class group
|
||||||
|
//TODO: Add magic for "all" if all classes selected
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
//Also internal class needs to be selected
|
||||||
|
if(isInternal == "true") {
|
||||||
|
pageContentSection.find("input[name='display-internalClass']").attr("checked", "checked");
|
||||||
|
}
|
||||||
|
//Since this is populating content from the template, no need to "uncheck" anything
|
||||||
|
|
||||||
|
},
|
||||||
|
//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 "";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -20,6 +20,8 @@ import com.hp.hpl.jena.query.QueryFactory;
|
||||||
import com.hp.hpl.jena.query.QuerySolution;
|
import com.hp.hpl.jena.query.QuerySolution;
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
import com.hp.hpl.jena.rdf.model.Resource;
|
||||||
|
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||||
|
@ -39,16 +41,17 @@ public class ProcessInternalClassDataGetterN3 extends ProcessIndividualsForClas
|
||||||
|
|
||||||
}
|
}
|
||||||
//Pass in variable that represents the counter
|
//Pass in variable that represents the counter
|
||||||
|
//Saving both type and class group here
|
||||||
//Original menu managemenet didn't include the top level class group as type for internal classes
|
|
||||||
//That can be included here if need be, but for now just adding the type alone
|
//That can be included here if need be, but for now just adding the type alone
|
||||||
public List<String> retrieveN3Required(int counter) {
|
public List<String> retrieveN3Required(int counter) {
|
||||||
|
return super.retrieveN3Required(counter);
|
||||||
|
/*
|
||||||
List<String> requiredN3 = new ArrayList<String>();
|
List<String> requiredN3 = new ArrayList<String>();
|
||||||
String partialN3 = this.getN3ForTypePartial(counter) + ".";
|
String partialN3 = this.getN3ForTypePartial(counter) + ".";
|
||||||
requiredN3.add(getPrefixes() + partialN3);
|
requiredN3.add(getPrefixes() + partialN3);
|
||||||
requiredN3.addAll(this.addIndividualClassesN3(counter));
|
requiredN3.addAll(this.addIndividualClassesN3(counter));
|
||||||
return requiredN3;
|
return requiredN3;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,8 +84,7 @@ public class ProcessInternalClassDataGetterN3 extends ProcessIndividualsForClas
|
||||||
}
|
}
|
||||||
|
|
||||||
//URIs on form are same as individuals for class group so no need to reimplement
|
//URIs on form are same as individuals for class group so no need to reimplement
|
||||||
|
//i.e. class groups and individuals selected within class group
|
||||||
|
|
||||||
|
|
||||||
public List<FieldVTwo> retrieveFields(int counter) {
|
public List<FieldVTwo> retrieveFields(int counter) {
|
||||||
List<FieldVTwo> fields = super.retrieveFields(counter);
|
List<FieldVTwo> fields = super.retrieveFields(counter);
|
||||||
|
@ -97,46 +99,58 @@ public class ProcessInternalClassDataGetterN3 extends ProcessIndividualsForClas
|
||||||
return Arrays.asList(internalClassVarNameBase);
|
return Arrays.asList(internalClassVarNameBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
//these are for the fields ON the form
|
//get URI Var Names base is same as ProcessIndividualsForClassGroup: classGroup and individualClassVarNameBase
|
||||||
public List<String> getUriVarNamesBase() {
|
|
||||||
return Arrays.asList(individualClassVarNameBase);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getClassType() {
|
public String getClassType() {
|
||||||
return classType;
|
return classType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel) {
|
|
||||||
JSONObject jo = new JSONObject();
|
|
||||||
return jo;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Existing values
|
|
||||||
//TODO: Correct
|
|
||||||
//How to override methods in here and access elements required?
|
|
||||||
//Unclear?
|
|
||||||
/*
|
|
||||||
@Override
|
|
||||||
public void populateExistingValues(String dataGetterURI, int counter, OntModel queryModel) {
|
public void populateExistingValues(String dataGetterURI, int counter, OntModel queryModel) {
|
||||||
//First, put dataGetterURI within scope as well
|
//First, put dataGetterURI within scope as well
|
||||||
existingUriValues.put(this.getDataGetterVar(counter), new ArrayList<String>(Arrays.asList(dataGetterURI)));
|
//((ProcessDataGetterAbstract)this).populateExistingDataGetterURI(dataGetterURI, counter);
|
||||||
|
this.populateExistingDataGetterURI(dataGetterURI, counter);
|
||||||
//Sparql queries for values to be executed
|
//Sparql queries for values to be executed
|
||||||
//And then placed in the correct place/literal or uri
|
//And then placed in the correct place/literal or uri
|
||||||
String querystr = getExistingValuesSparqlQuery(dataGetterURI);
|
String querystr = getExistingValuesInternalClass(dataGetterURI);
|
||||||
QueryExecution qe = null;
|
QueryExecution qe = null;
|
||||||
|
Literal internalClassLiteral = null;
|
||||||
try{
|
try{
|
||||||
Query query = QueryFactory.create(querystr);
|
Query query = QueryFactory.create(querystr);
|
||||||
qe = QueryExecutionFactory.create(query, queryModel);
|
qe = QueryExecutionFactory.create(query, queryModel);
|
||||||
ResultSet results = qe.execSelect();
|
ResultSet results = qe.execSelect();
|
||||||
|
String classGroupURI = null;
|
||||||
|
List<String> individualsForClasses = new ArrayList<String>();
|
||||||
while( results.hasNext()){
|
while( results.hasNext()){
|
||||||
QuerySolution qs = results.nextSolution();
|
QuerySolution qs = results.nextSolution();
|
||||||
Literal saveToVarLiteral = qs.getLiteral("saveToVar");
|
//Class group
|
||||||
Literal htmlValueLiteral = qs.getLiteral("htmlValue");
|
Resource classGroupResource = qs.getResource("classGroup");
|
||||||
|
String classGroupVarName = this.getVarName(classGroupVarBase, counter);
|
||||||
|
if(classGroupURI == null) {
|
||||||
//Put both literals in existing literals
|
//Put both literals in existing literals
|
||||||
existingLiteralValues.put(this.getVarName("saveToVar", counter),
|
existingUriValues.put(this.getVarName(classGroupVarBase, counter),
|
||||||
new ArrayList<Literal>(Arrays.asList(saveToVarLiteral, htmlValueLiteral)));
|
new ArrayList<String>(Arrays.asList(classGroupResource.getURI())));
|
||||||
|
}
|
||||||
|
//Individuals For classes
|
||||||
|
Resource individualForClassResource = qs.getResource("individualForClass");
|
||||||
|
individualsForClasses.add(individualForClassResource.getURI());
|
||||||
|
//If internal class value is present and we have not already saved it in a previous result iteration
|
||||||
|
if(qs.get("internalClass") != null && internalClassLiteral == null) {
|
||||||
|
|
||||||
|
internalClassLiteral= qs.getLiteral("internalClass");
|
||||||
|
existingLiteralValues.put(this.getVarName("internalClass", counter),
|
||||||
|
new ArrayList<Literal>(Arrays.asList(internalClassLiteral)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Put array of individuals for classes within
|
||||||
|
existingUriValues.put(this.getVarName(individualClassVarNameBase, counter),
|
||||||
|
new ArrayList<String>(individualsForClasses));
|
||||||
|
//Final check, in case no internal class flag was returned, set to false
|
||||||
|
if(internalClassLiteral == null) {
|
||||||
|
existingLiteralValues.put(this.getVarName("internalClass", counter),
|
||||||
|
new ArrayList<Literal>(
|
||||||
|
Arrays.asList(ResourceFactory.createPlainLiteral("false"))
|
||||||
|
));
|
||||||
}
|
}
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
|
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
|
||||||
|
@ -147,16 +161,60 @@ public class ProcessInternalClassDataGetterN3 extends ProcessIndividualsForClas
|
||||||
|
|
||||||
|
|
||||||
//?dataGetter a FixedHTMLDataGetter ; display:saveToVar ?saveToVar; display:htmlValue ?htmlValue .
|
//?dataGetter a FixedHTMLDataGetter ; display:saveToVar ?saveToVar; display:htmlValue ?htmlValue .
|
||||||
@Override
|
protected String getExistingValuesInternalClass(String dataGetterURI) {
|
||||||
protected String getExistingValuesSparqlQuery(String dataGetterURI) {
|
String query = this.getSparqlPrefix() + "SELECT ?classGroup ?individualForClass ?internalClass WHERE {" +
|
||||||
String query = super.getSparqlPrefix() + "SELECT ?saveToVar ?htmlValue WHERE {" +
|
"<" + dataGetterURI + "> <" + DisplayVocabulary.FOR_CLASSGROUP + "> ?classGroup . \n" +
|
||||||
"<" + dataGetterURI + "> display:saveToVar ?saveToVar . \n" +
|
"<" + dataGetterURI + "> <" + DisplayVocabulary.GETINDIVIDUALS_FOR_CLASS + "> ?individualForClass . \n" +
|
||||||
"<" + dataGetterURI + "> display:htmlValue ?htmlValue . \n" +
|
"OPTIONAL {<" + dataGetterURI + "> <" + DisplayVocabulary.RESTRICT_RESULTS_BY_INTERNAL + "> ?internaClass .} \n" +
|
||||||
"}";
|
"}";
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
|
||||||
|
public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel) {
|
||||||
|
JSONObject jObject = new JSONObject();
|
||||||
|
jObject.element("dataGetterClass", classType);
|
||||||
|
String querystr = getExistingValuesInternalClass(dataGetterURI);
|
||||||
|
QueryExecution qe = null;
|
||||||
|
Literal internalClassLiteral = 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();
|
||||||
|
}
|
||||||
|
//individuals for classes
|
||||||
|
Resource individualForClassResource = qs.getResource("individualForClass");
|
||||||
|
individualsForClasses.add(individualForClassResource.getURI());
|
||||||
|
//Put both literals in existing literals
|
||||||
|
//If internal class value is present and we have not already saved it in a previous result iteration
|
||||||
|
if(qs.get("internalClass") != null && internalClassLiteral == null) {
|
||||||
|
internalClassLiteral= qs.getLiteral("internalClass");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
jObject.element("classGroup", classGroupURI);
|
||||||
|
//this is a json array
|
||||||
|
jObject.element("individualsForClasses", individualsForClasses);
|
||||||
|
//Internal class - if null then add false otherwise use the value
|
||||||
|
if(internalClassLiteral != null) {
|
||||||
|
jObject.element("internalClass", internalClassLiteral.getString());
|
||||||
|
} else {
|
||||||
|
jObject.element("internalClass", "false");
|
||||||
|
}
|
||||||
|
} catch(Exception ex) {
|
||||||
|
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
|
||||||
|
}
|
||||||
|
return jObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue