union domains on data property pages
This commit is contained in:
parent
8ab6d229a6
commit
89d4fc9228
6 changed files with 81 additions and 19 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,15 +105,22 @@ 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) {
|
||||||
|
VClass domainClass = vcDao.getVClassByURI(pLangNeut.getDomainVClassURI());
|
||||||
|
VClass domainWLang = vcDaoWLang.getVClassByURI(pLangNeut.getDomainVClassURI());
|
||||||
|
if (domainClass != null && domainClass.getURI() != null && domainClass.getPickListName() != null) {
|
||||||
try {
|
try {
|
||||||
VClass domainClass = getWebappDaoFactory().getVClassDao().getVClassByURI(dp.getDomainClassURI());
|
if (domainClass.isAnonymous()) {
|
||||||
String domainLinkAnchor = (domainClass != null) ? domainClass.getPickListName() : dp.getDomainClassURI();
|
domainStr = domainClass.getPickListName();
|
||||||
domainStr = (dp.getDomainClassURI() == null) ? "" : "<a href=\"vclassEdit?uri="+URLEncoder.encode(dp.getDomainClassURI(),"UTF-8")+"\">"+domainLinkAnchor+"</a>";
|
} else {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
results.add(domainStr); // column 6
|
results.add(domainStr); // column 6
|
||||||
|
|
||||||
String rangeStr = (dp.getRangeDatatypeURI() == null) ? "<i>untyped</i> (rdfs:Literal)" : dp.getRangeDatatypeURI();
|
String rangeStr = (dp.getRangeDatatypeURI() == null) ? "<i>untyped</i> (rdfs:Literal)" : dp.getRangeDatatypeURI();
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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();
|
||||||
|
|
Loading…
Add table
Reference in a new issue