Merge branch 'maint-rel-1.6' into develop

This commit is contained in:
hudajkhan 2013-12-05 16:21:34 -05:00
commit 05be6f36bc
22 changed files with 420 additions and 204 deletions

View file

@ -71,6 +71,11 @@ public class DataProperty extends Property implements Comparable<DataProperty>,
return domainClassURI; return domainClassURI;
} }
@Override
public String getDomainVClassURI() {
return domainClassURI;
}
public void setDomainClassURI(String domainClassURI) { public void setDomainClassURI(String domainClassURI) {
this.domainClassURI = domainClassURI; this.domainClassURI = domainClassURI;
} }

View file

@ -28,6 +28,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
public class DatapropEditController extends BaseEditController { public class DatapropEditController extends BaseEditController {
@ -45,7 +46,13 @@ public class DatapropEditController extends BaseEditController {
String datapropURI = request.getParameter("uri"); String datapropURI = request.getParameter("uri");
DataPropertyDao dpDao = vreq.getUnfilteredWebappDaoFactory().getDataPropertyDao(); DataPropertyDao dpDao = vreq.getUnfilteredWebappDaoFactory().getDataPropertyDao();
DataPropertyDao dpDaoLangNeut = vreq.getLanguageNeutralWebappDaoFactory().getDataPropertyDao();
VClassDao vcDao = vreq.getLanguageNeutralWebappDaoFactory().getVClassDao();
VClassDao vcDaoWLang = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
DataProperty dp = dpDao.getDataPropertyByURI(datapropURI); DataProperty dp = dpDao.getDataPropertyByURI(datapropURI);
DataProperty pLangNeut = dpDaoLangNeut.getDataPropertyByURI(request.getParameter("uri"));
PropertyGroupDao pgDao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao(); PropertyGroupDao pgDao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao();
ArrayList results = new ArrayList(); ArrayList results = new ArrayList();
@ -98,14 +105,21 @@ public class DatapropEditController extends BaseEditController {
//String parentPropertyStr = "<i>(datatype properties are not yet modeled in a property hierarchy)</i>"; // TODO - need multiple inheritance //String parentPropertyStr = "<i>(datatype properties are not yet modeled in a property hierarchy)</i>"; // TODO - need multiple inheritance
//results.add(parentPropertyStr); //results.add(parentPropertyStr);
// TODO - need unionOf/intersectionOf-style domains for domain class String domainStr = "";
String domainStr=""; if (pLangNeut.getDomainVClassURI() != null) {
try { VClass domainClass = vcDao.getVClassByURI(pLangNeut.getDomainVClassURI());
VClass domainClass = getWebappDaoFactory().getVClassDao().getVClassByURI(dp.getDomainClassURI()); VClass domainWLang = vcDaoWLang.getVClassByURI(pLangNeut.getDomainVClassURI());
String domainLinkAnchor = (domainClass != null) ? domainClass.getPickListName() : dp.getDomainClassURI(); if (domainClass != null && domainClass.getURI() != null && domainClass.getPickListName() != null) {
domainStr = (dp.getDomainClassURI() == null) ? "" : "<a href=\"vclassEdit?uri="+URLEncoder.encode(dp.getDomainClassURI(),"UTF-8")+"\">"+domainLinkAnchor+"</a>"; try {
} catch (UnsupportedEncodingException e) { if (domainClass.isAnonymous()) {
log.error(e, e); domainStr = domainClass.getPickListName();
} else {
domainStr = "<a href=\"vclassEdit?uri="+URLEncoder.encode(domainClass.getURI(),"UTF-8")+"\">"+domainWLang.getPickListName()+"</a>";
}
} catch (UnsupportedEncodingException e) {
log.error(e, e);
}
}
} }
results.add(domainStr); // column 6 results.add(domainStr); // column 6

View file

@ -27,6 +27,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers; import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
@ -47,10 +48,12 @@ public class PropertyEditController extends BaseEditController {
VitroRequest vreq = new VitroRequest(request); VitroRequest vreq = new VitroRequest(request);
ObjectPropertyDao propDao = vreq.getUnfilteredWebappDaoFactory().getObjectPropertyDao(); ObjectPropertyDao propDao = vreq.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
VClassDao vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao(); ObjectPropertyDao propDaoLangNeut = vreq.getLanguageNeutralWebappDaoFactory().getObjectPropertyDao();
VClassDao vcDao = vreq.getLanguageNeutralWebappDaoFactory().getVClassDao();
VClassDao vcDaoWLang = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
PropertyGroupDao pgDao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao(); PropertyGroupDao pgDao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao();
DataPropertyDao dpDao = vreq.getUnfilteredWebappDaoFactory().getDataPropertyDao(); ObjectProperty p = propDao.getObjectPropertyByURI(request.getParameter("uri"));
ObjectProperty p = (ObjectProperty)propDao.getObjectPropertyByURI(request.getParameter("uri")); ObjectProperty pLangNeut = propDaoLangNeut.getObjectPropertyByURI(request.getParameter("uri"));
request.setAttribute("property",p); request.setAttribute("property",p);
ArrayList<String> results = new ArrayList<String>(); ArrayList<String> results = new ArrayList<String>();
@ -119,14 +122,15 @@ public class PropertyEditController extends BaseEditController {
results.add(p.getDomainPublic() == null ? "(no public label)" : p.getDomainPublic()); // column 6 results.add(p.getDomainPublic() == null ? "(no public label)" : p.getDomainPublic()); // column 6
String domainStr = ""; String domainStr = "";
if (p.getDomainVClassURI() != null) { if (pLangNeut.getDomainVClassURI() != null) {
VClass domainClass = vcDao.getVClassByURI(p.getDomainVClassURI()); VClass domainClass = vcDao.getVClassByURI(pLangNeut.getDomainVClassURI());
VClass domainWLang = vcDaoWLang.getVClassByURI(pLangNeut.getDomainVClassURI());
if (domainClass != null && domainClass.getURI() != null && domainClass.getPickListName() != null) { if (domainClass != null && domainClass.getURI() != null && domainClass.getPickListName() != null) {
try { try {
if (domainClass.isAnonymous()) { if (domainClass.isAnonymous()) {
domainStr = domainClass.getPickListName(); domainStr = domainClass.getPickListName();
} else { } else {
domainStr = "<a href=\"vclassEdit?uri="+URLEncoder.encode(domainClass.getURI(),"UTF-8")+"\">"+domainClass.getPickListName()+"</a>"; domainStr = "<a href=\"vclassEdit?uri="+URLEncoder.encode(domainClass.getURI(),"UTF-8")+"\">"+domainWLang.getPickListName()+"</a>";
} }
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
log.error(e, e); log.error(e, e);
@ -136,14 +140,15 @@ public class PropertyEditController extends BaseEditController {
results.add(domainStr); // column 7 results.add(domainStr); // column 7
String rangeStr = ""; String rangeStr = "";
if (p.getRangeVClassURI() != null) { if (pLangNeut.getRangeVClassURI() != null) {
VClass rangeClass = vcDao.getVClassByURI(p.getRangeVClassURI()); VClass rangeClass = vcDao.getVClassByURI(pLangNeut.getRangeVClassURI());
VClass rangeWLang = vcDaoWLang.getVClassByURI(pLangNeut.getRangeVClassURI());
if (rangeClass != null && rangeClass.getURI() != null && rangeClass.getPickListName() != null) { if (rangeClass != null && rangeClass.getURI() != null && rangeClass.getPickListName() != null) {
try { try {
if (rangeClass.isAnonymous()) { if (rangeClass.isAnonymous()) {
rangeStr = rangeClass.getPickListName(); rangeStr = rangeClass.getPickListName();
} else { } else {
rangeStr = "<a href=\"vclassEdit?uri="+URLEncoder.encode(rangeClass.getURI(),"UTF-8")+"\">"+rangeClass.getPickListName()+"</a>"; rangeStr = "<a href=\"vclassEdit?uri="+URLEncoder.encode(rangeClass.getURI(),"UTF-8")+"\">"+rangeWLang.getPickListName()+"</a>";
} }
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
log.error(e, e); log.error(e, e);

View file

@ -20,6 +20,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty; import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Datatype; import edu.cornell.mannlib.vitro.webapp.beans.Datatype;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup; import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
@ -57,7 +58,9 @@ public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
String ontologyUri = vreq.getParameter("ontologyUri"); String ontologyUri = vreq.getParameter("ontologyUri");
DataPropertyDao dao = vreq.getUnfilteredWebappDaoFactory().getDataPropertyDao(); DataPropertyDao dao = vreq.getUnfilteredWebappDaoFactory().getDataPropertyDao();
DataPropertyDao dpDaoLangNeut = vreq.getLanguageNeutralWebappDaoFactory().getDataPropertyDao();
VClassDao vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao(); VClassDao vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
VClassDao vcDaoLangNeut = vreq.getLanguageNeutralWebappDaoFactory().getVClassDao();
DatatypeDao dDao = vreq.getUnfilteredWebappDaoFactory().getDatatypeDao(); DatatypeDao dDao = vreq.getUnfilteredWebappDaoFactory().getDatatypeDao();
PropertyGroupDao pgDao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao(); PropertyGroupDao pgDao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao();
@ -132,8 +135,11 @@ public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
} }
} }
*/ */
VClass vc = (prop.getDomainClassURI() != null) ? vcDao.getVClassByURI(prop.getDomainClassURI()) : null; DataProperty dpLangNeut = dpDaoLangNeut.getDataPropertyByURI(prop.getURI());
String domainStr = (vc != null) ? vc.getPickListName() : ""; if(dpLangNeut == null) {
dpLangNeut = prop;
}
String domainStr = getVClassNameFromURI(dpLangNeut.getDomainVClassURI(), vcDao, vcDaoLangNeut);
json += "\"domainVClass\": " + JSONUtils.quote(domainStr) + ", " ; json += "\"domainVClass\": " + JSONUtils.quote(domainStr) + ", " ;
Datatype rangeDatatype = dDao.getDatatypeByURI(prop.getRangeDatatypeURI()); Datatype rangeDatatype = dDao.getDatatypeByURI(prop.getRangeDatatypeURI());
@ -156,4 +162,20 @@ public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
} }
return new TemplateResponseValues(TEMPLATE_NAME, body); return new TemplateResponseValues(TEMPLATE_NAME, body);
} }
private String getVClassNameFromURI(String vclassURI, VClassDao vcDao, VClassDao vcDaoLangNeut) {
if(vclassURI == null) {
return "";
}
VClass vclass = vcDaoLangNeut.getVClassByURI(vclassURI);
if(vclass == null) {
return "";
}
if(vclass.isAnonymous()) {
return vclass.getPickListName();
} else {
VClass vclassWLang = vcDao.getVClassByURI(vclassURI);
return (vclassWLang != null) ? vclassWLang.getPickListName() : vclass.getPickListName();
}
}
} }

View file

@ -59,8 +59,10 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
String ontologyUri = vreq.getParameter("ontologyUri"); String ontologyUri = vreq.getParameter("ontologyUri");
ObjectPropertyDao dao = vreq.getUnfilteredWebappDaoFactory().getObjectPropertyDao(); ObjectPropertyDao dao = vreq.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
ObjectPropertyDao opDaoLangNeut = vreq.getLanguageNeutralWebappDaoFactory().getObjectPropertyDao();
PropertyInstanceDao piDao = vreq.getLanguageNeutralWebappDaoFactory().getPropertyInstanceDao(); PropertyInstanceDao piDao = vreq.getLanguageNeutralWebappDaoFactory().getPropertyInstanceDao();
VClassDao vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao(); VClassDao vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
VClassDao vcDaoLangNeut = vreq.getLanguageNeutralWebappDaoFactory().getVClassDao();
PropertyGroupDao pgDao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao(); PropertyGroupDao pgDao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao();
String vclassURI = vreq.getParameter("vclassUri"); String vclassURI = vreq.getParameter("vclassUri");
@ -160,12 +162,14 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
json += "\"data\": { \"internalName\": " + JSONUtils.quote(prop.getLocalNameWithPrefix()) + ", "; json += "\"data\": { \"internalName\": " + JSONUtils.quote(prop.getLocalNameWithPrefix()) + ", ";
VClass vc = (prop.getDomainVClassURI() != null) ? vcDao.getVClassByURI(prop.getDomainVClassURI()) : null; ObjectProperty opLangNeut = opDaoLangNeut.getObjectPropertyByURI(prop.getURI());
String domainStr = (vc != null) ? vc.getPickListName() : ""; if(opLangNeut == null) {
opLangNeut = prop;
}
String domainStr = getVClassNameFromURI(opLangNeut.getDomainVClassURI(), vcDao, vcDaoLangNeut);
json += "\"domainVClass\": " + JSONUtils.quote(domainStr) + ", " ; json += "\"domainVClass\": " + JSONUtils.quote(domainStr) + ", " ;
vc = (prop.getRangeVClassURI() != null) ? vcDao.getVClassByURI(prop.getRangeVClassURI()) : null; String rangeStr = getVClassNameFromURI(opLangNeut.getRangeVClassURI(), vcDao, vcDaoLangNeut);
String rangeStr = (vc != null) ? vc.getPickListName() : "";
json += "\"rangeVClass\": " + JSONUtils.quote(rangeStr) + ", " ; json += "\"rangeVClass\": " + JSONUtils.quote(rangeStr) + ", " ;
if (prop.getGroupURI() != null) { if (prop.getGroupURI() != null) {
@ -186,4 +190,20 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
return new TemplateResponseValues(TEMPLATE_NAME, body); return new TemplateResponseValues(TEMPLATE_NAME, body);
} }
private String getVClassNameFromURI(String vclassURI, VClassDao vcDao, VClassDao vcDaoLangNeut) {
if(vclassURI == null) {
return "";
}
VClass vclass = vcDaoLangNeut.getVClassByURI(vclassURI);
if(vclass == null) {
return "";
}
if(vclass.isAnonymous()) {
return vclass.getPickListName();
} else {
VClass vclassWLang = vcDao.getVClassByURI(vclassURI);
return (vclassWLang != null) ? vclassWLang.getPickListName() : vclass.getPickListName();
}
}
} }

View file

@ -21,6 +21,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty; import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Datatype; import edu.cornell.mannlib.vitro.webapp.beans.Datatype;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup; import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
@ -40,7 +41,9 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
private int MAXDEPTH = 5; private int MAXDEPTH = 5;
private DataPropertyDao dpDao = null; private DataPropertyDao dpDao = null;
private DataPropertyDao dpDaoLangNeut = null;
private VClassDao vcDao = null; private VClassDao vcDao = null;
private VClassDao vcDaoLangNeut = null;
private PropertyGroupDao pgDao = null; private PropertyGroupDao pgDao = null;
private DatatypeDao dDao = null; private DatatypeDao dDao = null;
@ -77,7 +80,9 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
body.put("propertyType", "data"); body.put("propertyType", "data");
dpDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getDataPropertyDao(); dpDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getDataPropertyDao();
dpDaoLangNeut = vreq.getLanguageNeutralWebappDaoFactory().getDataPropertyDao();
vcDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getVClassDao(); vcDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getVClassDao();
vcDaoLangNeut = vreq.getLanguageNeutralWebappDaoFactory().getVClassDao();
pgDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getPropertyGroupDao(); pgDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getPropertyGroupDao();
dDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getDatatypeDao(); dDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getDatatypeDao();
@ -217,15 +222,14 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
tempString += "\"data\": { \"internalName\": " + JSONUtils.quote( tempString += "\"data\": { \"internalName\": " + JSONUtils.quote(
dp.getPickListName()) + ", "; dp.getPickListName()) + ", ";
VClass tmp = null; DataProperty dpLangNeut = dpDaoLangNeut.getDataPropertyByURI(dp.getURI());
if(dpLangNeut == null) {
dpLangNeut = dp;
}
String domainStr = getVClassNameFromURI(dpLangNeut.getDomainVClassURI(), vcDao, vcDaoLangNeut);
try { try {
tempString += "\"domainVClass\": " + JSONUtils.quote( tempString += "\"domainVClass\": " + JSONUtils.quote(domainStr) + ", " ;
((tmp = vcDao.getVClassByURI(dp.getDomainClassURI())) != null
&& (tmp.getPickListName() == null))
? ""
: vcDao.getVClassByURI(
dp.getDomainClassURI())
.getPickListName()) + ", " ;
} catch (NullPointerException e) { } catch (NullPointerException e) {
tempString += "\"domainVClass\": \"\","; tempString += "\"domainVClass\": \"\",";
} }
@ -249,4 +253,20 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
return tempString; return tempString;
} }
private String getVClassNameFromURI(String vclassURI, VClassDao vcDao, VClassDao vcDaoLangNeut) {
if(vclassURI == null) {
return "";
}
VClass vclass = vcDaoLangNeut.getVClassByURI(vclassURI);
if(vclass == null) {
return "";
}
if(vclass.isAnonymous()) {
return vclass.getPickListName();
} else {
VClass vclassWLang = vcDao.getVClassByURI(vclassURI);
return (vclassWLang != null) ? vclassWLang.getPickListName() : vclass.getPickListName();
}
}
} }

View file

@ -39,7 +39,9 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
private int MAXDEPTH = 5; private int MAXDEPTH = 5;
private ObjectPropertyDao opDao = null; private ObjectPropertyDao opDao = null;
private ObjectPropertyDao opDaoLangNeut = null;
private VClassDao vcDao = null; private VClassDao vcDao = null;
private VClassDao vcDaoLangNeut = null;
private PropertyGroupDao pgDao = null; private PropertyGroupDao pgDao = null;
private int previous_posn = 0; private int previous_posn = 0;
@ -75,7 +77,9 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
body.put("propertyType", "object"); body.put("propertyType", "object");
opDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getObjectPropertyDao(); opDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getObjectPropertyDao();
opDaoLangNeut = vreq.getLanguageNeutralWebappDaoFactory().getObjectPropertyDao();
vcDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getVClassDao(); vcDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getVClassDao();
vcDaoLangNeut = vreq.getLanguageNeutralWebappDaoFactory().getVClassDao();
pgDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getPropertyGroupDao(); pgDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getPropertyGroupDao();
String json = new String(); String json = new String();
@ -213,29 +217,20 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
tempString += "\"data\": { \"internalName\": " + JSONUtils.quote( tempString += "\"data\": { \"internalName\": " + JSONUtils.quote(
op.getLocalNameWithPrefix()) + ", "; op.getLocalNameWithPrefix()) + ", ";
VClass tmp = null; ObjectProperty opLangNeut = opDaoLangNeut.getObjectPropertyByURI(op.getURI());
if(opLangNeut == null) {
opLangNeut = op;
}
String domainStr = getVClassNameFromURI(opLangNeut.getDomainVClassURI(), vcDao, vcDaoLangNeut);
String rangeStr = getVClassNameFromURI(opLangNeut.getRangeVClassURI(), vcDao, vcDaoLangNeut);
try { try {
tempString += "\"domainVClass\": " + JSONUtils.quote( tempString += "\"domainVClass\": " + JSONUtils.quote(domainStr) + ", " ;
((tmp = vcDao.getVClassByURI(
op.getDomainVClassURI())) != null
&& (tmp.getPickListName() == null))
? ""
: vcDao.getVClassByURI(
op.getDomainVClassURI())
.getPickListName()) + ", " ;
} catch (NullPointerException e) { } catch (NullPointerException e) {
tempString += "\"domainVClass\": \"\","; tempString += "\"domainVClass\": \"\",";
} }
try { try {
tempString += "\"rangeVClass\": " + JSONUtils.quote( tempString += "\"rangeVClass\": " + JSONUtils.quote(rangeStr) + ", " ;
((tmp = vcDao.getVClassByURI(
op.getRangeVClassURI())) != null
&& (tmp.getPickListName() == null))
? ""
: vcDao.getVClassByURI(
op.getRangeVClassURI())
.getPickListName()) + ", " ;
} catch (NullPointerException e) { } catch (NullPointerException e) {
tempString += "\"rangeVClass\": \"\","; tempString += "\"rangeVClass\": \"\",";
} }
@ -253,6 +248,22 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
return tempString; return tempString;
} }
private String getVClassNameFromURI(String vclassURI, VClassDao vcDao, VClassDao vcDaoLangNeut) {
if(vclassURI == null) {
return "";
}
VClass vclass = vcDaoLangNeut.getVClassByURI(vclassURI);
if(vclass == null) {
return "";
}
if(vclass.isAnonymous()) {
return vclass.getPickListName();
} else {
VClass vclassWLang = vcDao.getVClassByURI(vclassURI);
return (vclassWLang != null) ? vclassWLang.getPickListName() : vclass.getPickListName();
}
}
public static class ObjectPropertyAlphaComparator implements Comparator<ObjectProperty> { public static class ObjectPropertyAlphaComparator implements Comparator<ObjectProperty> {
Collator collator; Collator collator;

View file

@ -183,7 +183,7 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
dp.setPickListName(getWebappDaoFactory().makePickListName(dp)); dp.setPickListName(getWebappDaoFactory().makePickListName(dp));
Resource dRes = op.getDomain(); Resource dRes = op.getDomain();
if (dRes != null) { if (dRes != null) {
dp.setDomainClassURI(dRes.getURI()); dp.setDomainClassURI(dRes.isAnon()? PSEUDO_BNODE_NS + dRes.getId().toString() : dRes.getURI());
} }
Resource rRes = op.getRange(); Resource rRes = op.getRange();
if (rRes != null) { if (rRes != null) {

View file

@ -192,6 +192,7 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
return getLabelOrId(cls); return getLabelOrId(cls);
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e, e);
return "???"; return "???";
} finally { } finally {
cls.getModel().leaveCriticalSection(); cls.getModel().leaveCriticalSection();

View file

@ -107,6 +107,9 @@ public class ABoxRecomputer {
} }
} }
// don't check for existing inferences in the rebuild model
private boolean DO_CHECK = true;
/* /*
* Recompute the entire ABox inference graph. The new * Recompute the entire ABox inference graph. The new
* inference graph is built in a separate model and * inference graph is built in a separate model and
@ -132,11 +135,13 @@ public class ABoxRecomputer {
log.info("Recomputing inferences for " + individuals.size() + " individuals"); log.info("Recomputing inferences for " + individuals.size() + " individuals");
long start = System.currentTimeMillis();
for (String individualURI : individuals) { for (String individualURI : individuals) {
Resource individual = ResourceFactory.createResource(individualURI); Resource individual = ResourceFactory.createResource(individualURI);
try { try {
addedABoxTypeAssertion(individual, inferenceRebuildModel, unknownTypes); addedABoxTypeAssertion(individual, inferenceRebuildModel, unknownTypes, DO_CHECK);
simpleReasoner.setMostSpecificTypes(individual, inferenceRebuildModel, unknownTypes); simpleReasoner.setMostSpecificTypes(individual, inferenceRebuildModel, unknownTypes);
List<ReasonerPlugin> pluginList = simpleReasoner.getPluginList(); List<ReasonerPlugin> pluginList = simpleReasoner.getPluginList();
if (pluginList.size() > 0) { if (pluginList.size() > 0) {
@ -165,8 +170,11 @@ public class ABoxRecomputer {
} }
numStmts++; numStmts++;
if ((numStmts % 10000) == 0) { if ((numStmts % 1000) == 0) {
log.info("Still computing class subsumption ABox inferences..."); log.info("Still computing class subsumption ABox inferences ("
+ numStmts + "/" + individuals.size() + " individuals)");
log.info((System.currentTimeMillis() - start) / 1000 + " ms per individual");
start = System.currentTimeMillis();
} }
if (stopRequested) { if (stopRequested) {
@ -275,7 +283,7 @@ public class ABoxRecomputer {
log.info("Finished computing sameAs ABox inferences"); log.info("Finished computing sameAs ABox inferences");
try { try {
if (updateInferenceModel(inferenceRebuildModel)) { if (updateInferenceModel(inferenceRebuildModel, individuals)) {
log.info("a stopRequested signal was received during updateInferenceModel. Halting Processing."); log.info("a stopRequested signal was received during updateInferenceModel. Halting Processing.");
return; return;
} }
@ -366,7 +374,13 @@ public class ABoxRecomputer {
} }
protected void addedABoxTypeAssertion(Resource individual, Model inferenceModel, HashSet<String> unknownTypes) { protected void addedABoxTypeAssertion(Resource individual, Model inferenceModel,
HashSet<String> unknownTypes) {
addedABoxTypeAssertion(individual, inferenceModel, unknownTypes, true);
}
protected void addedABoxTypeAssertion(Resource individual, Model inferenceModel,
HashSet<String> unknownTypes, boolean checkRedundancy) {
StmtIterator iter = null; StmtIterator iter = null;
@ -376,7 +390,8 @@ public class ABoxRecomputer {
while (iter.hasNext()) { while (iter.hasNext()) {
Statement stmt = iter.next(); Statement stmt = iter.next();
simpleReasoner.addedABoxTypeAssertion(stmt, inferenceModel, unknownTypes); simpleReasoner.addedABoxTypeAssertion(
stmt, inferenceModel, unknownTypes, checkRedundancy);
} }
} finally { } finally {
if (iter != null) { if (iter != null) {
@ -388,125 +403,72 @@ public class ABoxRecomputer {
/* /*
* reconcile a set of inferences into the application inference model * reconcile a set of inferences into the application inference model
*/ */
protected boolean updateInferenceModel(Model inferenceRebuildModel) { protected boolean updateInferenceModel(Model inferenceRebuildModel,
Collection<String> individuals) {
log.info("Updating ABox inference model"); log.info("Updating ABox inference model");
Iterator<Statement> iter = null;
// Remove everything from the current inference model that is not // Remove everything from the current inference model that is not
// in the recomputed inference model // in the recomputed inference model
int num = 0; int num = 0;
scratchpadModel.enterCriticalSection(Lock.WRITE); scratchpadModel.enterCriticalSection(Lock.WRITE);
scratchpadModel.removeAll(); scratchpadModel.removeAll();
log.info("Updating ABox inference model (checking for outdated inferences)"); Model rebuild = ModelFactory.createDefaultModel();
try { Model existing = ModelFactory.createDefaultModel();
inferenceModel.enterCriticalSection(Lock.READ);
try { long start = System.currentTimeMillis();
iter = listModelStatements(inferenceModel, JenaDataSourceSetupBase.JENA_INF_MODEL);
while (iter.hasNext()) {
Statement stmt = iter.next();
if (!inferenceRebuildModel.contains(stmt)) {
scratchpadModel.add(stmt);
}
num++; for (String individualURI : individuals) {
if ((num % 10000) == 0) { rebuild.removeAll();
log.info("Still updating ABox inference model (checking for outdated inferences)..."); existing.removeAll();
} Resource subjInd = ResourceFactory.createResource(individualURI);
inferenceModel.enterCriticalSection(Lock.READ);
try {
existing.add(inferenceModel.listStatements(subjInd, null, (RDFNode) null));
} finally {
inferenceModel.leaveCriticalSection();
}
inferenceRebuildModel.enterCriticalSection(Lock.READ);
try {
rebuild.add(inferenceRebuildModel.listStatements(subjInd, null, (RDFNode) null));
} finally {
inferenceRebuildModel.leaveCriticalSection();
}
if (stopRequested) { Model retractions = existing.difference(rebuild);
return true; Model additions = rebuild.difference(existing);
}
}
} finally {
// if (iter != null) {
// iter.close();
// }
inferenceModel.leaveCriticalSection();
}
try { inferenceModel.enterCriticalSection(Lock.WRITE);
iter = listModelStatements(scratchpadModel, SimpleReasonerSetup.JENA_INF_MODEL_SCRATCHPAD); try {
while (iter.hasNext()) { inferenceModel.remove(retractions);
Statement stmt = iter.next(); inferenceModel.add(additions);
} finally {
inferenceModel.leaveCriticalSection();
}
// skip statements with blank nodes to avoid excessive deletion inferenceRebuildModel.enterCriticalSection(Lock.WRITE);
if (stmt.getSubject().isAnon() || stmt.getObject().isAnon()) { try {
continue; inferenceRebuildModel.remove(rebuild);
} } finally {
inferenceRebuildModel.leaveCriticalSection();
}
inferenceModel.enterCriticalSection(Lock.WRITE); num++;
try { if ((num % 1000) == 0) {
inferenceModel.remove(stmt); log.info("Still updating ABox inference model (" +
} finally { + num + "/" + individuals.size() + " individuals)");
inferenceModel.leaveCriticalSection(); log.info((System.currentTimeMillis() - start) / 1000 + " ms per individual");
} start = System.currentTimeMillis();
} }
} finally {
// if (iter != null) {
// iter.close();
// }
}
// Add everything from the recomputed inference model that is not already if (stopRequested) {
// in the current inference model to the current inference model. return true;
try { }
scratchpadModel.removeAll();
log.info("Updating ABox inference model (adding any new inferences)");
iter = listModelStatements(inferenceRebuildModel, SimpleReasonerSetup.JENA_INF_MODEL_REBUILD);
while (iter.hasNext()) { }
Statement stmt = iter.next();
inferenceModel.enterCriticalSection(Lock.READ); log.info("ABox inference model updated");
try { return false;
if (!inferenceModel.contains(stmt)) {
scratchpadModel.add(stmt);
}
} finally {
inferenceModel.leaveCriticalSection();
}
num++;
if ((num % 10000) == 0) {
log.info("Still updating ABox inference model (adding any new inferences)...");
}
if (stopRequested) {
return true;
}
}
} finally {
// if (iter != null) {
// iter.close();
// }
}
iter = listModelStatements(scratchpadModel, SimpleReasonerSetup.JENA_INF_MODEL_SCRATCHPAD);
try {
while (iter.hasNext()) {
Statement stmt = iter.next();
inferenceModel.enterCriticalSection(Lock.WRITE);
try {
inferenceModel.add(stmt);
} finally {
inferenceModel.leaveCriticalSection();
}
}
} finally {
// if (iter != null) {
// iter.close();
// }
}
} finally {
scratchpadModel.removeAll();
scratchpadModel.leaveCriticalSection();
}
log.info("ABox inference model updated");
return false;
} }
private Iterator<Statement> listModelStatements(Model model, String graphURI) { private Iterator<Statement> listModelStatements(Model model, String graphURI) {

View file

@ -12,6 +12,8 @@ public interface ReasonerPlugin {
public boolean isInterestedInRemovedStatement(Statement stmt); public boolean isInterestedInRemovedStatement(Statement stmt);
public boolean isConfigurationOnlyPlugin();
public void addedABoxStatement(Statement stmt, public void addedABoxStatement(Statement stmt,
Model aboxAssertionsModel, Model aboxAssertionsModel,
Model aboxInferencesModel, Model aboxInferencesModel,

View file

@ -162,6 +162,10 @@ public class SimpleReasoner extends StatementListener {
this.doSameAs = tf; this.doSameAs = tf;
} }
public boolean getSameAsEnabled() {
return this.doSameAs;
}
/* /*
* Performs incremental ABox reasoning based * Performs incremental ABox reasoning based
* on the addition of a new statement * on the addition of a new statement
@ -343,6 +347,12 @@ public class SimpleReasoner extends StatementListener {
changedTBoxStatement(stmt, false); changedTBoxStatement(stmt, false);
} }
protected void addedABoxTypeAssertion(Statement stmt,
Model inferenceModel,
HashSet<String> unknownTypes) {
addedABoxTypeAssertion(stmt, inferenceModel, unknownTypes, true);
}
/** /**
* Performs incremental reasoning based on a new type assertion * Performs incremental reasoning based on a new type assertion
* added to the ABox (assertion that an individual is of a certain * added to the ABox (assertion that an individual is of a certain
@ -353,7 +363,8 @@ public class SimpleReasoner extends StatementListener {
*/ */
protected void addedABoxTypeAssertion(Statement stmt, protected void addedABoxTypeAssertion(Statement stmt,
Model inferenceModel, Model inferenceModel,
HashSet<String> unknownTypes) { HashSet<String> unknownTypes,
boolean checkRedundancy) {
tboxModel.enterCriticalSection(Lock.READ); tboxModel.enterCriticalSection(Lock.READ);
try { try {
@ -379,7 +390,7 @@ public class SimpleReasoner extends StatementListener {
Statement infStmt = Statement infStmt =
ResourceFactory.createStatement(stmt.getSubject(), ResourceFactory.createStatement(stmt.getSubject(),
RDF.type, parentClass); RDF.type, parentClass);
addInference(infStmt,inferenceModel,true); addInference(infStmt, inferenceModel, true, checkRedundancy);
} }
} }
} else { } else {
@ -1189,13 +1200,20 @@ public class SimpleReasoner extends StatementListener {
addInference(infStmt,inferenceModel,true); addInference(infStmt,inferenceModel,true);
} }
protected void addInference(Statement infStmt, Model inferenceModel, boolean handleSameAs) { protected void addInference(Statement infStmt, Model inferenceModel,
boolean handleSameAs) {
addInference(infStmt, inferenceModel, handleSameAs, true);
}
protected void addInference(Statement infStmt, Model inferenceModel,
boolean handleSameAs, boolean checkRedundancy) {
aboxModel.enterCriticalSection(Lock.READ); aboxModel.enterCriticalSection(Lock.READ);
try { try {
inferenceModel.enterCriticalSection(Lock.WRITE); inferenceModel.enterCriticalSection(Lock.WRITE);
try { try {
if (!inferenceModel.contains(infStmt) && !aboxModel.contains(infStmt)) { if (!checkRedundancy
|| (!inferenceModel.contains(infStmt) && !aboxModel.contains(infStmt))) {
inferenceModel.add(infStmt); inferenceModel.add(infStmt);
} }
@ -1732,8 +1750,6 @@ public class SimpleReasoner extends StatementListener {
} }
} }
/** /**
* Utility method for logging * Utility method for logging
*/ */

View file

@ -15,7 +15,7 @@ import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasoner;
/** /**
* Disables sameAs in associated SimpleReasoner. * Disables sameAs in associated SimpleReasoner.
*/ */
public abstract class DisableSameAs implements ReasonerPlugin { public class DisableSameAs implements ReasonerPlugin {
private static final Log log = LogFactory.getLog(DisableSameAs.class); private static final Log log = LogFactory.getLog(DisableSameAs.class);
@ -27,6 +27,10 @@ public abstract class DisableSameAs implements ReasonerPlugin {
log.info("owl:sameAs disabled in SimpleReasoner."); log.info("owl:sameAs disabled in SimpleReasoner.");
} }
public boolean isConfigurationOnlyPlugin() {
return true;
}
public SimpleReasoner getSimpleReasoner() { public SimpleReasoner getSimpleReasoner() {
return this.simpleReasoner; return this.simpleReasoner;
} }

View file

@ -62,6 +62,10 @@ public abstract class SimpleBridgingRule implements ReasonerPlugin {
} }
public boolean isConfigurationOnlyPlugin() {
return false;
}
public boolean isInterestedInAddedStatement(Statement stmt) { public boolean isInterestedInAddedStatement(Statement stmt) {
return isRelevantPredicate(stmt); return isRelevantPredicate(stmt);
} }

View file

@ -36,6 +36,10 @@ public abstract class SimplePropertyAndTypeRule implements ReasonerPlugin {
INFERRED_PROP = ResourceFactory.createProperty(inferredProp); INFERRED_PROP = ResourceFactory.createProperty(inferredProp);
} }
public boolean isConfigurationOnlyPlugin() {
return false;
}
public boolean isInterestedInAddedStatement(Statement stmt) { public boolean isInterestedInAddedStatement(Statement stmt) {
return (RDF.type.equals(stmt.getPredicate()) || isRelevantPredicate(stmt)); return (RDF.type.equals(stmt.getPredicate()) || isRelevantPredicate(stmt));
} }

View file

@ -104,7 +104,10 @@ public class SimpleReasonerSetup implements ServletContextListener {
ReasonerPlugin plugin = (ReasonerPlugin) Class.forName( ReasonerPlugin plugin = (ReasonerPlugin) Class.forName(
classname).getConstructors()[0].newInstance(); classname).getConstructors()[0].newInstance();
plugin.setSimpleReasoner(simpleReasoner); plugin.setSimpleReasoner(simpleReasoner);
pluginList.add(plugin); if (!plugin.isConfigurationOnlyPlugin()) {
pluginList.add(plugin);
log.info("adding reasoner plugin " + plugin.getClass().getName());
}
} catch(Throwable t) { } catch(Throwable t) {
ss.info(this, "Could not instantiate reasoner plugin " + classname); ss.info(this, "Could not instantiate reasoner plugin " + classname);
} }

View file

@ -14,6 +14,7 @@ import com.hp.hpl.jena.ontology.OntProperty;
import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.vocabulary.OWL;
import edu.cornell.mannlib.vitro.testing.AbstractTestClass; import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread; import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
@ -431,10 +432,10 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass {
tBox.register(simpleReasonerTBoxListener); tBox.register(simpleReasonerTBoxListener);
// add abox data // add abox data
Resource a = aBox.createResource("http://test.vivo/a"); Resource a = aBox.createIndividual("http://test.vivo/a", OWL.Thing);
Resource b = aBox.createResource("http://test.vivo/b"); Resource b = aBox.createIndividual("http://test.vivo/b", OWL.Thing);
Resource c = aBox.createResource("http://test.vivo/c"); Resource c = aBox.createIndividual("http://test.vivo/c", OWL.Thing);
Resource d = aBox.createResource("http://test.vivo/d"); Resource d = aBox.createIndividual("http://test.vivo/d", OWL.Thing);
aBox.add(a,P,b); aBox.add(a,P,b);
aBox.add(c,P,d); aBox.add(c,P,d);
@ -496,8 +497,8 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass {
tBox.register(simpleReasonerTBoxListener); tBox.register(simpleReasonerTBoxListener);
// add statements to the abox and verify inference // add statements to the abox and verify inference
Resource c = aBox.createResource("http://test.vivo/c"); Resource c = aBox.createIndividual("http://test.vivo/c", OWL.Thing);
Resource d = aBox.createResource("http://test.vivo/d"); Resource d = aBox.createIndividual("http://test.vivo/d", OWL.Thing);
aBox.add(c,P,d); aBox.add(c,P,d);
Assert.assertTrue(inf.contains(d,Q,c)); Assert.assertTrue(inf.contains(d,Q,c));
@ -555,10 +556,10 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass {
aBox.register(simpleReasoner); aBox.register(simpleReasoner);
// abox statements // abox statements
Resource a = aBox.createResource("http://test.vivo/a"); Resource a = aBox.createIndividual("http://test.vivo/a", OWL.Thing);
Resource b = aBox.createResource("http://test.vivo/b"); Resource b = aBox.createIndividual("http://test.vivo/b", OWL.Thing);
Resource c = aBox.createResource("http://test.vivo/c"); Resource c = aBox.createIndividual("http://test.vivo/c", OWL.Thing);
Resource d = aBox.createResource("http://test.vivo/d"); Resource d = aBox.createIndividual("http://test.vivo/d", OWL.Thing);
aBox.add(a,P,b); aBox.add(a,P,b);
aBox.add(c,X,d); aBox.add(c,X,d);

View file

@ -782,10 +782,10 @@ public class SimpleReasonerSameAsTest extends AbstractTestClass {
aBox.register(simpleReasoner); aBox.register(simpleReasoner);
// Individuals a, b, c and d // Individuals a, b, c and d
Resource a = aBox.createResource("http://test.vivo/a"); Resource a = aBox.createIndividual("http://test.vivo/a", OWL.Thing);
Resource b = aBox.createResource("http://test.vivo/b"); Resource b = aBox.createIndividual("http://test.vivo/b", OWL.Thing);
Resource c = aBox.createResource("http://test.vivo/c"); Resource c = aBox.createIndividual("http://test.vivo/c", OWL.Thing);
Resource d = aBox.createResource("http://test.vivo/d"); Resource d = aBox.createIndividual("http://test.vivo/d", OWL.Thing);
aBox.add(a,P,c); aBox.add(a,P,c);
aBox.add(a,S,literal1); aBox.add(a,S,literal1);

View file

@ -697,6 +697,7 @@ select_existing_collaborator = Select an existing Collaborator for {0}
selected = Selected selected = Selected
change_selection = change selection change_selection = change selection
there_are_no_entries_for_selection = There are no entries in the system from which to select. there_are_no_entries_for_selection = There are no entries in the system from which to select.
the_range_class_does_not_exist= The range class for this property does not exist in the system.
editing_prohibited = This property is currently configured to prohibit editing. editing_prohibited = This property is currently configured to prohibit editing.
confirm_entry_deletion_from = Are you sure you want to delete the following entry from confirm_entry_deletion_from = Are you sure you want to delete the following entry from
@ -752,6 +753,7 @@ custom_template_containing_content = Custom template containing all content
a_menu_page = This is a menu page a_menu_page = This is a menu page
menu_item_name = Menu Item Name menu_item_name = Menu Item Name
if_blank_page_title_used = If left blank, the page title will be used. if_blank_page_title_used = If left blank, the page title will be used.
multiple_content_default_template_error = With multiple content types, you must specify a custom template.
label = label label = label
no_classes_to_select = There are no Classes in the system from which to select. no_classes_to_select = There are no Classes in the system from which to select.

View file

@ -205,13 +205,15 @@ var pageManagementUtils = {
//Also clear custom template value so as not to submit it //Also clear custom template value so as not to submit it
pageManagementUtils.clearInputs(pageManagementUtils.customTemplate); pageManagementUtils.clearInputs(pageManagementUtils.customTemplate);
pageManagementUtils.rightSideDiv.show(); pageManagementUtils.rightSideDiv.show();
pageManagementUtils.disablePageSave(); //Check to see if there is already content on page, in which case save should be enabled
var pageContentSections = $("section[class='pageContent']");
if(pageContentSections.length == 0) {
pageManagementUtils.disablePageSave();
}
}); });
this.customTemplateRadio.click( function() { this.customTemplateRadio.click( function() {
pageManagementUtils.customTemplate.removeClass('hidden'); pageManagementUtils.handleSelectCustomTemplate();
pageManagementUtils.rightSideDiv.show();
pageManagementUtils.disablePageSave();
}); });
this.selfContainedTemplateRadio.click( function() { this.selfContainedTemplateRadio.click( function() {
@ -265,6 +267,16 @@ var pageManagementUtils = {
}); });
}, },
handleSelectCustomTemplate: function() {
pageManagementUtils.customTemplate.removeClass('hidden');
pageManagementUtils.rightSideDiv.show();
//Check to see if there is already content on page, in which case save should be enabled
var pageContentSections = $("section[class='pageContent']");
if(pageContentSections.length == 0) {
pageManagementUtils.disablePageSave();
}
},
handleClickDone:function() { handleClickDone:function() {
var selectedType = pageManagementUtils.contentTypeSelect.val(); var selectedType = pageManagementUtils.contentTypeSelect.val();
var selectedTypeText = $("#typeSelect option:selected").text(); var selectedTypeText = $("#typeSelect option:selected").text();
@ -392,6 +404,9 @@ var pageManagementUtils = {
pageManagementUtils.adjustSaveButtonHeight(); pageManagementUtils.adjustSaveButtonHeight();
//Disable save button until the user has clicked done or cancel from the addition //Disable save button until the user has clicked done or cancel from the addition
pageManagementUtils.disablePageSave(); pageManagementUtils.disablePageSave();
//If the default template is selected, there is already content on the page, and the user is selecting new content
//display alert message that they must select a custom template and select
pageManagementUtils.checkTemplateForMultipleContent(_this.contentTypeSelect.val());
}, },
disablePageSave:function() { disablePageSave:function() {
pageManagementUtils.pageSaveButton.attr("disabled", "disabled"); pageManagementUtils.pageSaveButton.attr("disabled", "disabled");
@ -430,6 +445,21 @@ var pageManagementUtils = {
$el.find("select option:eq(0)").attr("selected", "selected"); $el.find("select option:eq(0)").attr("selected", "selected");
}, },
checkTemplateForMultipleContent:function(contentTypeSelected) {
if(contentTypeSelected != "") {
var pageContentSections = $("section[class='pageContent']");
var selectedTemplateValue = $('input:radio[name=selectedTemplate]:checked').val();
//A new section hasn't been added yet so check to see if there is at least one content type already on page
if(selectedTemplateValue == "default" && pageContentSections.length >= 1) {
//alert the user that they should be picking custom template instead
alert(pageManagementUtils.multipleContentWithDefaultTemplateError);
//pick custom template
$('input:radio[name=selectedTemplate][value="custom"]').attr("checked", true);
pageManagementUtils.handleSelectCustomTemplate();
}
}
},
//Clone content area //Clone content area
//When adding a new content type, this function will copy the values from the new content form and generate //When adding a new content type, this function will copy the values from the new content form and generate
//the content for the new section containing the content //the content for the new section containing the content
@ -874,7 +904,12 @@ var pageManagementUtils = {
if(pageContentSections.length == 0) { if(pageContentSections.length == 0) {
validationErrorMsg = pageManagementUtils.selectContentType + " <br /> "; validationErrorMsg = pageManagementUtils.selectContentType + " <br /> ";
} else { } else {
//For each, based on type, validate if a validation function exists //If there are multiple content types, and the default template option is selected, then display error message
var selectedTemplateValue = $('input:radio[name=selectedTemplate]:checked').val();
if(selectedTemplateValue == "default") {
validationErrorMsg += pageManagementUtils.multipleContentWithDefaultTemplateError;
}
//For each, based on type, validate if a validation function exists
$.each(pageContentSections, function(i) { $.each(pageContentSections, function(i) {
if(pageManagementUtils.processDataGetterUtils != null) { if(pageManagementUtils.processDataGetterUtils != null) {
var dataGetterType = pageManagementUtils.processDataGetterUtils.selectDataGetterType($(this)); var dataGetterType = pageManagementUtils.processDataGetterUtils.selectDataGetterType($(this));

View file

@ -0,0 +1,84 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#--This is an example of including multiple content types in the same template, this combines the default templates for Fixed HTML, Class groups and Solr Individuals in one template-->
<#include "menupage-checkForData.ftl">
<#--Fixed HTML portion-->
<#--Note that variableName is employed by both the fixed html and sparql query templates, this is used to store the
actual name of the variable that is used to store either the fixed html or sparql query results. If combining fixed html
and sparql query results in a custom template, the template can utilize the actual variable name e.g. "query results" instead of how
variableName is used below.-->
<#assign htmlExists = false/>
<#if variableName?has_content>
<#assign htmlExists = true />
</#if>
<#if htmlExists>
${.globals[variableName]}
<#else>
${i18n().no_html_specified}
</#if>
<#--Class grou section-->
<#if !noData>
<section id="menupage-intro" role="region">
<h2>${page.title}</h2>
</section>
<#include "menupage-browse.ftl">
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/css/menupage/menupage.css" />')}
<#include "menupage-scripts.ftl">
<#else>
${noDataNotification}
</#if>
<#--Solr Individuals section-->
<#import "lib-list.ftl" as l>
<#include "individualList-checkForData.ftl">
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/css/browseIndex.css" />')}
<section class="individualList">
<h2>${title}
</h2>
<#if subtitle?has_content>
<h4>${subtitle}</h4>
</#if>
<#if (!noData)>
<#if errorMessage?has_content>
<p>${errorMessage}</p>
<#else>
<#assign pagination>
<#if (pages?has_content && pages?size > 1)>
${i18n().pages}:
<ul class="pagination">
<#list pages as page>
<#if page.selected>
<li class="selectedNavPage">${page.text}</li>
<#else>
<#-- RY Ideally the urls would be generated by the controller; see search-pagedResults.ftl -->
<li><a href="${urls.base}/individuallist?${page.param}&vclassId=${vclassId?url}" title="${i18n().page_text}">${page.text}</a></li>
</#if>
</#list>
</ul>
</#if>
</#assign>
${pagination}
<ul>
<#list individuals as individual>
<li>
<@shortView uri=individual.uri viewContext="index" />
</li>
</#list>
</ul>
${pagination}
</#if>
<#else>
${noDataNotification}
</#if>
</section> <!-- .individualList -->

View file

@ -189,7 +189,8 @@
supplyPrettyUrl: '${i18n().supply_url}', supplyPrettyUrl: '${i18n().supply_url}',
startUrlWithSlash: '${i18n().start_url_with_slash}', startUrlWithSlash: '${i18n().start_url_with_slash}',
supplyTemplate: '${i18n().supply_template}', supplyTemplate: '${i18n().supply_template}',
selectContentType: '${i18n().select_content_type}' selectContentType: '${i18n().select_content_type}',
multipleContentWithDefaultTemplateError: '${i18n().multiple_content_default_template_error}'
}; };
</script> </script>