VIVO-623 unión domains and ranges on object property displays
This commit is contained in:
parent
d2792db057
commit
8ab6d229a6
3 changed files with 67 additions and 31 deletions
|
@ -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);
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
@ -212,30 +216,21 @@ 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\": \"\",";
|
||||||
}
|
}
|
||||||
|
@ -252,6 +247,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> {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue