updates for page management - code.
This commit is contained in:
parent
4a9f6a6f28
commit
3646a214a5
12 changed files with 450 additions and 177 deletions
|
@ -190,8 +190,10 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
|||
//In the case where this is a new page, need to ensure page gets a new
|
||||
private void setNewResources(EditConfigurationVTwo conf) {
|
||||
//null makes default namespace be triggered
|
||||
conf.addNewResource("page", defaultDisplayNs);
|
||||
conf.addNewResource("menuItem", defaultDisplayNs);
|
||||
//conf.addNewResource("page", defaultDisplayNs);
|
||||
//conf.addNewResource("menuItem", defaultDisplayNs);
|
||||
conf.addNewResource("page", null);
|
||||
conf.addNewResource("menuItem", null);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,13 @@ public class ManagePagePreprocessor extends
|
|||
// TODO Auto-generated method stub
|
||||
List<String> newResources = pn.getNewResources(counter);
|
||||
for(String newResource:newResources) {
|
||||
editConfiguration.addNewResource(newResource, ManagePageGenerator.defaultDisplayNs);
|
||||
//Will null get us display vocabulary or something else?
|
||||
|
||||
editConfiguration.addNewResource(newResource, null);
|
||||
//Weirdly enough, the defaultDisplayNS doesn't act as a namespace REALLY
|
||||
//as it first gets assigned as the URI itself and this lead to an error
|
||||
//instead of repetitively trying to get another URI
|
||||
//editConfiguration.addNewResource(newResource, ManagePageGenerator.defaultDisplayNs );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
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.ClassGroupDataGetter";
|
||||
|
||||
public ProcessClassGroupDataGetterN3(){
|
||||
|
||||
}
|
||||
//Pass in variable that represents the counter
|
||||
|
||||
//TODO: ensure correct model returned
|
||||
//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" +
|
||||
"<" + DisplayVocabulary.FOR_CLASSGROUP + "> ?classGroup .";
|
||||
List<String> requiredList = new ArrayList<String>();
|
||||
requiredList.add(getPrefixes() + n3);
|
||||
return requiredList;
|
||||
|
||||
}
|
||||
public List<String> retrieveN3Optional(int counter) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//These methods will return the literals and uris expected within the n3
|
||||
//and the counter is used to ensure they are numbered correctly
|
||||
|
||||
public List<String> retrieveLiteralsOnForm(int counter) {
|
||||
//no literals, just the class group URI
|
||||
List<String> literalsOnForm = new ArrayList<String>();
|
||||
return literalsOnForm;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<String> retrieveUrisOnForm(int counter) {
|
||||
List<String> urisOnForm = new ArrayList<String>();
|
||||
//Class group is a URI
|
||||
urisOnForm.add(getVarName("classGroup", counter));
|
||||
return urisOnForm;
|
||||
|
||||
}
|
||||
|
||||
public List<FieldVTwo> retrieveFields(int counter) {
|
||||
List<FieldVTwo> fields = new ArrayList<FieldVTwo>();
|
||||
fields.add(new FieldVTwo().setName(getVarName("classGroup", counter)));
|
||||
return fields;
|
||||
}
|
||||
|
||||
//These var names match the names of the elements within the json object returned with the info required for the data getter
|
||||
|
||||
public List<String> getLiteralVarNamesBase() {
|
||||
return Arrays.asList();
|
||||
}
|
||||
|
||||
//these are for the fields ON the form
|
||||
public List<String> getUriVarNamesBase() {
|
||||
return Arrays.asList("classGroup");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
import net.sf.json.JSONSerializer;
|
||||
//Returns the appropriate n3 based on data getter
|
||||
public abstract class ProcessDataGetterAbstract implements ProcessDataGetterN3 {
|
||||
|
||||
public ProcessDataGetterAbstract(){
|
||||
|
||||
}
|
||||
|
||||
//placeholder so need "?" in front of the variable
|
||||
public String getDataGetterVar(int counter) {
|
||||
return "?dataGetter" + counter;
|
||||
}
|
||||
|
||||
public String getPrefixes() {
|
||||
return "@prefix display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> . \n" +
|
||||
"@prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#> . \n";
|
||||
}
|
||||
|
||||
public String getVarName(String base, int 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
|||
import net.sf.json.JSONObject;
|
||||
import net.sf.json.JSONSerializer;
|
||||
//Returns the appropriate n3 based on data getter
|
||||
public class ProcessSparqlDataGetterN3 implements ProcessDataGetterN3 {
|
||||
public class ProcessSparqlDataGetterN3 extends ProcessDataGetterAbstract {
|
||||
private static String classType = "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter";
|
||||
|
||||
public ProcessSparqlDataGetterN3(){
|
||||
|
@ -39,15 +39,6 @@ public class ProcessSparqlDataGetterN3 implements ProcessDataGetterN3 {
|
|||
public List<String> retrieveN3Optional(int counter) {
|
||||
return null;
|
||||
}
|
||||
//placeholder so need "?" in front of the variable
|
||||
public String getDataGetterVar(int counter) {
|
||||
return "?dataGetter" + counter;
|
||||
}
|
||||
|
||||
private String getPrefixes() {
|
||||
return "@prefix display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> . \n" +
|
||||
"@prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#> . \n";
|
||||
}
|
||||
|
||||
|
||||
//Need to add method sfor returning the fields, literals on form, and all that
|
||||
|
@ -105,22 +96,7 @@ public class ProcessSparqlDataGetterN3 implements ProcessDataGetterN3 {
|
|||
return Arrays.asList("queryModel");
|
||||
}
|
||||
|
||||
public String getVarName(String base, int 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue