Merge branch 'develop' of github.com:vivo-project/Vitro into develop
This commit is contained in:
commit
08dab8e52f
27 changed files with 627 additions and 158 deletions
|
@ -250,6 +250,30 @@
|
|||
support websites.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The following browsers are supported for this release
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
Mac:
|
||||
<ul>
|
||||
<li>Chrome 30.0.1599.69 and above</li>
|
||||
<li>FireFox 3.6.28, 10.0.12, 24</li>
|
||||
<li>Opera 12.02</li>
|
||||
<li>Safari 5.0.3</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
PC:
|
||||
<ul>
|
||||
<li>Chrome 25.1364.2 and above</li>
|
||||
<li>FireFox 10.0.12, 24</li>
|
||||
<li>Internet Explorer 8, 9, 10</li>
|
||||
<li>Opera 12.02</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3 id="create_database">II. Create an empty MySQL database </h3>
|
||||
<p>
|
||||
Decide on a database name, username, and password. Log into your
|
||||
|
|
|
@ -15,6 +15,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display.DisplayObje
|
|||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
||||
|
||||
|
@ -113,10 +114,11 @@ public class DisplayByRolePermission extends Permission {
|
|||
private boolean isAuthorized(DisplayObjectPropertyStatement action) {
|
||||
ObjectPropertyStatement stmt = action.getObjectPropertyStatement();
|
||||
String subjectUri = stmt.getSubjectURI();
|
||||
String predicateUri = stmt.getPropertyURI();
|
||||
String objectUri = stmt.getObjectURI();
|
||||
Property op = (stmt.getProperty() != null)
|
||||
? stmt.getProperty() : new Property(stmt.getPropertyURI());
|
||||
return canDisplayResource(subjectUri)
|
||||
&& canDisplayPredicate(new Property(predicateUri))
|
||||
&& canDisplayPredicate(op)
|
||||
&& canDisplayResource(objectUri);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller.json;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupsForRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
||||
|
||||
/**
|
||||
*This class will get all the vclasses in the system.
|
||||
*/
|
||||
public class GetAllVClasses extends JsonObjectProducer {
|
||||
private static final Log log = LogFactory
|
||||
.getLog(GetAllVClasses.class);
|
||||
|
||||
public GetAllVClasses(VitroRequest vreq) {
|
||||
super(vreq);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject process() throws Exception {
|
||||
JSONObject map = new JSONObject();
|
||||
//Get all VClassGroups
|
||||
List<VClass> vclasses = new ArrayList<VClass>();
|
||||
VClassGroupsForRequest vcgc = VClassGroupCache.getVClassGroups(vreq);
|
||||
List<VClassGroup> groups = vcgc.getGroups();
|
||||
for(VClassGroup vcg: groups) {
|
||||
for( VClass vc : vcg){
|
||||
vclasses.add(vc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Sort vclass by name
|
||||
Collections.sort(vclasses);
|
||||
ArrayList<JSONObject> classes = new ArrayList<JSONObject>(vclasses.size());
|
||||
|
||||
for(VClass vc: vclasses) {
|
||||
JSONObject vcObj = new JSONObject();
|
||||
vcObj.put("name", vc.getName());
|
||||
vcObj.put("URI", vc.getURI());
|
||||
classes.add(vcObj);
|
||||
}
|
||||
map.put("classes", classes);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
|
@ -83,6 +83,8 @@ public class JsonServlet extends VitroHttpServlet {
|
|||
new GetRenderedSolrIndividualsByVClass(vreq).process(resp);
|
||||
}else if( vreq.getParameter("getRandomSolrIndividualsByVClass") != null ){
|
||||
new GetRandomSolrIndividualsByVClass(vreq).process(resp);
|
||||
} else if( vreq.getParameter("getAllVClasses") != null ){
|
||||
new GetAllVClasses(vreq).process(resp);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -104,8 +104,10 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
|
|||
// funny business because it needs to be able to retrieve anonymous union
|
||||
// classes by their "pseudo-bnode URIs".
|
||||
// Someday we'll need to figure out a different way of doing this.
|
||||
WebappDaoFactory ctxDaoFact = ModelAccess.on(
|
||||
vreq.getSession().getServletContext()).getWebappDaoFactory();
|
||||
//WebappDaoFactory ctxDaoFact = ModelAccess.on(
|
||||
// vreq.getSession().getServletContext()).getWebappDaoFactory();
|
||||
WebappDaoFactory ctxDaoFact = vreq.getLanguageNeutralWebappDaoFactory();
|
||||
|
||||
List<VClass> types = new ArrayList<VClass>();
|
||||
Individual subject = EditConfigurationUtils.getSubjectIndividual(vreq);
|
||||
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||
|
|
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -30,10 +31,14 @@ import com.hp.hpl.jena.rdf.model.Resource;
|
|||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
import com.hp.hpl.jena.vocabulary.XSD;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupsForRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
||||
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.fields.FieldVTwo;
|
||||
|
@ -521,6 +526,8 @@ private String getExistingIsSelfContainedTemplateQuery() {
|
|||
MenuManagementDataUtils.includeRequiredSystemData(vreq.getSession().getServletContext(), data);
|
||||
data.put("classGroup", new ArrayList<String>());
|
||||
data.put("classGroups", DataGetterUtils.getClassGroups(vreq));
|
||||
//for solr individuals data get getter
|
||||
data.put("classes", this.getAllVClasses(vreq));
|
||||
data.put("availablePermissions", this.getAvailablePermissions(vreq));
|
||||
data.put("availablePermissionOrderedList", this.getAvailablePermissonsOrderedURIs());
|
||||
}
|
||||
|
@ -664,4 +671,33 @@ private String getExistingIsSelfContainedTemplateQuery() {
|
|||
return query;
|
||||
}
|
||||
|
||||
//Get all vclasses for the list of vclasses for solr
|
||||
//Originally considered using an ajax request to get the vclasses list which is fine for adding a new content type
|
||||
//but for an existing solr content type, would need to make yet another ajax request which seems too much
|
||||
private List<HashMap<String, String>> getAllVClasses(VitroRequest vreq) {
|
||||
List<VClass> vclasses = new ArrayList<VClass>();
|
||||
VClassGroupsForRequest vcgc = VClassGroupCache.getVClassGroups(vreq);
|
||||
List<VClassGroup> groups = vcgc.getGroups();
|
||||
for(VClassGroup vcg: groups) {
|
||||
for( VClass vc : vcg){
|
||||
vclasses.add(vc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Sort vclass by name
|
||||
Collections.sort(vclasses);
|
||||
ArrayList<HashMap<String, String>> classes = new ArrayList<HashMap<String, String>>(vclasses.size());
|
||||
|
||||
|
||||
for(VClass vc: vclasses) {
|
||||
HashMap<String, String> vcObj = new HashMap<String, String>();
|
||||
vcObj.put("name", vc.getName());
|
||||
vcObj.put("URI", vc.getURI());
|
||||
classes.add(vcObj);
|
||||
}
|
||||
return classes;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ public class ProcessDataGetterN3Map {
|
|||
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessClassGroupDataGetterN3");
|
||||
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.IndividualsForClassesDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessIndividualsForClassesDataGetterN3");
|
||||
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.FixedHTMLDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessFixedHTMLN3");
|
||||
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SolrIndividualsDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessSolrIndividualsDataGetterN3");
|
||||
|
||||
return map;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,179 @@
|
|||
/* $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.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
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;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||
//Returns the appropriate n3 based on data getter
|
||||
public class ProcessSolrIndividualsDataGetterN3 extends ProcessDataGetterAbstract {
|
||||
private static String classType = "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SolrIndividualsDataGetter";
|
||||
private Log log = LogFactory.getLog(ProcessFixedHTMLN3.class);
|
||||
|
||||
public ProcessSolrIndividualsDataGetterN3(){
|
||||
|
||||
}
|
||||
//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
|
||||
//?dataGetter a FixedHTMLDataGetter ; display:saveToVar ?saveToVar; display:htmlValue ?htmlValue .
|
||||
public List<String> retrieveN3Required(int counter) {
|
||||
String dataGetterVar = getDataGetterVar(counter);
|
||||
//UPDATE: Using variable for class type
|
||||
String classTypeVar = getN3VarName(classTypeVarBase, counter);
|
||||
String n3 = dataGetterVar + " a " + classTypeVar + "; \n" +
|
||||
"display:saveToVar " + getN3VarName("saveToVar", counter) + "; \n" +
|
||||
"display:hasVClassId " + getN3VarName("vclassUri", counter) + " .";
|
||||
List<String> requiredList = new ArrayList<String>();
|
||||
requiredList.add(getPrefixes() + n3);
|
||||
return requiredList;
|
||||
|
||||
}
|
||||
public List<String> retrieveN3Optional(int counter) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public List<String> retrieveLiteralsOnForm(int counter) {
|
||||
List<String> literalsOnForm = new ArrayList<String>();
|
||||
literalsOnForm.add(getVarName("saveToVar",counter));
|
||||
return literalsOnForm;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<String> retrieveUrisOnForm(int counter) {
|
||||
List<String> urisOnForm = new ArrayList<String>();
|
||||
//UPDATE: adding class type as uri on form
|
||||
urisOnForm.add(getVarName("vclassUri", counter));
|
||||
|
||||
urisOnForm.add(getVarName(classTypeVarBase, counter));
|
||||
return urisOnForm;
|
||||
|
||||
}
|
||||
|
||||
public List<FieldVTwo> retrieveFields(int counter) {
|
||||
List<FieldVTwo> fields = new ArrayList<FieldVTwo>();
|
||||
|
||||
//fields.add(new FieldVTwo().setName(getVarName("dataGetter", counter)));
|
||||
fields.add(new FieldVTwo().setName(getVarName("saveToVar", counter)));
|
||||
fields.add(new FieldVTwo().setName(getVarName("vclassUri", counter)));
|
||||
//UPDATE: adding class type to the uris on the form
|
||||
fields.add(new FieldVTwo().setName(getVarName(classTypeVarBase, counter)));
|
||||
return fields;
|
||||
}
|
||||
|
||||
public List<String> getLiteralVarNamesBase() {
|
||||
return Arrays.asList("saveToVar");
|
||||
}
|
||||
|
||||
//these are for the fields ON the form
|
||||
public List<String> getUriVarNamesBase() {
|
||||
return Arrays.asList(classTypeVarBase, "vclassUri");
|
||||
}
|
||||
|
||||
//For Existing Values in case of editing
|
||||
|
||||
//Execute populate before retrieval
|
||||
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);
|
||||
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");
|
||||
Resource vclassUriResource = qs.getResource("vclassUri");
|
||||
//Put both literals in existing literals
|
||||
existingLiteralValues.put(this.getVarName("saveToVar", counter),
|
||||
new ArrayList<Literal>(Arrays.asList(saveToVarLiteral)));
|
||||
existingUriValues.put(this.getVarName("vclassUri", counter),
|
||||
new ArrayList<String>(Arrays.asList(vclassUriResource.getURI())));
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//?dataGetter a FixedHTMLDataGetter ; display:saveToVar ?saveToVar; display:htmlValue ?htmlValue .
|
||||
protected String getExistingValuesSparqlQuery(String dataGetterURI) {
|
||||
String query = this.getSparqlPrefix() + " SELECT ?saveToVar ?vclassUri WHERE {" +
|
||||
"<" + dataGetterURI + "> display:saveToVar ?saveToVar . \n" +
|
||||
"<" + dataGetterURI + "> display:hasVClassId ?vclassUri . \n" +
|
||||
"}";
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
//Method to create a JSON object with existing values to return to form
|
||||
//There may be a better way to do this without having to run the query twice
|
||||
//TODO: Refactor code if required
|
||||
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{
|
||||
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");
|
||||
Resource vclassUriResource = qs.getResource("vclassUri");
|
||||
String vclassUriString = vclassUriResource.getURI();
|
||||
jObject.element("saveToVar", saveToVarLiteral.getString());
|
||||
//TODO: Handle single and double quotes within string and escape properlyu
|
||||
jObject.element("vclassUri", vclassUriString);
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
|
||||
}
|
||||
return jObject;
|
||||
|
||||
}
|
||||
|
||||
//Escape single and double quotes for html string to be returned to form
|
||||
public String replaceQuotes(String inputStr) {
|
||||
return inputStr.replaceAll("\'", "'").replaceAll("\"", """);
|
||||
|
||||
}
|
||||
|
||||
//This class can be extended so returning type here
|
||||
public String getClassType() {
|
||||
return classType;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ public class KnowledgeBaseUpdater {
|
|||
}
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
log.info("Migrating the knowledge base");
|
||||
log.info("Performing any necessary data migration");
|
||||
logger.log("Started knowledge base migration");
|
||||
|
||||
try {
|
||||
|
@ -94,24 +94,6 @@ public class KnowledgeBaseUpdater {
|
|||
|
||||
AtomicOntologyChangeLists changes = new AtomicOntologyChangeLists(rawChanges,settings.getNewTBoxModel(),settings.getOldTBoxModel());
|
||||
|
||||
// Only modify the TBox and migration metadata the first time
|
||||
if(updateRequired(servletContext)) {
|
||||
//process the TBox before the ABox
|
||||
try {
|
||||
log.debug("\tupdating tbox annotations");
|
||||
updateTBoxAnnotations();
|
||||
} catch (Exception e) {
|
||||
log.error(e,e);
|
||||
}
|
||||
|
||||
try {
|
||||
migrateMigrationMetadata(servletContext);
|
||||
logger.log("Migrated migration metadata");
|
||||
} catch (Exception e) {
|
||||
log.error("unable to migrate migration metadata " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// update ABox data any time
|
||||
log.info("performing SPARQL CONSTRUCT additions");
|
||||
performSparqlConstructs(settings.getSparqlConstructAdditionsDir(), settings.getRDFService(), ADD);
|
||||
|
@ -131,6 +113,18 @@ public class KnowledgeBaseUpdater {
|
|||
settings.getRDFService(), RETRACT);
|
||||
|
||||
|
||||
// Only modify the TBox and migration metadata the first time
|
||||
if(updateRequired(servletContext)) {
|
||||
//process the TBox before the ABox
|
||||
try {
|
||||
log.debug("\tupdating tbox annotations");
|
||||
updateTBoxAnnotations();
|
||||
} catch (Exception e) {
|
||||
log.error(e,e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static final boolean ADD = true;
|
||||
|
@ -264,39 +258,6 @@ public class KnowledgeBaseUpdater {
|
|||
aboxUpdater.processClassChanges(changes.getAtomicClassChanges());
|
||||
}
|
||||
|
||||
// special for 1.5 - temporary code
|
||||
// migrate past migration indicators to not use blank nodes and move them to app metadata model
|
||||
// changing structure for pre 1.5 ones in the process
|
||||
private void migrateMigrationMetadata(ServletContext servletContext) throws Exception {
|
||||
|
||||
String baseResourceURI = "http://vitro.mannlib.cornell.edu/ns/vitro/metadata/migration/";
|
||||
String queryFile = "MigrationData.sparql";
|
||||
|
||||
RDFService rdfService = RDFServiceUtils.getRDFServiceFactory(servletContext).getRDFService();
|
||||
|
||||
String fmQuery = FileUtils.readFileToString(new File(settings.getSparqlConstructDeletionsDir() + "/" + queryFile));
|
||||
Model toRemove = ModelFactory.createDefaultModel();
|
||||
toRemove.read(rdfService.sparqlConstructQuery(fmQuery, RDFService.ModelSerializationFormat.RDFXML), null);
|
||||
|
||||
String cmQuery = FileUtils.readFileToString(new File(settings.getSparqlConstructAdditionsDir() + "/" + queryFile));
|
||||
Model toAdd = ModelFactory.createDefaultModel();
|
||||
toAdd.read(rdfService.sparqlConstructQuery(cmQuery, RDFService.ModelSerializationFormat.RDFXML), null);
|
||||
|
||||
ByteArrayOutputStream outAdd = new ByteArrayOutputStream();
|
||||
toAdd.write(outAdd);
|
||||
InputStream inAdd = new ByteArrayInputStream(outAdd.toByteArray());
|
||||
ChangeSet addChangeSet = rdfService.manufactureChangeSet();
|
||||
addChangeSet.addAddition(inAdd, RDFService.ModelSerializationFormat.RDFXML, JenaDataSourceSetupBase.JENA_APPLICATION_METADATA_MODEL);
|
||||
rdfService.changeSetUpdate(addChangeSet);
|
||||
|
||||
ByteArrayOutputStream outRemove = new ByteArrayOutputStream();
|
||||
toRemove.write(outRemove);
|
||||
InputStream inRemove = new ByteArrayInputStream(outRemove.toByteArray());
|
||||
ChangeSet removeChangeSet = rdfService.manufactureChangeSet();
|
||||
removeChangeSet.addRemoval(inRemove, RDFService.ModelSerializationFormat.RDFXML, JenaDataSourceSetupBase.JENA_DB_MODEL);
|
||||
rdfService.changeSetUpdate(removeChangeSet);
|
||||
}
|
||||
|
||||
private void updateTBoxAnnotations() {
|
||||
TBoxUpdater tboxUpdater = new TBoxUpdater(settings, logger, record);
|
||||
try {
|
||||
|
|
|
@ -89,10 +89,6 @@ public class TBoxUpdater {
|
|||
|
||||
}
|
||||
|
||||
private Model mergeConfigurations(Model oldConfig, Model newConfig) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void updateDefaultAnnotationValues() throws IOException {
|
||||
updateDefaultAnnotationValues(null);
|
||||
}
|
||||
|
@ -454,89 +450,69 @@ public class TBoxUpdater {
|
|||
}
|
||||
|
||||
public void renameProperty(AtomicOntologyChange changeObj) throws IOException {
|
||||
Dataset dataset = new RDFServiceDataset(settings.getRDFService());
|
||||
Model userAnnotationsModel = dataset.getNamedModel(
|
||||
JenaDataSourceSetupBase.JENA_TBOX_ASSERTIONS_MODEL);
|
||||
if(changeObj.getNotes() != null && changeObj.getNotes().startsWith("cc:")) {
|
||||
mergePropertyAnnotationsToPropertyConfig(changeObj, userAnnotationsModel);
|
||||
mergePropertyAnnotationsToPropertyConfig(changeObj, siteModel);
|
||||
}
|
||||
Resource renamedProperty = userAnnotationsModel.getResource(changeObj.getSourceURI());
|
||||
userAnnotationsModel.removeAll(renamedProperty, null, (RDFNode) null);
|
||||
userAnnotationsModel.removeAll(null, null, renamedProperty);
|
||||
Resource renamedProperty = siteModel.getResource(changeObj.getSourceURI());
|
||||
siteModel.removeAll(renamedProperty, null, (RDFNode) null);
|
||||
siteModel.removeAll(null, null, renamedProperty);
|
||||
}
|
||||
|
||||
private void mergePropertyAnnotationsToPropertyConfig(AtomicOntologyChange changeObj,
|
||||
Model userAnnotationsModel) throws IOException {
|
||||
String contextURI = VitroVocabulary.PROPERTY_CONFIG_DATA + changeObj.getNotes().substring(3);
|
||||
String oldPropertyURI = changeObj.getSourceURI();
|
||||
|
||||
Model oldAnnotationsModel = settings.getOldTBoxAnnotationsModel();
|
||||
|
||||
String propertyAnnotationsQuery =
|
||||
"PREFIX config: <" + VitroVocabulary.configURI + "> \n" +
|
||||
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
||||
"CONSTRUCT { \n" +
|
||||
" <" + oldPropertyURI + "> vitro:inPropertyGroupAnnot ?group . \n" +
|
||||
" <" + oldPropertyURI + "> <" + RDFS.label.getURI() + "> ?label . \n" +
|
||||
" <" + oldPropertyURI + "> vitro:displayRankAnnot ?displayRank . \n" +
|
||||
" <" + oldPropertyURI + "> vitro:customEntryFormAnnot ?customForm . \n" +
|
||||
" <" + oldPropertyURI + "> vitro:hiddenFromDisplayBelowRoleLevelAnnot ?displayLevel . \n" +
|
||||
" <" + oldPropertyURI + "> vitro:prohibitedFromUpdateBelowRoleLevelAnnot ?updateLevel . \n " +
|
||||
" <" + oldPropertyURI + "> ?vitroProp ?vitroValue \n" +
|
||||
"} WHERE { \n" +
|
||||
" { <" + oldPropertyURI + "> vitro:inPropertyGroupAnnot ?group } \n" +
|
||||
" UNION { <" + oldPropertyURI + "> <" + RDFS.label.getURI() + "> ?label } \n" +
|
||||
" UNION { <" + oldPropertyURI + "> vitro:displayRankAnnot ?displayRank } \n" +
|
||||
" UNION { <" + oldPropertyURI + "> vitro:customEntryFormAnnot ?customForm } \n" +
|
||||
" UNION { <" + oldPropertyURI + "> vitro:hiddenFromDisplayBelowRoleLevelAnnot ?displayLevel } \n" +
|
||||
" UNION { <" + oldPropertyURI + "> vitro:prohibitedFromUpdateBelowRoleLevelAnnot ?updateLevel } \n " +
|
||||
" { <" + oldPropertyURI + "> <" + RDFS.label.getURI() + "> ?label } \n" +
|
||||
" UNION { <" + oldPropertyURI + "> ?vitroProp ?vitroValue \n" +
|
||||
" FILTER (regex(str(?vitroProp), \"" + VitroVocabulary.vitroURI + "\")) } \n" +
|
||||
"} \n" ;
|
||||
|
||||
Model userChangesModel = construct(
|
||||
propertyAnnotationsQuery, userAnnotationsModel).difference(
|
||||
construct(propertyAnnotationsQuery, oldAnnotationsModel));
|
||||
|
||||
String addQuery = "PREFIX config: <" + VitroVocabulary.configURI + "> \n" +
|
||||
if(userChangesModel.size() == 0) {
|
||||
return;
|
||||
} else {
|
||||
log.info("Updating PropertyConfig.n3 to include locally-changed " +
|
||||
"settings from old property " + oldPropertyURI);
|
||||
}
|
||||
|
||||
String newQuery = "PREFIX config: <" + VitroVocabulary.configURI + "> \n" +
|
||||
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
||||
"CONSTRUCT { \n" +
|
||||
" ?configuration config:propertyGroup ?group . \n" +
|
||||
" ?configuration config:displayName ?label . \n" +
|
||||
" ?configuration vitro:displayRankAnnot ?displayRank . \n" +
|
||||
" ?configuration vitro:customEntryFormAnnot ?customForm . \n" +
|
||||
" ?configuration vitro:hiddenFromDisplayBelowRoleLevelAnnot ?displayLevel . \n" +
|
||||
" ?configuration vitro:prohibitedFromUpdateBelowRoleLevelAnnot ?updateLevel . \n " +
|
||||
" ?configuration ?vitroProp ?vitroValue . \n" +
|
||||
"} WHERE { \n" +
|
||||
" <" + contextURI + "> config:hasConfiguration ?configuration . \n" +
|
||||
" OPTIONAL { <" + oldPropertyURI + "> vitro:inPropertyGroupAnnot ?group } \n" +
|
||||
" OPTIONAL { <" + oldPropertyURI + "> <" + RDFS.label.getURI() + "> ?label } \n" +
|
||||
" OPTIONAL { <" + oldPropertyURI + "> vitro:displayRankAnnot ?displayRank } \n" +
|
||||
" OPTIONAL { <" + oldPropertyURI + "> vitro:customEntryFormAnnot ?customForm } \n" +
|
||||
" OPTIONAL { <" + oldPropertyURI + "> vitro:hiddenFromDisplayBelowRoleLevelAnnot ?displayLevel } \n" +
|
||||
" OPTIONAL { <" + oldPropertyURI + "> vitro:prohibitedFromUpdateBelowRoleLevelAnnot ?updateLevel } \n " +
|
||||
" OPTIONAL { <" + oldPropertyURI + "> ?vitroProp ?vitroValue \n" +
|
||||
" FILTER (regex(str(?vitroProp), \"" + VitroVocabulary.vitroURI + "\")) } \n" +
|
||||
"} \n" ;
|
||||
|
||||
String retractQuery = "PREFIX config: <" + VitroVocabulary.configURI + "> \n" +
|
||||
String existingQuery = "PREFIX config: <" + VitroVocabulary.configURI + "> \n" +
|
||||
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
|
||||
"CONSTRUCT { \n" +
|
||||
" <" + oldPropertyURI + "> config:propertyGroup ?rgroup . \n" +
|
||||
" ?configuration config:displayName ?rlabel . \n" +
|
||||
" ?configuration vitro:displayRankAnnot ?rdisplayRank . \n" +
|
||||
" ?configuration vitro:customEntryFormAnnot ?rcustomForm . \n" +
|
||||
" ?configuration vitro:hiddenFromDisplayBelowRoleLevelAnnot ?rdisplayLevel . \n" +
|
||||
" ?configuration vitro:prohibitedFromUpdateBelowRoleLevelAnnot ?rupdateLevel . \n " +
|
||||
" ?configuration config:propertyGroup ?group . \n" +
|
||||
" ?configuration config:displayName ?label . \n" +
|
||||
" ?configuration ?vitroProp ?vitroValue . \n" +
|
||||
"} WHERE { \n" +
|
||||
" <" + contextURI + "> config:hasConfiguration ?configuration . \n" +
|
||||
" OPTIONAL { <" + oldPropertyURI + "> vitro:inPropertyGroupAnnot ?group . \n" +
|
||||
" ?configuration config:propertyGroup ?rgroup } \n" +
|
||||
" OPTIONAL { <" + oldPropertyURI + "> <" + RDFS.label.getURI() + "> ?label . \n" +
|
||||
" ?configuration config:displayName ?rlabel } \n " +
|
||||
" OPTIONAL { <" + oldPropertyURI + "> vitro:displayRankAnnot ?displayRank . \n" +
|
||||
" ?configuration vitro:displayRantAnnot ?rdisplayRank } \n " +
|
||||
" OPTIONAL { <" + oldPropertyURI + "> vitro:customEntryFormAnnot ?customForm . \n" +
|
||||
" ?configuration vitro:customEntryFormAnnot ?rcustomForm } \n" +
|
||||
" OPTIONAL { <" + oldPropertyURI + "> vitro:hiddenFromDisplayBelowRoleLevelAnnot ?displayLevel . \n" +
|
||||
" ?configuration vitro:hiddenFromDisplayBelowRoleLevelAnnot ?rdisplayLevel } \n" +
|
||||
" OPTIONAL { <" + oldPropertyURI + "> vitro:prohibitedFromUpdateBelowRoleLevelAnnot ?updateLevel . \n " +
|
||||
" ?configuration vitro:prohibitedFromUpdateBelowRoleLevelAnnot ?updateLevel } " +
|
||||
" OPTIONAL { ?configuration config:propertyGroup ?group } \n" +
|
||||
" OPTIONAL { ?configuration config:displayName ?label } \n" +
|
||||
" OPTIONAL { ?configuration ?vitroProp ?vitroValue \n" +
|
||||
" FILTER (regex(str(?vitroProp), \"" + VitroVocabulary.vitroURI + "\")) } \n" +
|
||||
"} \n" ;
|
||||
|
||||
Model configModel = ModelFactory.createDefaultModel();
|
||||
|
@ -545,17 +521,31 @@ public class TBoxUpdater {
|
|||
FileInputStream fis = new FileInputStream(file);
|
||||
configModel.read(fis, null, "N3");
|
||||
|
||||
Model union = ModelFactory.createUnion(configModel,
|
||||
userChangesModel);
|
||||
Model currentUnion = ModelFactory.createUnion(configModel,
|
||||
userAnnotationsModel);
|
||||
|
||||
Model additions = construct(addQuery, union);
|
||||
Model retractions = construct(retractQuery, union);
|
||||
Model userAnnotationsAsConfig = construct(newQuery, currentUnion);
|
||||
Model currentDefaultConfig = construct(existingQuery, currentUnion);
|
||||
|
||||
if (additions.size() > 0 || retractions.size() > 0) {
|
||||
configModel.remove(retractions);
|
||||
log.info("Removing " + retractions.size() + " statements from " + contextURI);
|
||||
Model additions = userAnnotationsAsConfig.difference(currentDefaultConfig);
|
||||
Model retractions = currentDefaultConfig.difference(userAnnotationsAsConfig);
|
||||
|
||||
// filter the retractions so we won't remove a value for a given predicate
|
||||
// unless the additions model contains at least one value for the same predicate
|
||||
Model filteredRetractions = ModelFactory.createDefaultModel();
|
||||
StmtIterator retractIt = retractions.listStatements();
|
||||
while(retractIt.hasNext()) {
|
||||
Statement candidate = retractIt.nextStatement();
|
||||
if(additions.contains(null, candidate.getPredicate(), (RDFNode) null)) {
|
||||
filteredRetractions.add(candidate);
|
||||
}
|
||||
}
|
||||
|
||||
if (additions.size() > 0 || filteredRetractions.size() > 0) {
|
||||
configModel.remove(filteredRetractions);
|
||||
log.debug("Removing " + filteredRetractions.size() + " statements from " + contextURI);
|
||||
configModel.add(additions);
|
||||
log.info("Adding " + additions.size() + " statements from " + contextURI);
|
||||
log.debug("Adding " + additions.size() + " statements from " + contextURI);
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
configModel.write(fos, "N3");
|
||||
}
|
||||
|
|
|
@ -81,6 +81,8 @@ public class SimpleReasonerSetup implements ServletContextListener {
|
|||
|
||||
log.info("Pellet reasoner connected for the TBox");
|
||||
|
||||
waitForTBoxReasoning(sce);
|
||||
|
||||
// set up simple reasoning for the ABox
|
||||
|
||||
RDFService rdfService = RDFServiceUtils.getRDFServiceFactory(ctx).getRDFService();
|
||||
|
@ -131,7 +133,7 @@ public class SimpleReasonerSetup implements ServletContextListener {
|
|||
int sleeps = 0;
|
||||
// sleep at least once to make sure the TBox reasoning gets started
|
||||
while ((0 == sleeps) || ((sleeps < 1000) && pelletListener.isReasoning())) {
|
||||
if ((sleeps % 10) == 0) { // print message at 10 second intervals
|
||||
if (((sleeps - 1) % 10) == 0) { // print message at 10 second intervals
|
||||
log.info("Waiting for initial TBox reasoning to complete");
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
|
|
|
@ -141,7 +141,6 @@ public class UpdateKnowledgeBase implements ServletContextListener {
|
|||
if(!JenaDataSourceSetupBase.isFirstStartup()) {
|
||||
try {
|
||||
ctx.setAttribute(KBM_REQURIED_AT_STARTUP, Boolean.TRUE);
|
||||
log.info("Data migration required");
|
||||
migrationChangesMade = ontologyUpdater.update(ctx);
|
||||
if (tryMigrateDisplay) {
|
||||
try {
|
||||
|
@ -221,8 +220,8 @@ public class UpdateKnowledgeBase implements ServletContextListener {
|
|||
StartupStatus.getBean(ctx).info(this, "Updating knowledge base: reports are in '" + dataDir + "'");
|
||||
|
||||
Path changedDir = createDirectory(dataDir, "changedData");
|
||||
settings.setAddedDataFile(changedDir.resolve("addedData.n3").toString());
|
||||
settings.setRemovedDataFile(changedDir.resolve("removedData.n3").toString());
|
||||
settings.setAddedDataFile(changedDir.resolve(timestampedFileName("addedData", "n3")).toString());
|
||||
settings.setRemovedDataFile(changedDir.resolve(timestampedFileName("removedData", "n3")).toString());
|
||||
|
||||
Path logDir = createDirectory(dataDir, "logs");
|
||||
settings.setLogFile(logDir.resolve(timestampedFileName("knowledgeBaseUpdate", "log")).toString());
|
||||
|
|
|
@ -108,9 +108,9 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
|
||||
if (editing) {
|
||||
mergeAllPossibleDataProperties(propertyList);
|
||||
propertyList = correctLanguageForProperties(propertyList);
|
||||
}
|
||||
|
||||
propertyList = correctLanguageForProperties(propertyList);
|
||||
sort(propertyList);
|
||||
|
||||
// Put the list into groups
|
||||
|
|
|
@ -106,7 +106,8 @@ h1.fn .display-title {
|
|||
margin-left: 10px;
|
||||
}
|
||||
#individual-info h2 {
|
||||
padding-bottom: 10px;
|
||||
padding-bottom: 6px;
|
||||
padding-top: 18px;
|
||||
}
|
||||
#individual-info nav {
|
||||
float: left;
|
||||
|
|
|
@ -5,7 +5,19 @@
|
|||
<%@ page import="com.oreilly.servlet.ServletUtils,edu.cornell.mannlib.vitro.webapp.web.*" %>
|
||||
<%@page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%>
|
||||
<%@page import="edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean"%>
|
||||
<%@page import="org.apache.commons.logging.Log"%>
|
||||
<%@page import="org.apache.commons.logging.LogFactory"%>
|
||||
<%
|
||||
// We have seen that this page can throw its own error.
|
||||
// Before it does so, be sure that we have written the original error to the log.
|
||||
Object c = request.getAttribute("javax.servlet.jsp.jspException");
|
||||
if (c instanceof Throwable) {
|
||||
Throwable cause = (Throwable) c;
|
||||
Log log = LogFactory.getLog(this.getClass());
|
||||
log.error("Error: ", cause);
|
||||
}
|
||||
|
||||
|
||||
VitroRequest vreq = new VitroRequest(request);
|
||||
ApplicationBean appBean = vreq.getAppBean();
|
||||
String themeDir = appBean.getThemeDir();
|
||||
|
|
|
@ -605,7 +605,8 @@ page_text = page text
|
|||
|
||||
sparql_query_results = Sparql Query Results
|
||||
no_results_returned = No results were returned.
|
||||
|
||||
solr_individual_results = Solr Class Individuals
|
||||
select_vclass_uri = Select VClass
|
||||
#
|
||||
# manage proxies templates ( /templates/freemarker/body/manageproxies )
|
||||
#
|
||||
|
@ -849,9 +850,9 @@ delete = delete
|
|||
map_processor_error = An error has occurred and the map of processors for this content is missing. Please contact the administrator
|
||||
code_processing_error = An error has occurred and the code for processing this content is missing a component. Please contact the administrator.
|
||||
|
||||
supply_class_group = You must supply a class group
|
||||
select_classes_to_display = You must select the classes to display
|
||||
|
||||
supply_class_group = You must supply a class group.
|
||||
select_classes_to_display = You must select the classes to display.
|
||||
select_class_for_solr = You must select a class to display its individuals.
|
||||
supply_variable_name = You must supply a variable to save HTML content.
|
||||
apostrophe_not_allowed = The variable name should not have an apostrophe.
|
||||
double_quote_note_allowed = The variable name should not have a double quote.
|
||||
|
|
|
@ -104,6 +104,7 @@ var pageManagementUtils = {
|
|||
this.classGroupSection = $("section#browseClassGroup");
|
||||
this.sparqlQuerySection = $("section#sparqlQuery");
|
||||
this.fixedHTMLSection = $("section#fixedHtml");
|
||||
this.solrIndividualsSection = $("section#solrIndividuals");
|
||||
//From original menu management edit
|
||||
this.defaultTemplateRadio = $('input.default-template');
|
||||
this.customTemplateRadio = $('input.custom-template');
|
||||
|
@ -117,6 +118,7 @@ var pageManagementUtils = {
|
|||
this.classesForClassGroup = $('section#classesInSelectedGroup');
|
||||
this.selectedGroupForPage = $('#selectedContentTypeValue');
|
||||
this.allClassesSelectedCheckbox = $('#allSelected');
|
||||
|
||||
this.displayInternalMessage = $('#internal-class label em');
|
||||
this.pageContentSubmissionInputs = $("#pageContentSubmissionInputs");
|
||||
this.headerBar = $("section#headerBar");
|
||||
|
@ -131,6 +133,8 @@ var pageManagementUtils = {
|
|||
this.rightSideDiv = $("div#rightSide");
|
||||
//contentDivs container where content added/existing placed
|
||||
this.savedContentDivs = $("section#contentDivs");
|
||||
//for solr individuals data getter
|
||||
this.solrAllClassesDropdown = $("select#vclassUri");
|
||||
},
|
||||
initDisplay: function(){
|
||||
//right side components
|
||||
|
@ -143,6 +147,7 @@ var pageManagementUtils = {
|
|||
this.classGroupSection.hide();
|
||||
this.sparqlQuerySection.hide();
|
||||
this.fixedHTMLSection.hide();
|
||||
this.solrIndividualsSection.hide();
|
||||
this.classesForClassGroup.addClass('hidden');
|
||||
//left side components
|
||||
//These depend on whether or not this is an existing item or not
|
||||
|
@ -155,8 +160,44 @@ var pageManagementUtils = {
|
|||
this.menuSection.hide();
|
||||
}
|
||||
}
|
||||
|
||||
//populates the dropdown of classes for the solr individuals template
|
||||
//dropdown now populated in template/from form specific data instead of ajax request
|
||||
//this.populateClassForSolrDropdown();
|
||||
},
|
||||
//this method can be utilized if using an ajax request to get the vclasses
|
||||
/*
|
||||
//for solr individuals - remember this populates the template class dropdown
|
||||
populateClassForSolrDropdown:function() {
|
||||
|
||||
//Run ajax query
|
||||
var url = "dataservice?getAllVClasses=1";
|
||||
|
||||
//Make ajax call to retrieve vclasses
|
||||
$.getJSON(url, function(results) {
|
||||
//Moved the function to processClassGroupDataGetterContent
|
||||
//Should probably remove this entire method and copy there
|
||||
pageManagementUtils.displayAllClassesForSolrDropdown(results);
|
||||
});
|
||||
},
|
||||
displayAllClassesForSolrDropdown:function(results) {
|
||||
if ( results.classes.length == 0 ) {
|
||||
|
||||
} else {
|
||||
var appendHtml = "";
|
||||
$.each(results.classes, function(i, item) {
|
||||
var thisClass = results.classes[i];
|
||||
var thisClassName = thisClass.name;
|
||||
//Create options for the dropdown
|
||||
appendHtml += "<option value='" + thisClass.URI + "'>" + thisClassName + "</option>";
|
||||
});
|
||||
|
||||
//if there are options to add
|
||||
if(appendHtml != "") {
|
||||
pageManagementUtils.solrAllClassesDropdown.html(appendHtml);
|
||||
}
|
||||
|
||||
}
|
||||
},*/
|
||||
bindEventListeners:function(){
|
||||
|
||||
this.defaultTemplateRadio.click( function() {
|
||||
|
@ -206,10 +247,13 @@ var pageManagementUtils = {
|
|||
pageManagementUtils.checkSelfContainedRadio();
|
||||
});
|
||||
//replacing with menu management edit version which is extended with some of the logic below
|
||||
//This is technically content specific and should be moved into the individual processor classes somehow
|
||||
this.selectClassGroupDropdown.change(function() {
|
||||
pageManagementUtils.chooseClassGroup();
|
||||
});
|
||||
|
||||
|
||||
|
||||
this.contentTypeSelect.change( function() {
|
||||
pageManagementUtils.handleContentTypeSelect();
|
||||
});
|
||||
|
@ -229,6 +273,7 @@ var pageManagementUtils = {
|
|||
pageManagementUtils.classGroupSection.hide();
|
||||
pageManagementUtils.fixedHTMLSection.hide();
|
||||
pageManagementUtils.sparqlQuerySection.hide();
|
||||
pageManagementUtils.solrIndividualsSection.hide();
|
||||
//Reset main content type drop-down
|
||||
pageManagementUtils.contentTypeSelectOptions.eq(0).attr('selected', 'selected');
|
||||
if ( pageManagementUtils.leftSideDiv.css("height") != undefined ) {
|
||||
|
@ -291,7 +336,8 @@ var pageManagementUtils = {
|
|||
}
|
||||
},
|
||||
|
||||
//Select content type
|
||||
//Select content type - this is content type specific
|
||||
//TODO: Find better way to refactor this and/or see if any of this display functionality can be moved into content type processing
|
||||
handleContentTypeSelect:function() {
|
||||
_this = pageManagementUtils;
|
||||
pageManagementUtils.clearSourceTemplateValues();
|
||||
|
@ -299,22 +345,31 @@ var pageManagementUtils = {
|
|||
pageManagementUtils.classGroupSection.show();
|
||||
pageManagementUtils.fixedHTMLSection.hide();
|
||||
pageManagementUtils.sparqlQuerySection.hide();
|
||||
pageManagementUtils.solrIndividualsSection.hide();
|
||||
pageManagementUtils.headerBar.text(pageManagementUtils.browseClassGroup + " - ");
|
||||
pageManagementUtils.headerBar.show();
|
||||
$('div#selfContainedDiv').hide();
|
||||
}
|
||||
if ( _this.contentTypeSelect.val() == "fixedHtml" || _this.contentTypeSelect.val() == "sparqlQuery" ) {
|
||||
if ( _this.contentTypeSelect.val() == "fixedHtml" || _this.contentTypeSelect.val() == "sparqlQuery" || _this.contentTypeSelect.val() == "solrIndividuals") {
|
||||
pageManagementUtils.classGroupSection.hide();
|
||||
//if fixed html show that, otherwise show sparql results
|
||||
if ( _this.contentTypeSelect.val() == "fixedHtml" ) {
|
||||
pageManagementUtils.headerBar.text(pageManagementUtils.fixedHtml + " - ");
|
||||
pageManagementUtils.fixedHTMLSection.show();
|
||||
pageManagementUtils.sparqlQuerySection.hide();
|
||||
pageManagementUtils.solrIndividualsSection.hide();
|
||||
}
|
||||
else {
|
||||
else if (_this.contentTypeSelect.val() == "sparqlQuery"){
|
||||
pageManagementUtils.headerBar.text(pageManagementUtils.sparqlResults + " - ");
|
||||
pageManagementUtils.sparqlQuerySection.show();
|
||||
pageManagementUtils.fixedHTMLSection.hide();
|
||||
pageManagementUtils.solrIndividualsSection.hide();
|
||||
} else {
|
||||
//solr individuals
|
||||
pageManagementUtils.headerBar.text(pageManagementUtils.solrIndividuals + " - ");
|
||||
pageManagementUtils.sparqlQuerySection.hide();
|
||||
pageManagementUtils.fixedHTMLSection.hide();
|
||||
pageManagementUtils.solrIndividualsSection.show();
|
||||
}
|
||||
|
||||
pageManagementUtils.headerBar.show();
|
||||
|
@ -325,6 +380,7 @@ var pageManagementUtils = {
|
|||
pageManagementUtils.classGroupSection.hide();
|
||||
pageManagementUtils.fixedHTMLSection.hide();
|
||||
pageManagementUtils.sparqlQuerySection.hide();
|
||||
pageManagementUtils.solrIndividualsSection.hide();
|
||||
pageManagementUtils.classesForClassGroup.addClass('hidden');
|
||||
pageManagementUtils.headerBar.hide();
|
||||
pageManagementUtils.headerBar.text("");
|
||||
|
@ -359,6 +415,7 @@ var pageManagementUtils = {
|
|||
pageManagementUtils.clearInputs(pageManagementUtils.fixedHTMLSection);
|
||||
pageManagementUtils.clearInputs(pageManagementUtils.sparqlQuerySection);
|
||||
pageManagementUtils.clearInputs(pageManagementUtils.classGroupSection);
|
||||
pageManagementUtils.clearInputs(pageManagementUtils.solrIndividualsSection);
|
||||
|
||||
},
|
||||
clearInputs:function($el) {
|
||||
|
@ -387,7 +444,7 @@ var pageManagementUtils = {
|
|||
// Get rid of the cancel link; it'll be replaced by a delete link
|
||||
$newContentObj.find('span#cancelContent' + counter).html('');
|
||||
|
||||
if ( contentType == "sparqlQuery" || contentType == "fixedHtml") {
|
||||
if ( contentType == "sparqlQuery" || contentType == "fixedHtml" || contentType == "solrIndividuals") {
|
||||
varOrClass = $newContentObj.find('input[name="saveToVar"]').val();
|
||||
}
|
||||
else if ( contentType == "browseClassGroup" ) {
|
||||
|
|
|
@ -9,7 +9,8 @@ var processDataGetterUtils = {
|
|||
dataGetterProcessorMap:{"browseClassGroup": processClassGroupDataGetterContent,
|
||||
"sparqlQuery": processSparqlDataGetterContent,
|
||||
"fixedHtml":processFixedHTMLDataGetterContent,
|
||||
"individualsForClasses":processIndividualsForClassesDataGetterContent},
|
||||
"individualsForClasses":processIndividualsForClassesDataGetterContent,
|
||||
"solrIndividuals":processSolrDataGetterContent},
|
||||
selectDataGetterType:function(pageContentSection) {
|
||||
var contentType = pageContentSection.attr("contentType");
|
||||
//The form can provide "browse class group" as content type but need to check
|
||||
|
|
86
webapp/web/js/menupage/processSolrDataGetterContent.js
Normal file
86
webapp/web/js/menupage/processSolrDataGetterContent.js
Normal file
|
@ -0,0 +1,86 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
$.extend(this, i18nStringsSolrIndividuals);
|
||||
|
||||
//Process sparql data getter and provide a json object with the necessary information
|
||||
var processSolrDataGetterContent = {
|
||||
dataGetterClass:null,
|
||||
//can use this if expect to initialize from elsewhere
|
||||
initProcessor:function(dataGetterClass) {
|
||||
this.dataGetterClass =dataGetterClass;
|
||||
|
||||
},
|
||||
|
||||
processPageContentSection:function(pageContentSection) {
|
||||
|
||||
var variableValue = pageContentSection.find("input[name='saveToVar']").val();
|
||||
var vclassUriValue = pageContentSection.find("select[name='vclassUri']").val();
|
||||
|
||||
|
||||
//query model should also be an input
|
||||
//set query model to query model here - vitro:contentDisplayModel
|
||||
var returnObject = {saveToVar:variableValue, vclassUri:vclassUriValue, 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 saveToVarValue = existingContentObject["saveToVar"];
|
||||
var vclassUriValue = existingContentObject["vclassUri"];
|
||||
|
||||
|
||||
//Now find and set value
|
||||
pageContentSection.find("input[name='saveToVar']").val(saveToVarValue);
|
||||
//set value of solr query
|
||||
pageContentSection.find("select[name='vclassUri']").val(vclassUriValue);
|
||||
|
||||
},
|
||||
//For the label of the content section for editing, need to add additional value
|
||||
retrieveContentLabel:function() {
|
||||
return i18nStringsSolrIndividuals.solrIndividuals;
|
||||
},
|
||||
//For the label of the content section for editing, need to add additional value
|
||||
retrieveAdditionalLabelText:function(existingContentObject) {
|
||||
var saveToVarValue = existingContentObject["saveToVar"];
|
||||
return saveToVarValue;
|
||||
},
|
||||
//Validation on form submit: Check to see that class group has been selected
|
||||
validateFormSubmission: function(pageContentSection, pageContentSectionLabel) {
|
||||
var validationError = "";
|
||||
//Check that vclassuri and saveToVar have been input
|
||||
var variableValue = pageContentSection.find("input[name='saveToVar']").val();
|
||||
if(variableValue == "") {
|
||||
validationError += pageContentSectionLabel + ": " + i18nStringsSolrIndividuals.supplyQueryVariable + " <br />"
|
||||
}
|
||||
if(processSolrDataGetterContent.stringHasSingleQuote(variableValue)) {
|
||||
validationError += pageContentSectionLabel + ": " + i18nStringsSolrIndividuals.noApostrophes + " <br />";
|
||||
}
|
||||
if(processSolrDataGetterContent.stringHasDoubleQuote(variableValue)) {
|
||||
validationError += pageContentSectionLabel + ": " + i18nStringsSolrIndividuals.noDoubleQuotes + " <br />";
|
||||
}
|
||||
|
||||
//validation for solr individuals
|
||||
|
||||
var vclassUriValue = pageContentSection.find("select[name='vclassUri']").val();
|
||||
if(vclassUriValue == "") {
|
||||
validationError += pageContentSectionLabel + ": " + i18nStringsSolrIndividuals.selectClass + " <br />";
|
||||
}
|
||||
return validationError;
|
||||
},
|
||||
encodeQuotes:function(inputStr) {
|
||||
return inputStr.replace(/'/g, ''').replace(/"/g, '"');
|
||||
},
|
||||
//For the variable name, no single quote should be allowed
|
||||
//This can be extended for other special characters
|
||||
stringHasSingleQuote:function(inputStr) {
|
||||
return(inputStr.indexOf("'") != -1);
|
||||
},
|
||||
stringHasDoubleQuote:function(inputStr) {
|
||||
return(inputStr.indexOf("\"") != -1);
|
||||
},
|
||||
replaceEncodedWithEscapedQuotes: function(inputStr) {
|
||||
|
||||
return inputStr.replace(/'/g, "\'").replace(/"/g, "\"");
|
||||
}
|
||||
|
||||
|
||||
};
|
|
@ -5,7 +5,7 @@ $(document).ready(function(){
|
|||
// Use jQuery() instead of $() alias, because dwr/util.js, loaded on back end editing
|
||||
// pages, overwrites $.
|
||||
// fade out welcome-message when user logs in
|
||||
$.extend(this, i18nStrings);
|
||||
jQuery.extend(this, i18nStrings);
|
||||
|
||||
jQuery('section#welcome-message').css('display', 'block').delay(2000).fadeOut(1500);
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
</h3>
|
||||
<#elseif rangeClass == "Name" && property.statements?has_content && editable >
|
||||
<h3 id="${property.localName}">${property.name} <@p.verboseDisplay property /> </h3>
|
||||
<#elseif rangeClass == "Title" && property.statements?has_content && editable >
|
||||
<h3 id="${property.localName}">${property.name} <@p.verboseDisplay property /> </h3>
|
||||
<#else>
|
||||
<h3 id="${property.localName}">${property.name} <@p.addLink property editable /> <@p.verboseDisplay property /> </h3>
|
||||
</#if>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<ul class="propertyTabsList">
|
||||
<li class="groupTabSpacer"> </li>
|
||||
<#list propertyGroups.all as groupTabs>
|
||||
<#if ( groupTabs.properties?size > 0 ) >
|
||||
<#assign groupName = groupTabs.getName(nameForOtherGroup)>
|
||||
<#if groupName?has_content>
|
||||
<#--the function replaces spaces in the name with underscores, also called for the property group menu-->
|
||||
|
@ -26,6 +27,7 @@
|
|||
<li class="nonSelectedGroupTab clickable" groupName="${groupNameHtmlId}">${groupName?capitalize}</li>
|
||||
<li class="groupTabSpacer"> </li>
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
<#if (propertyGroups.all?size > 1) >
|
||||
<li class="nonSelectedGroupTab clickable" groupName="viewAll">${i18n().view_all_capitalized}</li>
|
||||
|
|
|
@ -3,3 +3,4 @@
|
|||
<#include "pageManagement--browseClassGroups.ftl">
|
||||
<#include "pageManagement--sparqlQuery.ftl">
|
||||
<#include "pageManagement--fixedHtml.ftl">
|
||||
<#include "pageManagement--solrIndividuals.ftl">
|
|
@ -12,7 +12,8 @@ scripts list.-->
|
|||
"browseClassGroup": "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData",
|
||||
"individualsForClasses": "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.IndividualsForClassesDataGetter",
|
||||
"sparqlQuery":"java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter",
|
||||
"fixedHtml":"java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.FixedHTMLDataGetter"
|
||||
"fixedHtml":"java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.FixedHTMLDataGetter",
|
||||
"solrIndividuals":"java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SolrIndividualsDataGetter"
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,33 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
<#--This contains the template for the Solr Class individuals content type that is to be cloned and used in page management-->
|
||||
<#assign classGroup = pageData.classGroup />
|
||||
<#assign classGroups = pageData.classGroups />
|
||||
<#assign classes = pageData.classes />
|
||||
<section id="solrIndividuals" class="contentSectionContainer">
|
||||
<label id="variableLabel" for="variable">${i18n().variable_name_all_caps}<span class="requiredHint"> *</span></label>
|
||||
<input type="text" name="saveToVar" size="20" value="" id="saveToVar" role="input" />
|
||||
<label id="vclassUriLabel" for="vclassUri">${i18n().select_vclass_uri}<span class="requiredHint"> *</span></label>
|
||||
<br/>
|
||||
<select name="vclassUri" id="vclassUri">
|
||||
<option value="">Select class</option>
|
||||
<#list classes as classObj>
|
||||
<option value="${classObj.URI}">${classObj.name}</option>
|
||||
</#list>
|
||||
</select>
|
||||
<br/>
|
||||
<input type="button" id="doneWithContent" class="doneWithContent" name="doneWithContent" value="${i18n().save_this_content}" />
|
||||
<#if menuAction == "Add">
|
||||
<span id="cancelContent"> or <a class="cancel" href="javascript:" id="cancelContentLink" title="${i18n().cancel_title}">${i18n().cancel_link}</a></span>
|
||||
</#if>
|
||||
</section>
|
||||
<script>
|
||||
var i18nStringsSolrIndividuals = {
|
||||
solrIndividuals: '${i18n().solr_individual_results}',
|
||||
supplyQueryVariable: '${i18n().supply_query_variable}',
|
||||
noApostrophes: '${i18n().apostrophe_not_allowed}',
|
||||
noDoubleQuotes: '${i18n().double_quote_note_allowed}',
|
||||
supplyQuery: '${i18n().supply_sparql_query}',
|
||||
selectClass: '${i18n().select_class_for_solr}'
|
||||
};
|
||||
</script>
|
||||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/menupage/processSolrDataGetterContent.js"></script>')}
|
|
@ -81,6 +81,7 @@
|
|||
<option value="browseClassGroup">${i18n().browse_class_group}</option>
|
||||
<option value="fixedHtml">${i18n().fixed_html}</option>
|
||||
<option value="sparqlQuery">${i18n().sparql_query_results}</option>
|
||||
<option value="solrIndividuals">${i18n().solr_individual_results}</option>
|
||||
</select> <span class="note">${i18n().add_types}</span>
|
||||
</section>
|
||||
<section id="contentDivs"></section>
|
||||
|
@ -136,8 +137,10 @@
|
|||
|
||||
|
||||
</section>
|
||||
<section id="pagePermissions>
|
||||
<label for="default">${i18n().page_select_permission}</label>
|
||||
<section id="pagePermissions">
|
||||
<br/>
|
||||
<label for="action">${i18n().page_select_permission}</label>
|
||||
|
||||
<select id="action" name="action">
|
||||
<option value="">${i18n().page_select_permission_option}</option>
|
||||
<#list pageAvailablePermissionsURIsList as permissionURI>
|
||||
|
@ -176,6 +179,7 @@
|
|||
browseClassGroup: '${i18n().browse_class_group}',
|
||||
fixedHtml: '${i18n().fixed_html}',
|
||||
sparqlResults: '${i18n().sparql_query_results}',
|
||||
solrIndividuals: '${i18n().solr_individual_results}',
|
||||
orString: '${i18n().or}',
|
||||
deleteString: '${i18n().delete}',
|
||||
allCapitalized: '${i18n().all_capitalized}',
|
||||
|
|
|
@ -123,16 +123,21 @@ name will be used as the label. -->
|
|||
</#macro>
|
||||
|
||||
<#macro addLink property editable label="${property.name}">
|
||||
<#if property.rangeUri?? >
|
||||
<#local rangeUri = property.rangeUri />
|
||||
<#else>
|
||||
<#local rangeUri = "" />
|
||||
</#if>
|
||||
<#if editable>
|
||||
<#local url = property.addUrl>
|
||||
<#if url?has_content>
|
||||
<@showAddLink property.localName property.name label url />
|
||||
<@showAddLink property.localName label url rangeUri/>
|
||||
</#if>
|
||||
</#if>
|
||||
</#macro>
|
||||
|
||||
<#macro showAddLink propertyLocalName propertyName label url>
|
||||
<#if propertyName == "authors" || propertyName == "webpage" || propertyLocalName == "hasResearchArea">
|
||||
<#macro showAddLink propertyLocalName label url rangeUri>
|
||||
<#if rangeUri?contains("Authorship") || rangeUri?contains("URL") || rangeUri?contains("Editorship") || label == "hasResearchArea">
|
||||
<a class="add-${propertyLocalName}" href="${url}" title="${i18n().manage_list_of} ${label?lower_case}">
|
||||
<img class="add-individual" src="${urls.images}/individual/manage-icon.png" alt="${i18n().manage}" /></a>
|
||||
<#else>
|
||||
|
@ -147,17 +152,23 @@ name will be used as the label. -->
|
|||
|
||||
|
||||
<#macro propertyListItem property statement editable >
|
||||
<#if property.rangeUri?? >
|
||||
<#local rangeUri = property.rangeUri />
|
||||
<#else>
|
||||
<#local rangeUri = "" />
|
||||
</#if>
|
||||
<li role="listitem">
|
||||
<#nested>
|
||||
<@editingLinks "${property.localName}" "${property.name}" statement editable/>
|
||||
<@editingLinks "${property.localName}" "${property.name}" statement editable rangeUri/>
|
||||
</li>
|
||||
</#macro>
|
||||
|
||||
<#macro editingLinks propertyLocalName propertyName statement editable>
|
||||
<#if editable && (propertyName != "authors" && propertyName != "webpage" && propertyLocalName != "hasResearchArea")>
|
||||
<#macro editingLinks propertyLocalName propertyName statement editable rangeUri="">
|
||||
<#if editable >
|
||||
<#if (!rangeUri?contains("Authorship") && !rangeUri?contains("URL") && !rangeUri?contains("Editorship") && propertyLocalName != "hasResearchArea")>
|
||||
<@editLink propertyLocalName propertyName statement />
|
||||
<@deleteLink propertyLocalName propertyName statement />
|
||||
|
||||
</#if>
|
||||
</#if>
|
||||
</#macro>
|
||||
<#macro editLink propertyLocalName propertyName statement>
|
||||
|
@ -250,7 +261,7 @@ name will be used as the label. -->
|
|||
<#local label = individual.nameStatement>
|
||||
${label.value}
|
||||
<#if useEditLink>
|
||||
<@editingLinks "label" "" label editable />
|
||||
<@editingLinks "label" "" label editable ""/>
|
||||
<#elseif (editable && (labelCount > 0)) || (languageCount > 1)>
|
||||
<#--We display the link even when the user is not logged in case of multiple labels with different languages-->
|
||||
<#assign labelLink = ""/>
|
||||
|
|
Loading…
Add table
Reference in a new issue