updates for page management, enabling changing class group content type to internal class/selected classes and vice versa
This commit is contained in:
parent
c83ff876c5
commit
2e07a5687c
7 changed files with 61 additions and 9 deletions
|
@ -133,6 +133,9 @@ public class ManagePagePreprocessor extends
|
|||
for(JSONObject jsonObject:pageContentUnitsJSON) {
|
||||
String dataGetterClass = getDataGetterClass(jsonObject);
|
||||
ProcessDataGetterN3 pn = ProcessDataGetterN3Utils.getDataGetterProcessorN3(dataGetterClass, jsonObject);
|
||||
//UPDATE: using class type to indicate class type/ could also get it from
|
||||
//processor but already have it here
|
||||
jsonObject.put("classType", pn.getClassType());
|
||||
//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
|
||||
|
|
|
@ -63,8 +63,12 @@ public class ProcessClassGroupDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
}
|
||||
|
||||
public String getN3ForTypePartial(int counter) {
|
||||
//UPDATE: including class type as
|
||||
String dataGetterVar = getDataGetterVar(counter);
|
||||
String n3 = dataGetterVar + " a <" + getClassType() + ">";
|
||||
String classTypeVar = getN3VarName(classTypeVarBase, counter);
|
||||
//String n3 = dataGetterVar + " a <" + getClassType() + ">";
|
||||
String n3 = dataGetterVar + " a " + classTypeVar;
|
||||
|
||||
return n3;
|
||||
}
|
||||
|
||||
|
@ -83,6 +87,8 @@ public class ProcessClassGroupDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
List<String> urisOnForm = new ArrayList<String>();
|
||||
//Class group is a URI
|
||||
urisOnForm.add(getVarName("classGroup", counter));
|
||||
//UPDATE: adding class type as uri on form
|
||||
urisOnForm.add(getVarName(classTypeVarBase, counter));
|
||||
return urisOnForm;
|
||||
|
||||
}
|
||||
|
@ -90,6 +96,9 @@ public class ProcessClassGroupDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
public List<FieldVTwo> retrieveFields(int counter) {
|
||||
List<FieldVTwo> fields = new ArrayList<FieldVTwo>();
|
||||
fields.add(new FieldVTwo().setName(getVarName("classGroup", counter)));
|
||||
//UPDATE: adding class type to the uris on the form
|
||||
fields.add(new FieldVTwo().setName(getVarName(classTypeVarBase, counter)));
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
|
@ -101,7 +110,8 @@ public class ProcessClassGroupDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
|
||||
//these are for the fields ON the form
|
||||
public List<String> getUriVarNamesBase() {
|
||||
return Arrays.asList("classGroup");
|
||||
//UPDATE: adding class type as uri
|
||||
return Arrays.asList("classGroup", classTypeVarBase);
|
||||
}
|
||||
|
||||
//This class can be extended so returning type here
|
||||
|
@ -114,6 +124,8 @@ public class ProcessClassGroupDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
public void populateExistingValues(String dataGetterURI, int counter, OntModel queryModel) {
|
||||
//First, put dataGetterURI within scope as well
|
||||
this.populateExistingDataGetterURI(dataGetterURI, counter);
|
||||
//Put in type
|
||||
this.populateExistingClassType(this.getClassType(), counter);
|
||||
//Sparql queries for values to be executed
|
||||
//And then placed in the correct place/literal or uri
|
||||
String querystr = getExistingValuesClassGroup(dataGetterURI);
|
||||
|
@ -148,6 +160,7 @@ public class ProcessClassGroupDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel, ServletContext context) {
|
||||
JSONObject jObject = new JSONObject();
|
||||
jObject.element("dataGetterClass", classType);
|
||||
jObject.element(classTypeVarBase, classType);
|
||||
//Get class group
|
||||
getExistingClassGroup(dataGetterURI, jObject, queryModel);
|
||||
//Get classes within class group
|
||||
|
|
|
@ -25,7 +25,7 @@ import com.hp.hpl.jena.rdf.model.Literal;
|
|||
|
||||
//Returns the appropriate n3 based on data getter
|
||||
public abstract class ProcessDataGetterAbstract implements ProcessDataGetterN3 {
|
||||
|
||||
public static String classTypeVarBase = "classType";
|
||||
public ProcessDataGetterAbstract(){
|
||||
|
||||
}
|
||||
|
@ -91,7 +91,11 @@ public abstract class ProcessDataGetterAbstract implements ProcessDataGetterN3 {
|
|||
|
||||
}
|
||||
|
||||
public void populateExistingClassType(String classType, int counter) {
|
||||
existingUriValues.put(this.getVarName(classTypeVarBase, counter), new ArrayList<String>(Arrays.asList(classType)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
|||
//Returns the appropriate n3 based on data getter
|
||||
|
||||
public interface ProcessDataGetterN3 {
|
||||
public String getClassType();
|
||||
public List<String> retrieveN3Required(int counter);
|
||||
public List<String> retrieveN3Optional(int counter);
|
||||
public List<String >retrieveLiteralsOnForm(int counter);
|
||||
|
|
|
@ -37,7 +37,9 @@ public class ProcessFixedHTMLN3 extends ProcessDataGetterAbstract {
|
|||
//?dataGetter a FixedHTMLDataGetter ; display:saveToVar ?saveToVar; display:htmlValue ?htmlValue .
|
||||
public List<String> retrieveN3Required(int counter) {
|
||||
String dataGetterVar = getDataGetterVar(counter);
|
||||
String n3 = dataGetterVar + " a <" + classType + ">; \n" +
|
||||
//UPDATE: Using variable for class type
|
||||
String classTypeVar = getN3VarName(classTypeVarBase, counter);
|
||||
String n3 = dataGetterVar + " a " + classTypeVar + "; \n" +
|
||||
"display:saveToVar " + getN3VarName("saveToVar", counter) + "; \n" +
|
||||
"display:htmlValue " + getN3VarName("htmlValue", counter) + " .";
|
||||
List<String> requiredList = new ArrayList<String>();
|
||||
|
@ -61,6 +63,8 @@ public class ProcessFixedHTMLN3 extends ProcessDataGetterAbstract {
|
|||
|
||||
public List<String> retrieveUrisOnForm(int counter) {
|
||||
List<String> urisOnForm = new ArrayList<String>();
|
||||
//UPDATE: adding class type as uri on form
|
||||
urisOnForm.add(getVarName(classTypeVarBase, counter));
|
||||
return urisOnForm;
|
||||
|
||||
}
|
||||
|
@ -71,7 +75,8 @@ public class ProcessFixedHTMLN3 extends ProcessDataGetterAbstract {
|
|||
//fields.add(new FieldVTwo().setName(getVarName("dataGetter", counter)));
|
||||
fields.add(new FieldVTwo().setName(getVarName("saveToVar", counter)));
|
||||
fields.add(new FieldVTwo().setName(getVarName("htmlValue", counter)));
|
||||
|
||||
//UPDATE: adding class type to the uris on the form
|
||||
fields.add(new FieldVTwo().setName(getVarName(classTypeVarBase, counter)));
|
||||
return fields;
|
||||
}
|
||||
|
||||
|
@ -81,7 +86,7 @@ public class ProcessFixedHTMLN3 extends ProcessDataGetterAbstract {
|
|||
|
||||
//these are for the fields ON the form
|
||||
public List<String> getUriVarNamesBase() {
|
||||
return Arrays.asList();
|
||||
return Arrays.asList(classTypeVarBase);
|
||||
}
|
||||
|
||||
//For Existing Values in case of editing
|
||||
|
@ -90,6 +95,8 @@ public class ProcessFixedHTMLN3 extends ProcessDataGetterAbstract {
|
|||
public void populateExistingValues(String dataGetterURI, int counter, OntModel queryModel) {
|
||||
//First, put dataGetterURI within scope as well
|
||||
this.populateExistingDataGetterURI(dataGetterURI, counter);
|
||||
//Put in type
|
||||
this.populateExistingClassType(this.getClassType(), counter);
|
||||
//Sparql queries for values to be executed
|
||||
//And then placed in the correct place/literal or uri
|
||||
String querystr = getExistingValuesSparqlQuery(dataGetterURI);
|
||||
|
@ -132,6 +139,7 @@ public class ProcessFixedHTMLN3 extends ProcessDataGetterAbstract {
|
|||
public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel, ServletContext context) {
|
||||
JSONObject jObject = new JSONObject();
|
||||
jObject.element("dataGetterClass", classType);
|
||||
jObject.element(classTypeVarBase, classType);
|
||||
String querystr = getExistingValuesSparqlQuery(dataGetterURI);
|
||||
QueryExecution qe = null;
|
||||
try{
|
||||
|
@ -161,6 +169,10 @@ public class ProcessFixedHTMLN3 extends ProcessDataGetterAbstract {
|
|||
|
||||
}
|
||||
|
||||
//This class can be extended so returning type here
|
||||
public String getClassType() {
|
||||
return classType;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ public class ProcessIndividualsForClassesDataGetterN3 extends ProcessClassGroup
|
|||
|
||||
//these are for the fields ON the form
|
||||
public List<String> getUriVarNamesBase() {
|
||||
return Arrays.asList("classGroup", individualClassVarNameBase);
|
||||
return Arrays.asList("classGroup", individualClassVarNameBase, classTypeVarBase);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -128,6 +128,8 @@ public class ProcessIndividualsForClassesDataGetterN3 extends ProcessClassGroup
|
|||
public void populateExistingValues(String dataGetterURI, int counter, OntModel queryModel) {
|
||||
//First, put dataGetterURI within scope as well
|
||||
this.populateExistingDataGetterURI(dataGetterURI, counter);
|
||||
//UPDATE: Put in type
|
||||
this.populateExistingClassType(this.getClassType(), counter);
|
||||
//Sparql queries for values to be executed
|
||||
//And then placed in the correct place/literal or uri
|
||||
String querystr = getExistingValuesIndividualsForClasses(dataGetterURI);
|
||||
|
@ -175,6 +177,8 @@ public class ProcessIndividualsForClassesDataGetterN3 extends ProcessClassGroup
|
|||
public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel, ServletContext context) {
|
||||
JSONObject jObject = new JSONObject();
|
||||
jObject.element("dataGetterClass", classType);
|
||||
//Update to include class type as variable
|
||||
jObject.element(classTypeVarBase, classType);
|
||||
//Get selected class group and which classes were selected
|
||||
getExistingClassGroupAndIndividuals(dataGetterURI, jObject, queryModel);
|
||||
//Get all classes within the class group
|
||||
|
|
|
@ -39,7 +39,10 @@ public class ProcessSparqlDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
//We shouldn't use the ACTUAL values here but generate the n3 required
|
||||
public List<String> retrieveN3Required(int counter) {
|
||||
String dataGetterVar = getDataGetterVar(counter);
|
||||
String n3 = dataGetterVar + " a <" + classType + ">; \n" +
|
||||
//UPDATE: Using variable for class type
|
||||
String classTypeVar = getN3VarName(classTypeVarBase, counter);
|
||||
|
||||
String n3 = dataGetterVar + " a " + classTypeVar + "; \n" +
|
||||
"display:saveToVar " + getN3VarName("saveToVar", counter) + "; \n" +
|
||||
"display:query " + getN3VarName("query", counter) + " .";
|
||||
List<String> requiredList = new ArrayList<String>();
|
||||
|
@ -70,6 +73,8 @@ public class ProcessSparqlDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
List<String> urisOnForm = new ArrayList<String>();
|
||||
//We have no uris as far as I know.. well query Model is a uri
|
||||
urisOnForm.add(getVarName("queryModel", counter));
|
||||
//UPDATE: adding class type as uri on form
|
||||
urisOnForm.add(getVarName(classTypeVarBase, counter));
|
||||
return urisOnForm;
|
||||
|
||||
}
|
||||
|
@ -82,6 +87,8 @@ public class ProcessSparqlDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
fields.add(new FieldVTwo().setName(getVarName("queryModel", counter)));
|
||||
fields.add(new FieldVTwo().setName(getVarName("saveToVar", counter)));
|
||||
fields.add(new FieldVTwo().setName(getVarName("query", counter)));
|
||||
//UPDATE: adding class type to the uris on the form
|
||||
fields.add(new FieldVTwo().setName(getVarName(classTypeVarBase, counter)));
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
@ -92,7 +99,7 @@ public class ProcessSparqlDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
|
||||
//these are for the fields ON the form
|
||||
public List<String> getUriVarNamesBase() {
|
||||
return Arrays.asList("queryModel");
|
||||
return Arrays.asList("queryModel", classTypeVarBase);
|
||||
}
|
||||
|
||||
//Existing values
|
||||
|
@ -101,6 +108,8 @@ public class ProcessSparqlDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
public void populateExistingValues(String dataGetterURI, int counter, OntModel queryModel) {
|
||||
//First, put dataGetterURI within scope as well
|
||||
this.populateExistingDataGetterURI(dataGetterURI, counter);
|
||||
//Put in type
|
||||
this.populateExistingClassType(this.getClassType(), counter);
|
||||
//Sparql queries for values to be executed
|
||||
//And then placed in the correct place/literal or uri
|
||||
String querystr = getExistingValuesSparqlQuery(dataGetterURI);
|
||||
|
@ -150,6 +159,7 @@ public class ProcessSparqlDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel, ServletContext context) {
|
||||
JSONObject jObject = new JSONObject();
|
||||
jObject.element("dataGetterClass", classType);
|
||||
jObject.element(classTypeVarBase, classType);
|
||||
String querystr = getExistingValuesSparqlQuery(dataGetterURI);
|
||||
QueryExecution qe = null;
|
||||
try{
|
||||
|
@ -189,6 +199,11 @@ public class ProcessSparqlDataGetterN3 extends ProcessDataGetterAbstract {
|
|||
return inputStr.replaceAll("\'", "'").replaceAll("\"", """);
|
||||
|
||||
}
|
||||
|
||||
//This class can be extended so returning type here
|
||||
public String getClassType() {
|
||||
return classType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue