VIVO-723 remove obsolete controller classes.
This commit is contained in:
parent
bc7d827741
commit
761b47827c
7 changed files with 0 additions and 1337 deletions
|
@ -1,248 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.edit.listing;
|
|
||||||
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.servlet.RequestDispatcher;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.vocabulary.OWL;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vedit.beans.ButtonForm;
|
|
||||||
import edu.cornell.mannlib.vedit.controller.BaseEditController;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
|
||||||
|
|
||||||
public class ClassHierarchyListingController extends BaseEditController {
|
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(ClassHierarchyListingController.class.getName());
|
|
||||||
|
|
||||||
private int MAXDEPTH = 7;
|
|
||||||
private int NUM_COLS = 9;
|
|
||||||
|
|
||||||
private VClassDao vcDao = null;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
if (!isAuthorizedToDisplayPage(request, response, SimplePermission.EDIT_ONTOLOGY.ACTIONS)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
VitroRequest vrequest = new VitroRequest(request);
|
|
||||||
|
|
||||||
try {
|
|
||||||
boolean inferred = (vrequest.getParameter("inferred") != null);
|
|
||||||
|
|
||||||
if (!inferred) {
|
|
||||||
vcDao = ModelAccess.on(vrequest).getBaseWebappDaoFactory().getVClassDao();
|
|
||||||
} else {
|
|
||||||
vcDao = vrequest.getUnfilteredWebappDaoFactory().getVClassDao();
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<String> results = new ArrayList<String>();
|
|
||||||
results.add("XX"); // column 1
|
|
||||||
results.add("class"); // column 2
|
|
||||||
results.add("shortdef"); // column 3
|
|
||||||
results.add("example"); // column 4
|
|
||||||
results.add("group"); // column 5
|
|
||||||
results.add("ontology"); // column 6
|
|
||||||
results.add("display level"); // column 7
|
|
||||||
results.add("update level"); // column 8
|
|
||||||
results.add("XX"); // column 9
|
|
||||||
|
|
||||||
String ontologyUri = request.getParameter("ontologyUri");
|
|
||||||
String startClassUri = request.getParameter("vclassUri");
|
|
||||||
|
|
||||||
List<VClass> roots = null;
|
|
||||||
|
|
||||||
if (ontologyUri != null) {
|
|
||||||
roots = vcDao.getOntologyRootClasses(ontologyUri);
|
|
||||||
} else if (startClassUri != null) {
|
|
||||||
roots = new LinkedList<VClass>();
|
|
||||||
roots.add(vcDao.getVClassByURI(startClassUri));
|
|
||||||
} else {
|
|
||||||
roots = vcDao.getRootClasses();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (roots.isEmpty()) {
|
|
||||||
roots = new LinkedList<VClass>();
|
|
||||||
roots.add(vrequest.getUnfilteredWebappDaoFactory().getVClassDao()
|
|
||||||
.getTopConcept());
|
|
||||||
}
|
|
||||||
|
|
||||||
Collections.sort(roots);
|
|
||||||
|
|
||||||
Iterator rootIt = roots.iterator();
|
|
||||||
if (!rootIt.hasNext()) {
|
|
||||||
VClass vcw = new VClass();
|
|
||||||
vcw.setName("<strong>No classes found.</strong>");
|
|
||||||
results.addAll(addVClassDataToResultsList(vrequest.getUnfilteredWebappDaoFactory(), vcw,0,ontologyUri));
|
|
||||||
} else {
|
|
||||||
while (rootIt.hasNext()) {
|
|
||||||
VClass root = (VClass) rootIt.next();
|
|
||||||
if (root != null) {
|
|
||||||
ArrayList childResults = new ArrayList();
|
|
||||||
addChildren(vrequest.getUnfilteredWebappDaoFactory(), root, childResults, 0, ontologyUri);
|
|
||||||
results.addAll(childResults);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
request.setAttribute("results",results);
|
|
||||||
request.setAttribute("columncount",NUM_COLS);
|
|
||||||
request.setAttribute("suppressquery","true");
|
|
||||||
request.setAttribute("title", (inferred) ? "Inferred Class Hierarchy" : "Class Hierarchy");
|
|
||||||
request.setAttribute("bodyJsp", Controllers.HORIZONTAL_JSP);
|
|
||||||
// new way of adding more than one button
|
|
||||||
List <ButtonForm> buttons = new ArrayList<ButtonForm>();
|
|
||||||
HashMap<String,String> newClassParams=new HashMap<String,String>();
|
|
||||||
String temp;
|
|
||||||
if ( (temp=vrequest.getParameter("ontologyUri")) != null) {
|
|
||||||
newClassParams.put("ontologyUri",temp);
|
|
||||||
}
|
|
||||||
ButtonForm newClassButton = new ButtonForm(Controllers.VCLASS_RETRY_URL,"buttonForm","Add new class",newClassParams);
|
|
||||||
buttons.add(newClassButton);
|
|
||||||
HashMap<String,String> allClassParams=new HashMap<String,String>();
|
|
||||||
if ( (temp=vrequest.getParameter("ontologyUri")) != null) {
|
|
||||||
allClassParams.put("ontologyUri",temp);
|
|
||||||
}
|
|
||||||
ButtonForm allClassButton = new ButtonForm("listVClassWebapps","buttonForm","All classes",allClassParams);
|
|
||||||
buttons.add(allClassButton);
|
|
||||||
if (!inferred) {
|
|
||||||
HashMap<String,String> inferParams=new HashMap<String,String>();
|
|
||||||
if ( (temp=vrequest.getParameter("ontologyUri")) != null) {
|
|
||||||
inferParams.put("ontologyUri",temp);
|
|
||||||
}
|
|
||||||
inferParams.put("inferred", "1");
|
|
||||||
ButtonForm inferButton = new ButtonForm("showClassHierarchy","buttonForm","Inferred class hierarchy",inferParams);
|
|
||||||
buttons.add(inferButton);
|
|
||||||
} else {
|
|
||||||
HashMap<String,String> inferParams=new HashMap<String,String>();
|
|
||||||
if ( (temp=vrequest.getParameter("ontologyUri")) != null) {
|
|
||||||
inferParams.put("ontologyUri",temp);
|
|
||||||
}
|
|
||||||
ButtonForm inferButton = new ButtonForm("showClassHierarchy","buttonForm","Asserted class hierarchy",inferParams);
|
|
||||||
buttons.add(inferButton);
|
|
||||||
}
|
|
||||||
request.setAttribute("topButtons", buttons);
|
|
||||||
/*
|
|
||||||
request.setAttribute("horizontalJspAddButtonUrl", Controllers.VCLASS_RETRY_URL);
|
|
||||||
request.setAttribute("horizontalJspAddButtonText", "Add new class");
|
|
||||||
*/
|
|
||||||
|
|
||||||
RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
|
|
||||||
try {
|
|
||||||
rd.forward(request, response);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addChildren(WebappDaoFactory wadf, VClass parent, ArrayList list, int position, String ontologyUri) {
|
|
||||||
List rowElts = addVClassDataToResultsList(wadf, parent, position, ontologyUri);
|
|
||||||
int childShift = (rowElts.size() > 0) ? 1 : 0; // if addVClassDataToResultsList filtered out the result, don't shift the children over
|
|
||||||
list.addAll(rowElts);
|
|
||||||
List childURIstrs = vcDao.getSubClassURIs(parent.getURI());
|
|
||||||
if ((childURIstrs.size()>0) && position<MAXDEPTH) {
|
|
||||||
List childClasses = new ArrayList();
|
|
||||||
Iterator childURIstrIt = childURIstrs.iterator();
|
|
||||||
while (childURIstrIt.hasNext()) {
|
|
||||||
String URIstr = (String) childURIstrIt.next();
|
|
||||||
try {
|
|
||||||
VClass child = (VClass) vcDao.getVClassByURI(URIstr);
|
|
||||||
if (!child.getURI().equals(OWL.Nothing.getURI())) {
|
|
||||||
childClasses.add(child);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {}
|
|
||||||
}
|
|
||||||
Collections.sort(childClasses);
|
|
||||||
Iterator childClassIt = childClasses.iterator();
|
|
||||||
while (childClassIt.hasNext()) {
|
|
||||||
VClass child = (VClass) childClassIt.next();
|
|
||||||
addChildren(wadf, child, list, position + childShift, ontologyUri);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List addVClassDataToResultsList(WebappDaoFactory wadf, VClass vcw, int position, String ontologyUri) {
|
|
||||||
List results = new ArrayList();
|
|
||||||
if (ontologyUri == null || ( (vcw.getNamespace()!=null) && (vcw.getNamespace().equals(ontologyUri)) ) ) {
|
|
||||||
for (int i=0; i<position; i++) {
|
|
||||||
results.add("@@entities");
|
|
||||||
}
|
|
||||||
if (position==0)
|
|
||||||
results.add("XX"); // column 1
|
|
||||||
Integer numCols = (NUM_COLS-1)-position;
|
|
||||||
|
|
||||||
try {
|
|
||||||
numCols = addColToResults(((vcw.getPickListName() == null) ? "" : "<a href=\"vclassEdit?uri="+URLEncoder.encode(vcw.getURI(),"UTF-8")+"\">"+vcw.getPickListName()+"</a>"), results, numCols);
|
|
||||||
} catch (Exception e) {
|
|
||||||
numCols = addColToResults(((vcw.getPickListName() == null) ? "" : vcw.getPickListName()), results, numCols); // column 2
|
|
||||||
}
|
|
||||||
numCols = addColToResults(((vcw.getShortDef() == null) ? "" : vcw.getShortDef()), results, numCols); // column 3
|
|
||||||
numCols = addColToResults(((vcw.getExample() == null) ? "" : vcw.getExample()), results, numCols); // column 4
|
|
||||||
|
|
||||||
// Get group name if it exists
|
|
||||||
VClassGroupDao groupDao= wadf.getVClassGroupDao();
|
|
||||||
String groupURI = vcw.getGroupURI();
|
|
||||||
String groupName = null;
|
|
||||||
VClassGroup classGroup = null;
|
|
||||||
if(groupURI != null) {
|
|
||||||
classGroup = groupDao.getGroupByURI(groupURI);
|
|
||||||
if (classGroup != null) {
|
|
||||||
groupName = classGroup.getPublicName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
numCols = addColToResults(((groupName == null) ? "" : groupName), results, numCols); // column 5
|
|
||||||
|
|
||||||
// Get ontology name
|
|
||||||
String ontName = null;
|
|
||||||
try {
|
|
||||||
OntologyDao ontDao = wadf.getOntologyDao();
|
|
||||||
Ontology ont = ontDao.getOntologyByURI(vcw.getNamespace());
|
|
||||||
ontName = ont.getName();
|
|
||||||
} catch (Exception e) {}
|
|
||||||
numCols = addColToResults(((ontName == null) ? "" : ontName), results, numCols); // column 6
|
|
||||||
|
|
||||||
numCols = addColToResults(vcw.getHiddenFromDisplayBelowRoleLevel() == null ? "unspecified" : vcw.getHiddenFromDisplayBelowRoleLevel().getShorthand(), results, numCols); // column 7
|
|
||||||
numCols = addColToResults(vcw.getProhibitedFromUpdateBelowRoleLevel() == null ? "unspecified" : vcw.getProhibitedFromUpdateBelowRoleLevel().getShorthand(), results, numCols); // column 8
|
|
||||||
|
|
||||||
results.add("XX"); // column 9
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Integer addColToResults (String value, List results, Integer colIndex) {
|
|
||||||
if (colIndex>0) {
|
|
||||||
results.add(value);
|
|
||||||
}
|
|
||||||
return colIndex-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,240 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.edit.listing;
|
|
||||||
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.text.Collator;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.servlet.RequestDispatcher;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vedit.beans.ButtonForm;
|
|
||||||
import edu.cornell.mannlib.vedit.controller.BaseEditController;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Datatype;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
|
||||||
|
|
||||||
public class DataPropertyHierarchyListingController extends BaseEditController {
|
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(DataPropertyHierarchyListingController.class.getName());
|
|
||||||
|
|
||||||
private int MAXDEPTH = 5;
|
|
||||||
private int NUM_COLS = 9;
|
|
||||||
|
|
||||||
private DataPropertyDao dpDao = null;
|
|
||||||
private VClassDao vcDao = null;
|
|
||||||
private PropertyGroupDao pgDao = null;
|
|
||||||
private DatatypeDao dDao = null;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
if (!isAuthorizedToDisplayPage(request, response, SimplePermission.EDIT_ONTOLOGY.ACTIONS)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
VitroRequest vrequest = new VitroRequest(request);
|
|
||||||
try {
|
|
||||||
|
|
||||||
dpDao = vrequest.getUnfilteredAssertionsWebappDaoFactory().getDataPropertyDao();
|
|
||||||
vcDao = vrequest.getUnfilteredAssertionsWebappDaoFactory().getVClassDao();
|
|
||||||
pgDao = vrequest.getUnfilteredAssertionsWebappDaoFactory().getPropertyGroupDao();
|
|
||||||
dDao = vrequest.getUnfilteredAssertionsWebappDaoFactory().getDatatypeDao();
|
|
||||||
|
|
||||||
ArrayList<String> results = new ArrayList<String>();
|
|
||||||
results.add("XX"); // column 1
|
|
||||||
results.add("property"); // column 2
|
|
||||||
results.add("domain vclass"); // column 3
|
|
||||||
results.add("range vclass"); // column 4
|
|
||||||
results.add("group"); // column 5
|
|
||||||
results.add("display tier"); // column 6
|
|
||||||
results.add("display level"); // column 7
|
|
||||||
results.add("update level"); // column 8
|
|
||||||
results.add("XX"); // column 9
|
|
||||||
|
|
||||||
String ontologyUri = request.getParameter("ontologyUri");
|
|
||||||
String startPropertyUri = request.getParameter("propertyUri");
|
|
||||||
|
|
||||||
List<DataProperty> roots = null;
|
|
||||||
|
|
||||||
if (startPropertyUri != null) {
|
|
||||||
roots = new LinkedList<DataProperty>();
|
|
||||||
roots.add(dpDao.getDataPropertyByURI(startPropertyUri));
|
|
||||||
} else {
|
|
||||||
roots = dpDao.getRootDataProperties();
|
|
||||||
if (roots!=null){
|
|
||||||
Collections.sort(roots);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (roots!=null) {
|
|
||||||
Iterator<DataProperty> rootIt = roots.iterator();
|
|
||||||
if (!rootIt.hasNext()) {
|
|
||||||
DataProperty dp = new DataProperty();
|
|
||||||
dp.setURI(ontologyUri+"fake");
|
|
||||||
String notFoundMessage = "<strong>No data properties found.</strong>";
|
|
||||||
dp.setName(notFoundMessage);
|
|
||||||
dp.setName(notFoundMessage);
|
|
||||||
results.addAll(addDataPropertyDataToResultsList(dp,0,ontologyUri));
|
|
||||||
} else {
|
|
||||||
while (rootIt.hasNext()) {
|
|
||||||
DataProperty root = rootIt.next();
|
|
||||||
if ( (ontologyUri==null) || ( (ontologyUri!=null) && (root.getNamespace()!=null) && (ontologyUri.equals(root.getNamespace())) ) ) {
|
|
||||||
ArrayList childResults = new ArrayList();
|
|
||||||
addChildren(root, childResults, 0, ontologyUri);
|
|
||||||
results.addAll(childResults);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
request.setAttribute("results",results);
|
|
||||||
request.setAttribute("columncount",NUM_COLS);
|
|
||||||
request.setAttribute("suppressquery","true");
|
|
||||||
request.setAttribute("title", "Data Property Hierarchy");
|
|
||||||
request.setAttribute("bodyJsp", Controllers.HORIZONTAL_JSP);
|
|
||||||
|
|
||||||
// new way of adding more than one button
|
|
||||||
List <ButtonForm> buttons = new ArrayList<ButtonForm>();
|
|
||||||
HashMap<String,String> newPropParams=new HashMap<String,String>();
|
|
||||||
newPropParams.put("controller", "Dataprop");
|
|
||||||
|
|
||||||
ButtonForm newPropButton = new ButtonForm(Controllers.RETRY_URL,"buttonForm","Add new data property",newPropParams);
|
|
||||||
buttons.add(newPropButton);
|
|
||||||
HashMap<String,String> allPropParams=new HashMap<String,String>();
|
|
||||||
|
|
||||||
String temp;
|
|
||||||
if ( (temp=vrequest.getParameter("ontologyUri")) != null) {
|
|
||||||
allPropParams.put("ontologyUri",temp);
|
|
||||||
}
|
|
||||||
ButtonForm allPropButton = new ButtonForm("listDatatypeProperties","buttonForm","show all data properties",allPropParams);
|
|
||||||
buttons.add(allPropButton);
|
|
||||||
request.setAttribute("topButtons", buttons);
|
|
||||||
/*
|
|
||||||
request.setAttribute("horizontalJspAddButtonUrl", Controllers.RETRY_URL);
|
|
||||||
request.setAttribute("horizontalJspAddButtonText", "Add new data property");
|
|
||||||
request.setAttribute("horizontalJspAddButtonControllerParam", "Property");
|
|
||||||
*/
|
|
||||||
RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
|
|
||||||
try {
|
|
||||||
rd.forward(request, response);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addChildren(DataProperty parent, ArrayList list, int position, String ontologyUri) {
|
|
||||||
if (parent == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
list.addAll(addDataPropertyDataToResultsList(parent, position, ontologyUri));
|
|
||||||
List childURIstrs = dpDao.getSubPropertyURIs(parent.getURI());
|
|
||||||
if ((childURIstrs.size()>0) && position<MAXDEPTH) {
|
|
||||||
List childProps = new ArrayList();
|
|
||||||
Iterator childURIstrIt = childURIstrs.iterator();
|
|
||||||
while (childURIstrIt.hasNext()) {
|
|
||||||
String URIstr = (String) childURIstrIt.next();
|
|
||||||
DataProperty child = (DataProperty) dpDao.getDataPropertyByURI(URIstr);
|
|
||||||
childProps.add(child);
|
|
||||||
}
|
|
||||||
Collections.sort(childProps);
|
|
||||||
Iterator childPropIt = childProps.iterator();
|
|
||||||
while (childPropIt.hasNext()) {
|
|
||||||
DataProperty child = (DataProperty) childPropIt.next();
|
|
||||||
addChildren(child, list, position+1,ontologyUri);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List addDataPropertyDataToResultsList(DataProperty dp, int position, String ontologyUri) {
|
|
||||||
List results = new ArrayList();
|
|
||||||
if (dp == null) {
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
if (ontologyUri == null || ( (dp.getNamespace()!=null) && (dp.getNamespace().equals(ontologyUri)) ) ) {
|
|
||||||
//if (position==1)
|
|
||||||
// position=2;
|
|
||||||
for (int i=0; i<position; i++) {
|
|
||||||
results.add("@@entities"); // column 1
|
|
||||||
}
|
|
||||||
if (position==0)
|
|
||||||
results.add("XX"); // column 1
|
|
||||||
Integer numCols = (NUM_COLS-1)-position;
|
|
||||||
|
|
||||||
String nameStr = dp.getPublicName()==null ? dp.getName()==null ? dp.getURI()==null ? "(no name)" : dp.getURI() : dp.getName() : dp.getPublicName();
|
|
||||||
try {
|
|
||||||
numCols=addColToResults("<a href=\"datapropEdit?uri="+URLEncoder.encode(dp.getURI(),"UTF-8")+"\">"+nameStr+"</a> <span style='font-style:italic; color:\"grey\";'>"+dp.getPickListName()+"</span>",results,numCols); // column 2
|
|
||||||
} catch (Exception e) {
|
|
||||||
numCols=addColToResults(nameStr + " <i>" + dp.getPickListName() + "</i>",results,numCols); // column 2
|
|
||||||
}
|
|
||||||
VClass tmp = null;
|
|
||||||
try {
|
|
||||||
numCols = addColToResults((((tmp = vcDao.getVClassByURI(dp.getDomainClassURI())) != null && (tmp.getPickListName() == null)) ? "" : vcDao.getVClassByURI(dp.getDomainClassURI()).getPickListName()), results, numCols); // column 3
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
numCols = addColToResults("-",results,numCols);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Datatype rangeDatatype = dDao.getDatatypeByURI(dp.getRangeDatatypeURI());
|
|
||||||
String rangeDatatypeStr = (rangeDatatype==null)?dp.getRangeDatatypeURI():rangeDatatype.getName();
|
|
||||||
numCols = addColToResults( (rangeDatatypeStr != null) ? rangeDatatypeStr : "-", results, numCols); // column 4
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
numCols = addColToResults("-",results,numCols);
|
|
||||||
}
|
|
||||||
if (dp.getGroupURI() != null) {
|
|
||||||
PropertyGroup pGroup = pgDao.getGroupByURI(dp.getGroupURI());
|
|
||||||
numCols = addColToResults(((pGroup == null) ? "unspecified" : pGroup.getName()), results, numCols); // column 5
|
|
||||||
} else {
|
|
||||||
numCols = addColToResults("unspecified", results, numCols);
|
|
||||||
}
|
|
||||||
Integer displayTier = dp.getDisplayTier();
|
|
||||||
String displayTierStr = (displayTier < 0)
|
|
||||||
? ""
|
|
||||||
: Integer.toString(displayTier);
|
|
||||||
numCols = addColToResults(displayTierStr, results, numCols);
|
|
||||||
numCols = addColToResults(
|
|
||||||
(dp.getHiddenFromDisplayBelowRoleLevel() == null)
|
|
||||||
? "unspecified"
|
|
||||||
: dp.getHiddenFromDisplayBelowRoleLevel()
|
|
||||||
.getShorthand(), results, numCols); // column 7
|
|
||||||
numCols = addColToResults(
|
|
||||||
(dp.getProhibitedFromUpdateBelowRoleLevel() == null)
|
|
||||||
? "unspecified"
|
|
||||||
: dp.getProhibitedFromUpdateBelowRoleLevel()
|
|
||||||
.getShorthand(), results, numCols); // column 8
|
|
||||||
results.add("XX"); // column 9
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Integer addColToResults (String value, List results, Integer colIndex) {
|
|
||||||
if (colIndex>0) {
|
|
||||||
results.add(value);
|
|
||||||
}
|
|
||||||
return colIndex-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,173 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.edit.listing;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.servlet.RequestDispatcher;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vedit.controller.BaseEditController;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Datatype;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
|
||||||
|
|
||||||
public class DatatypePropertiesListingController extends BaseEditController {
|
|
||||||
private final int NUM_COLS = 9;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
if (!isAuthorizedToDisplayPage(request, response, SimplePermission.EDIT_ONTOLOGY.ACTIONS)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
VitroRequest vrequest = new VitroRequest(request);
|
|
||||||
|
|
||||||
String noResultsMsgStr = "No data properties found";
|
|
||||||
|
|
||||||
String ontologyUri = request.getParameter("ontologyUri");
|
|
||||||
|
|
||||||
DataPropertyDao dao = vrequest.getUnfilteredWebappDaoFactory().getDataPropertyDao();
|
|
||||||
VClassDao vcDao = vrequest.getUnfilteredWebappDaoFactory().getVClassDao();
|
|
||||||
DatatypeDao dDao = vrequest.getUnfilteredWebappDaoFactory().getDatatypeDao();
|
|
||||||
PropertyGroupDao pgDao = vrequest.getUnfilteredWebappDaoFactory().getPropertyGroupDao();
|
|
||||||
|
|
||||||
List<DataProperty> props = new ArrayList<DataProperty>();
|
|
||||||
|
|
||||||
if (request.getParameter("propsForClass") != null) {
|
|
||||||
noResultsMsgStr = "There are no data properties that apply to this class.";
|
|
||||||
Collection <DataProperty> dataProps = dao.getDataPropertiesForVClass(request.getParameter("vclassUri"));
|
|
||||||
Iterator<DataProperty> dataPropIt = dataProps.iterator();
|
|
||||||
HashSet<String> propURIs = new HashSet<String>();
|
|
||||||
while (dataPropIt.hasNext()) {
|
|
||||||
DataProperty dp = dataPropIt.next();
|
|
||||||
if (!(propURIs.contains(dp.getURI()))) {
|
|
||||||
propURIs.add(dp.getURI());
|
|
||||||
DataProperty prop = dao.getDataPropertyByURI(dp.getURI());
|
|
||||||
if (prop != null) {
|
|
||||||
props.add(prop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
props = dao.getAllDataProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ontologyUri != null) {
|
|
||||||
List<DataProperty> scratch = new ArrayList<DataProperty>();
|
|
||||||
for (DataProperty p: props) {
|
|
||||||
if (p.getNamespace().equals(ontologyUri)) {
|
|
||||||
scratch.add(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
props = scratch;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (props != null) {
|
|
||||||
Collections.sort(props);
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<String> results = new ArrayList<String>();
|
|
||||||
results.add("XX"); // column 1
|
|
||||||
results.add("Data Property"); // column 2
|
|
||||||
results.add("domain"); // column 3
|
|
||||||
results.add("range datatype"); // column 4
|
|
||||||
results.add("group"); // column 5
|
|
||||||
results.add("display tier"); // column 6
|
|
||||||
results.add("display limit"); // column 7
|
|
||||||
results.add("display level"); // column 8
|
|
||||||
results.add("update level"); // column 9
|
|
||||||
|
|
||||||
|
|
||||||
if (props != null) {
|
|
||||||
if (props.size()==0) {
|
|
||||||
results.add("XX");
|
|
||||||
results.add("<strong>"+noResultsMsgStr+"</strong>");
|
|
||||||
results.add("");
|
|
||||||
results.add("");
|
|
||||||
results.add("");
|
|
||||||
results.add("");
|
|
||||||
results.add("");
|
|
||||||
results.add("");
|
|
||||||
results.add("");
|
|
||||||
} else {
|
|
||||||
for (DataProperty prop: props) {
|
|
||||||
results.add("XX"); // column 1
|
|
||||||
String nameStr = prop.getPublicName()==null ? prop.getName()==null ? prop.getURI()==null ? "(no name)" : prop.getURI() : prop.getName() : prop.getPublicName();
|
|
||||||
try {
|
|
||||||
results.add("<a href=\"datapropEdit?uri="+URLEncoder.encode(prop.getURI(),"UTF-8")+"\">"+nameStr+"</a> <span style='font-style:italic; color:\"grey\";'>"+prop.getPickListName()+"</span>"); // column 2
|
|
||||||
} catch (Exception e) {
|
|
||||||
results.add(nameStr + " <span style='font-style:italic; color:\"grey\";'>" + prop.getPickListName() + "</span>"); // column 2
|
|
||||||
}
|
|
||||||
VClass vc = null;
|
|
||||||
String domainStr="";
|
|
||||||
if (prop.getDomainClassURI() != null) {
|
|
||||||
vc = vcDao.getVClassByURI(prop.getDomainClassURI());
|
|
||||||
if (vc != null) {
|
|
||||||
try {
|
|
||||||
domainStr="<a href=\"vclassEdit?uri="+URLEncoder.encode(prop.getDomainClassURI(),"UTF-8")+"\">"+vc.getName()+"</a>";
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
results.add(domainStr);
|
|
||||||
|
|
||||||
Datatype rangeDatatype = dDao.getDatatypeByURI(prop.getRangeDatatypeURI());
|
|
||||||
String rangeDatatypeStr = (rangeDatatype==null)?prop.getRangeDatatypeURI():rangeDatatype.getName();
|
|
||||||
results.add((rangeDatatypeStr==null)?"<i>untyped</i>":rangeDatatypeStr); // column 4
|
|
||||||
if (prop.getGroupURI() != null) {
|
|
||||||
PropertyGroup pGroup = pgDao.getGroupByURI(prop.getGroupURI());
|
|
||||||
results.add((pGroup == null) ? "unknown group" : pGroup.getName()); // column 5
|
|
||||||
} else {
|
|
||||||
results.add("unspecified");
|
|
||||||
}
|
|
||||||
Integer displayTier = prop.getDisplayTier();
|
|
||||||
String displayTierStr = (displayTier < 0)
|
|
||||||
? ""
|
|
||||||
: Integer.toString(displayTier);
|
|
||||||
results.add(displayTierStr); // column 6
|
|
||||||
Integer displayLimit = prop.getDisplayLimit();
|
|
||||||
String displayLimitStr = (displayLimit < 0)
|
|
||||||
? ""
|
|
||||||
: Integer.toString(displayLimit);
|
|
||||||
results.add(displayLimitStr); // column 7
|
|
||||||
results.add(prop.getHiddenFromDisplayBelowRoleLevel() == null ? "unspecified" : prop.getHiddenFromDisplayBelowRoleLevel().getShorthand()); // column 8
|
|
||||||
results.add(prop.getProhibitedFromUpdateBelowRoleLevel() == null ? "unspecified" : prop.getProhibitedFromUpdateBelowRoleLevel().getShorthand()); // column 9
|
|
||||||
}
|
|
||||||
}
|
|
||||||
request.setAttribute("results",results);
|
|
||||||
}
|
|
||||||
|
|
||||||
request.setAttribute("columncount",new Integer(NUM_COLS));
|
|
||||||
request.setAttribute("suppressquery","true");
|
|
||||||
request.setAttribute("title","Data Properties");
|
|
||||||
request.setAttribute("bodyJsp", Controllers.HORIZONTAL_JSP);
|
|
||||||
request.setAttribute("horizontalJspAddButtonUrl", Controllers.RETRY_URL);
|
|
||||||
request.setAttribute("horizontalJspAddButtonText", "Add new data property");
|
|
||||||
request.setAttribute("horizontalJspAddButtonControllerParam", "Dataprop");
|
|
||||||
RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
|
|
||||||
try {
|
|
||||||
rd.forward(request,response);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,276 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.edit.listing;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.text.Collator;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.servlet.RequestDispatcher;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vedit.beans.ButtonForm;
|
|
||||||
import edu.cornell.mannlib.vedit.controller.BaseEditController;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
|
||||||
|
|
||||||
public class ObjectPropertyHierarchyListingController extends BaseEditController {
|
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(ObjectPropertyHierarchyListingController.class.getName());
|
|
||||||
|
|
||||||
private int MAXDEPTH = 5;
|
|
||||||
private int NUM_COLS = 9;
|
|
||||||
|
|
||||||
private ObjectPropertyDao opDao = null;
|
|
||||||
private VClassDao vcDao = null;
|
|
||||||
private PropertyGroupDao pgDao = null;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
if (!isAuthorizedToDisplayPage(request, response, SimplePermission.EDIT_ONTOLOGY.ACTIONS)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
VitroRequest vrequest = new VitroRequest(request);
|
|
||||||
try {
|
|
||||||
|
|
||||||
opDao = vrequest.getUnfilteredAssertionsWebappDaoFactory().getObjectPropertyDao();
|
|
||||||
vcDao = vrequest.getUnfilteredAssertionsWebappDaoFactory().getVClassDao();
|
|
||||||
pgDao = vrequest.getUnfilteredAssertionsWebappDaoFactory().getPropertyGroupDao();
|
|
||||||
|
|
||||||
ArrayList<String> results = new ArrayList<String>();
|
|
||||||
results.add("XX"); // column 1
|
|
||||||
results.add("property"); // column 2
|
|
||||||
results.add("domain vclass"); // column 3
|
|
||||||
results.add("range vclass"); // column 4
|
|
||||||
results.add("group"); // column 5
|
|
||||||
results.add("display tier"); // column 6
|
|
||||||
results.add("display level"); // column 7
|
|
||||||
results.add("update level"); // column 8
|
|
||||||
results.add("XX"); // column 10
|
|
||||||
|
|
||||||
String ontologyUri = request.getParameter("ontologyUri");
|
|
||||||
String startPropertyUri = request.getParameter("propertyUri");
|
|
||||||
|
|
||||||
List<ObjectProperty> roots = null;
|
|
||||||
|
|
||||||
if (startPropertyUri != null) {
|
|
||||||
roots = new LinkedList<ObjectProperty>();
|
|
||||||
ObjectProperty op = opDao.getObjectPropertyByURI(startPropertyUri);
|
|
||||||
if (op == null) {
|
|
||||||
op = new ObjectProperty();
|
|
||||||
op.setURI(startPropertyUri);
|
|
||||||
}
|
|
||||||
roots.add(op);
|
|
||||||
} else {
|
|
||||||
roots = opDao.getRootObjectProperties();
|
|
||||||
if (roots!=null){
|
|
||||||
Collections.sort(roots, new ObjectPropertyAlphaComparator(vrequest.getCollator())); // sorts by domain public
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (roots != null) {
|
|
||||||
Iterator<ObjectProperty> rootIt = roots.iterator();
|
|
||||||
if (!rootIt.hasNext()) {
|
|
||||||
ObjectProperty op = new ObjectProperty();
|
|
||||||
op.setURI(ontologyUri+"fake");
|
|
||||||
String notFoundMessage = "<strong>No object properties found.</strong>";
|
|
||||||
op.setDomainPublic(notFoundMessage);
|
|
||||||
results.addAll(addObjectPropertyDataToResultsList(op,0,ontologyUri));
|
|
||||||
} else {
|
|
||||||
while (rootIt.hasNext()) {
|
|
||||||
ObjectProperty root = rootIt.next();
|
|
||||||
if ( (ontologyUri==null) ||
|
|
||||||
( (ontologyUri != null)
|
|
||||||
&& (root.getNamespace() != null)
|
|
||||||
&& (ontologyUri.equals(root.getNamespace())) ) ) {
|
|
||||||
ArrayList childResults = new ArrayList();
|
|
||||||
addChildren(root, childResults, 0, ontologyUri);
|
|
||||||
results.addAll(childResults);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
request.setAttribute("results",results);
|
|
||||||
request.setAttribute("columncount",NUM_COLS);
|
|
||||||
request.setAttribute("suppressquery","true");
|
|
||||||
request.setAttribute("title", "Object Property Hierarchy");
|
|
||||||
request.setAttribute("bodyJsp", Controllers.HORIZONTAL_JSP);
|
|
||||||
|
|
||||||
// new way of adding more than one button
|
|
||||||
List <ButtonForm> buttons = new ArrayList<ButtonForm>();
|
|
||||||
HashMap<String,String> newPropParams=new HashMap<String,String>();
|
|
||||||
newPropParams.put("controller", "Property");
|
|
||||||
ButtonForm newPropButton = new ButtonForm(Controllers.RETRY_URL,"buttonForm","Add new object property",newPropParams);
|
|
||||||
buttons.add(newPropButton);
|
|
||||||
HashMap<String,String> allPropParams=new HashMap<String,String>();
|
|
||||||
String temp;
|
|
||||||
if ( (temp=vrequest.getParameter("ontologyUri")) != null) {
|
|
||||||
allPropParams.put("ontologyUri",temp);
|
|
||||||
}
|
|
||||||
ButtonForm allPropButton = new ButtonForm("listPropertyWebapps","buttonForm","show all object properties",allPropParams);
|
|
||||||
buttons.add(allPropButton);
|
|
||||||
request.setAttribute("topButtons", buttons);
|
|
||||||
/*
|
|
||||||
request.setAttribute("horizontalJspAddButtonUrl", Controllers.RETRY_URL);
|
|
||||||
request.setAttribute("horizontalJspAddButtonText", "Add new object property");
|
|
||||||
request.setAttribute("horizontalJspAddButtonControllerParam", "Property");
|
|
||||||
*/
|
|
||||||
RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
|
|
||||||
try {
|
|
||||||
rd.forward(request, response);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addChildren(ObjectProperty parent, ArrayList list, int position, String ontologyUri) {
|
|
||||||
list.addAll(addObjectPropertyDataToResultsList(parent, position, ontologyUri));
|
|
||||||
List childURIstrs = opDao.getSubPropertyURIs(parent.getURI());
|
|
||||||
if ((childURIstrs.size()>0) && position<MAXDEPTH) {
|
|
||||||
List childProps = new ArrayList();
|
|
||||||
Iterator childURIstrIt = childURIstrs.iterator();
|
|
||||||
while (childURIstrIt.hasNext()) {
|
|
||||||
String URIstr = (String) childURIstrIt.next();
|
|
||||||
ObjectProperty child = (ObjectProperty) opDao.getObjectPropertyByURI(URIstr);
|
|
||||||
childProps.add(child);
|
|
||||||
}
|
|
||||||
Collections.sort(childProps);
|
|
||||||
Iterator childPropIt = childProps.iterator();
|
|
||||||
while (childPropIt.hasNext()) {
|
|
||||||
ObjectProperty child = (ObjectProperty) childPropIt.next();
|
|
||||||
addChildren(child, list, position+1,ontologyUri);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List addObjectPropertyDataToResultsList(ObjectProperty op, int position, String ontologyUri) {
|
|
||||||
List results = new ArrayList();
|
|
||||||
if (ontologyUri == null || ( (op.getNamespace()!=null) && (op.getNamespace().equals(ontologyUri)) ) ) {
|
|
||||||
for (int i=0; i<position; i++) {
|
|
||||||
results.add("@@entities"); // column 1
|
|
||||||
}
|
|
||||||
if (position==0)
|
|
||||||
results.add("XX"); // column 1
|
|
||||||
Integer numCols = (NUM_COLS-1)-position;
|
|
||||||
|
|
||||||
String hyperlink = null;
|
|
||||||
try {
|
|
||||||
hyperlink = "<a href=\"propertyEdit?uri="+URLEncoder.encode(op.getURI(),"UTF-8")+"\">"+getDisplayLabel(op)+"</a>";
|
|
||||||
} catch (UnsupportedEncodingException uee) {
|
|
||||||
log.error("Unsupported: URLEncoder.encode() with UTF-8");
|
|
||||||
}
|
|
||||||
|
|
||||||
numCols = addColToResults( ((hyperlink != null) ? hyperlink : getDisplayLabel(op))
|
|
||||||
+ "<br/><span style='font-style:italic; color:\"grey\";'>"+op.getPickListName()+"</span>", results, numCols); // column 2
|
|
||||||
|
|
||||||
VClass tmp = null;
|
|
||||||
try {
|
|
||||||
numCols = addColToResults((((tmp = vcDao.getVClassByURI(op.getDomainVClassURI())) != null && (tmp.getPickListName() == null)) ? "" : vcDao.getVClassByURI(op.getDomainVClassURI()).getPickListName()), results, numCols); // column 3
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
numCols = addColToResults("",results,numCols);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
numCols = addColToResults((((tmp = vcDao.getVClassByURI(op.getRangeVClassURI())) != null && (tmp.getPickListName() == null)) ? "" : vcDao.getVClassByURI(op.getRangeVClassURI()).getPickListName()), results, numCols); // column 4
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
numCols = addColToResults("",results,numCols);
|
|
||||||
}
|
|
||||||
if (op.getGroupURI() != null) {
|
|
||||||
PropertyGroup pGroup = pgDao.getGroupByURI(op.getGroupURI());
|
|
||||||
numCols = addColToResults(((pGroup == null) ? "unspecified" : pGroup.getName()), results, numCols); // column 5
|
|
||||||
} else {
|
|
||||||
numCols = addColToResults("unspecified", results, numCols);
|
|
||||||
}
|
|
||||||
Integer displayTier = op.getDomainDisplayTierInteger();
|
|
||||||
numCols = addColToResults(
|
|
||||||
(displayTier == null)
|
|
||||||
? ""
|
|
||||||
: Integer.toString(displayTier, BASE_10),
|
|
||||||
results, numCols); // column 6
|
|
||||||
numCols = addColToResults(
|
|
||||||
(op.getHiddenFromDisplayBelowRoleLevel() == null)
|
|
||||||
? "unspecified"
|
|
||||||
: op.getHiddenFromDisplayBelowRoleLevel()
|
|
||||||
.getShorthand(),
|
|
||||||
results, numCols); // column 7
|
|
||||||
numCols = addColToResults(
|
|
||||||
(op.getProhibitedFromUpdateBelowRoleLevel() == null)
|
|
||||||
? "unspecified"
|
|
||||||
: op.getProhibitedFromUpdateBelowRoleLevel()
|
|
||||||
.getShorthand(),
|
|
||||||
results, numCols); // column 8
|
|
||||||
results.add("XX"); // column 9
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Integer addColToResults (String value, List results, Integer colIndex) {
|
|
||||||
if (colIndex>0) {
|
|
||||||
results.add(value);
|
|
||||||
}
|
|
||||||
return colIndex-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ObjectPropertyAlphaComparator implements Comparator<ObjectProperty> {
|
|
||||||
|
|
||||||
Collator collator;
|
|
||||||
|
|
||||||
public ObjectPropertyAlphaComparator(Collator collator) {
|
|
||||||
this.collator = collator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int compare(ObjectProperty op1, ObjectProperty op2) {
|
|
||||||
if (op1 == null) {
|
|
||||||
return 1;
|
|
||||||
} else if (op2 == null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
String propLabel1 = getDisplayLabel(op1);
|
|
||||||
String propLabel2 = getDisplayLabel(op2);
|
|
||||||
if (propLabel1 == null) {
|
|
||||||
return 1;
|
|
||||||
} else if (propLabel2 == null) {
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
return collator.compare( propLabel1, propLabel2 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* should never be null
|
|
||||||
*/
|
|
||||||
public static String getDisplayLabel(ObjectProperty op) {
|
|
||||||
String domainPublic = op.getDomainPublic();
|
|
||||||
String displayLabel = (domainPublic != null && domainPublic.length() > 0)
|
|
||||||
? domainPublic
|
|
||||||
: op.getLocalName();
|
|
||||||
return (displayLabel != null) ? displayLabel : "[object property]" ;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,232 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.edit.listing;
|
|
||||||
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.servlet.RequestDispatcher;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vedit.beans.ButtonForm;
|
|
||||||
import edu.cornell.mannlib.vedit.controller.BaseEditController;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
|
||||||
|
|
||||||
public class PropertyWebappsListingController extends BaseEditController {
|
|
||||||
private static Log log = LogFactory.getLog( PropertyWebappsListingController.class );
|
|
||||||
private int NUM_COLS = 9;
|
|
||||||
|
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
if (!isAuthorizedToDisplayPage(request, response, SimplePermission.EDIT_ONTOLOGY.ACTIONS)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
VitroRequest vrequest = new VitroRequest(request);
|
|
||||||
|
|
||||||
String noResultsMsgStr = "No object properties found";
|
|
||||||
|
|
||||||
String ontologyUri = request.getParameter("ontologyUri");
|
|
||||||
|
|
||||||
ObjectPropertyDao dao = vrequest.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
|
|
||||||
PropertyInstanceDao piDao = vrequest.getUnfilteredWebappDaoFactory().getPropertyInstanceDao();
|
|
||||||
VClassDao vcDao = vrequest.getUnfilteredWebappDaoFactory().getVClassDao();
|
|
||||||
PropertyGroupDao pgDao = vrequest.getUnfilteredWebappDaoFactory().getPropertyGroupDao();
|
|
||||||
|
|
||||||
String vclassURI = request.getParameter("vclassUri");
|
|
||||||
|
|
||||||
List props = new ArrayList();
|
|
||||||
if (request.getParameter("propsForClass") != null) {
|
|
||||||
noResultsMsgStr = "There are no properties that apply to this class.";
|
|
||||||
|
|
||||||
// incomplete list of classes to check, but better than before
|
|
||||||
List<String> superclassURIs = vcDao.getAllSuperClassURIs(vclassURI);
|
|
||||||
superclassURIs.add(vclassURI);
|
|
||||||
superclassURIs.addAll(vcDao.getEquivalentClassURIs(vclassURI));
|
|
||||||
|
|
||||||
Map<String, PropertyInstance> propInstMap = new HashMap<String, PropertyInstance>();
|
|
||||||
for (String classURI : superclassURIs) {
|
|
||||||
Collection<PropertyInstance> propInsts = piDao.getAllPropInstByVClass(classURI);
|
|
||||||
for (PropertyInstance propInst : propInsts) {
|
|
||||||
propInstMap.put(propInst.getPropertyURI(), propInst);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<PropertyInstance> propInsts = new ArrayList<PropertyInstance>();
|
|
||||||
propInsts.addAll(propInstMap.values());
|
|
||||||
Collections.sort(propInsts);
|
|
||||||
|
|
||||||
Iterator propInstIt = propInsts.iterator();
|
|
||||||
HashSet propURIs = new HashSet();
|
|
||||||
while (propInstIt.hasNext()) {
|
|
||||||
PropertyInstance pi = (PropertyInstance) propInstIt.next();
|
|
||||||
if (!(propURIs.contains(pi.getPropertyURI()))) {
|
|
||||||
propURIs.add(pi.getPropertyURI());
|
|
||||||
ObjectProperty prop = (ObjectProperty) dao.getObjectPropertyByURI(pi.getPropertyURI());
|
|
||||||
if (prop != null) {
|
|
||||||
props.add(prop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
props = (request.getParameter("iffRoot")!=null)
|
|
||||||
? dao.getRootObjectProperties()
|
|
||||||
: dao.getAllObjectProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
OntologyDao oDao = vrequest.getUnfilteredWebappDaoFactory().getOntologyDao();
|
|
||||||
HashMap<String,String> ontologyHash = new HashMap<String,String>();
|
|
||||||
|
|
||||||
Iterator propIt = props.iterator();
|
|
||||||
List<ObjectProperty> scratch = new ArrayList();
|
|
||||||
while (propIt.hasNext()) {
|
|
||||||
ObjectProperty p = (ObjectProperty) propIt.next();
|
|
||||||
if (p.getNamespace()!=null) {
|
|
||||||
if( !ontologyHash.containsKey( p.getNamespace() )){
|
|
||||||
Ontology o = (Ontology)oDao.getOntologyByURI(p.getNamespace());
|
|
||||||
if (o==null) {
|
|
||||||
if (!VitroVocabulary.vitroURI.equals(p.getNamespace())) {
|
|
||||||
log.debug("doGet(): no ontology object found for the namespace "+p.getNamespace());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ontologyHash.put(p.getNamespace(), o.getName() == null ? p.getNamespace() : o.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ontologyUri != null && p.getNamespace().equals(ontologyUri)) {
|
|
||||||
scratch.add(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ontologyUri != null) {
|
|
||||||
props = scratch;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (props != null) {
|
|
||||||
Collections.sort(
|
|
||||||
props, new ObjectPropertyHierarchyListingController
|
|
||||||
.ObjectPropertyAlphaComparator(vrequest.getCollator()));
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList results = new ArrayList();
|
|
||||||
results.add("XX"); // column 1
|
|
||||||
results.add("property public name"); // column 2
|
|
||||||
results.add("prefix + local name"); // column 3
|
|
||||||
results.add("domain"); // column 4
|
|
||||||
results.add("range"); // column 5
|
|
||||||
results.add("group"); // column 6
|
|
||||||
results.add("display tier"); // column 7
|
|
||||||
results.add("display level"); // column 8
|
|
||||||
results.add("update level"); // column 9
|
|
||||||
|
|
||||||
if (props != null) {
|
|
||||||
if (props.size()==0) {
|
|
||||||
results.add("XX");
|
|
||||||
results.add("<strong>"+noResultsMsgStr+"</strong>");
|
|
||||||
results.add("");
|
|
||||||
results.add("");
|
|
||||||
results.add("");
|
|
||||||
results.add("");
|
|
||||||
results.add("");
|
|
||||||
results.add("");
|
|
||||||
results.add("");
|
|
||||||
} else {
|
|
||||||
Iterator propsIt = props.iterator();
|
|
||||||
while (propsIt.hasNext()) {
|
|
||||||
ObjectProperty prop = (ObjectProperty) propsIt.next();
|
|
||||||
results.add("XX");
|
|
||||||
|
|
||||||
String propNameStr = ObjectPropertyHierarchyListingController.getDisplayLabel(prop);
|
|
||||||
try {
|
|
||||||
results.add("<a href=\"./propertyEdit?uri="+URLEncoder.encode(prop.getURI(),"UTF-8")+"\">" + propNameStr + "</a>"); // column 1
|
|
||||||
} catch (Exception e) {
|
|
||||||
results.add(propNameStr); // column 2
|
|
||||||
}
|
|
||||||
|
|
||||||
results.add(prop.getPickListName()); // column 3
|
|
||||||
|
|
||||||
VClass vc = (prop.getDomainVClassURI() != null) ?
|
|
||||||
vcDao.getVClassByURI(prop.getDomainVClassURI()) : null;
|
|
||||||
String domainStr = (vc != null) ? vc.getPickListName() : "";
|
|
||||||
results.add(domainStr); // column 4
|
|
||||||
|
|
||||||
vc = (prop.getRangeVClassURI() != null) ?
|
|
||||||
vcDao.getVClassByURI(prop.getRangeVClassURI()) : null;
|
|
||||||
String rangeStr = (vc != null) ? vc.getPickListName() : "";
|
|
||||||
results.add(rangeStr); // column 5
|
|
||||||
|
|
||||||
if (prop.getGroupURI() != null) {
|
|
||||||
PropertyGroup pGroup = pgDao.getGroupByURI(prop.getGroupURI());
|
|
||||||
results.add(pGroup == null ? "unknown group" : pGroup.getName()); // column 6
|
|
||||||
} else {
|
|
||||||
results.add("unspecified");
|
|
||||||
}
|
|
||||||
if (prop.getDomainDisplayTierInteger() != null) {
|
|
||||||
results.add(Integer.toString(prop.getDomainDisplayTierInteger(), BASE_10)); // column 7
|
|
||||||
} else {
|
|
||||||
results.add(""); // column 7
|
|
||||||
}
|
|
||||||
results.add(prop.getHiddenFromDisplayBelowRoleLevel() == null ? "(unspecified)" : prop.getHiddenFromDisplayBelowRoleLevel().getShorthand()); // column 8
|
|
||||||
results.add(prop.getProhibitedFromUpdateBelowRoleLevel() == null ? "(unspecified)" : prop.getProhibitedFromUpdateBelowRoleLevel().getShorthand()); // column 9
|
|
||||||
}
|
|
||||||
}
|
|
||||||
request.setAttribute("results",results);
|
|
||||||
}
|
|
||||||
|
|
||||||
request.setAttribute("columncount",new Integer(NUM_COLS));
|
|
||||||
request.setAttribute("suppressquery","true");
|
|
||||||
request.setAttribute("title","Object Properties");
|
|
||||||
request.setAttribute("bodyJsp", Controllers.HORIZONTAL_JSP);
|
|
||||||
|
|
||||||
// new way of adding more than one button
|
|
||||||
List <ButtonForm> buttons = new ArrayList<ButtonForm>();
|
|
||||||
HashMap<String,String> newPropParams=new HashMap<String,String>();
|
|
||||||
newPropParams.put("controller", "Property");
|
|
||||||
ButtonForm newPropButton = new ButtonForm(Controllers.RETRY_URL,"buttonForm","Add new object property",newPropParams);
|
|
||||||
buttons.add(newPropButton);
|
|
||||||
HashMap<String,String> rootPropParams=new HashMap<String,String>();
|
|
||||||
rootPropParams.put("iffRoot", "true");
|
|
||||||
String temp;
|
|
||||||
if ( (temp=vrequest.getParameter("ontologyUri")) != null) {
|
|
||||||
rootPropParams.put("ontologyUri",temp);
|
|
||||||
}
|
|
||||||
ButtonForm rootPropButton = new ButtonForm("showObjectPropertyHierarchy","buttonForm","root properties",rootPropParams);
|
|
||||||
buttons.add(rootPropButton);
|
|
||||||
request.setAttribute("topButtons", buttons);
|
|
||||||
|
|
||||||
/* original way of adding 1 button
|
|
||||||
request.setAttribute("horizontalJspAddButtonUrl", Controllers.RETRY_URL);
|
|
||||||
request.setAttribute("horizontalJspAddButtonText", "Add new object property");
|
|
||||||
request.setAttribute("horizontalJspAddButtonControllerParam", "Property");
|
|
||||||
*/
|
|
||||||
RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
|
|
||||||
try {
|
|
||||||
rd.forward(request,response);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,165 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.edit.listing;
|
|
||||||
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.servlet.RequestDispatcher;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vedit.beans.ButtonForm;
|
|
||||||
import edu.cornell.mannlib.vedit.controller.BaseEditController;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
|
||||||
|
|
||||||
public class VClassWebappsListingController extends BaseEditController {
|
|
||||||
|
|
||||||
private int NUM_COLS = 9;
|
|
||||||
|
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
if (!isAuthorizedToDisplayPage(request, response, SimplePermission.EDIT_ONTOLOGY.ACTIONS)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
VitroRequest vrequest = new VitroRequest(request);
|
|
||||||
|
|
||||||
//need to figure out how to structure the results object to put the classes underneath
|
|
||||||
|
|
||||||
List<VClass> classes = null;
|
|
||||||
|
|
||||||
if (request.getParameter("showPropertyRestrictions") != null) {
|
|
||||||
PropertyDao pdao = vrequest.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
|
|
||||||
classes = pdao.getClassesWithRestrictionOnProperty(request.getParameter("propertyURI"));
|
|
||||||
} else {
|
|
||||||
VClassDao vcdao = vrequest.getUnfilteredWebappDaoFactory().getVClassDao();
|
|
||||||
|
|
||||||
if (request.getParameter("iffRoot") != null) {
|
|
||||||
classes = vcdao.getRootClasses();
|
|
||||||
} else {
|
|
||||||
classes = vcdao.getAllVclasses();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
String ontologyURI = vrequest.getParameter("ontologyUri");
|
|
||||||
|
|
||||||
ArrayList<String> results = new ArrayList<String>();
|
|
||||||
results.add("XX");
|
|
||||||
results.add("Class");
|
|
||||||
results.add("short definition");
|
|
||||||
results.add("example");
|
|
||||||
results.add("comments");
|
|
||||||
results.add("group");
|
|
||||||
results.add("ontology");
|
|
||||||
results.add("display level");
|
|
||||||
results.add("update level");
|
|
||||||
|
|
||||||
if (classes != null) {
|
|
||||||
Collections.sort(classes);
|
|
||||||
Iterator<VClass> classesIt = classes.iterator();
|
|
||||||
while (classesIt.hasNext()) {
|
|
||||||
VClass cls = (VClass) classesIt.next();
|
|
||||||
if ( (ontologyURI==null) || ( (ontologyURI != null) && (cls.getNamespace()!=null) && (ontologyURI.equals(cls.getNamespace())) ) ) {
|
|
||||||
results.add("XX");
|
|
||||||
if (cls.getName() != null)
|
|
||||||
try {
|
|
||||||
//String className = (cls.getName()==null || cls.getName().length()==0) ? cls.getURI() : cls.getName();
|
|
||||||
results.add("<a href=\"./vclassEdit?uri="+URLEncoder.encode(cls.getURI(),"UTF-8")+"\">"+cls.getPickListName()+"</a>");
|
|
||||||
} catch (Exception e) {
|
|
||||||
results.add(cls.getPickListName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
results.add("");
|
|
||||||
String shortDef = (cls.getShortDef()==null) ? "" : cls.getShortDef();
|
|
||||||
String example = (cls.getExample()==null) ? "" : cls.getExample();
|
|
||||||
StringBuffer commSb = new StringBuffer();
|
|
||||||
for (Iterator<String> commIt = vrequest.getUnfilteredWebappDaoFactory().getCommentsForResource(cls.getURI()).iterator(); commIt.hasNext();) {
|
|
||||||
commSb.append(commIt.next()).append(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
// get group name
|
|
||||||
WebappDaoFactory wadf = vrequest.getUnfilteredWebappDaoFactory();
|
|
||||||
VClassGroupDao groupDao= wadf.getVClassGroupDao();
|
|
||||||
String groupURI = cls.getGroupURI();
|
|
||||||
String groupName = "";
|
|
||||||
VClassGroup classGroup = null;
|
|
||||||
if(groupURI != null) {
|
|
||||||
classGroup = groupDao.getGroupByURI(groupURI);
|
|
||||||
if (classGroup!=null) {
|
|
||||||
groupName = classGroup.getPublicName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO : lastModified
|
|
||||||
|
|
||||||
// get ontology name
|
|
||||||
OntologyDao ontDao = wadf.getOntologyDao();
|
|
||||||
String ontName = null;
|
|
||||||
try {
|
|
||||||
Ontology ont = ontDao.getOntologyByURI(cls.getNamespace());
|
|
||||||
ontName = ont.getName();
|
|
||||||
} catch (Exception e) {}
|
|
||||||
ontName = (ontName == null) ? "" : ontName;
|
|
||||||
|
|
||||||
results.add(shortDef);
|
|
||||||
results.add(example);
|
|
||||||
results.add(commSb.toString());
|
|
||||||
results.add(groupName);
|
|
||||||
results.add(ontName);
|
|
||||||
results.add(cls.getHiddenFromDisplayBelowRoleLevel() == null ? "unspecified" : cls.getHiddenFromDisplayBelowRoleLevel().getShorthand()); // column 8
|
|
||||||
results.add(cls.getProhibitedFromUpdateBelowRoleLevel() == null ? "unspecified" : cls.getProhibitedFromUpdateBelowRoleLevel().getShorthand()); // column 9
|
|
||||||
}
|
|
||||||
}
|
|
||||||
request.setAttribute("results",results);
|
|
||||||
}
|
|
||||||
|
|
||||||
request.setAttribute("columncount",new Integer(NUM_COLS));
|
|
||||||
request.setAttribute("suppressquery","true");
|
|
||||||
request.setAttribute("title","Classes");
|
|
||||||
request.setAttribute("bodyJsp", Controllers.HORIZONTAL_JSP);
|
|
||||||
// new way of adding more than one button
|
|
||||||
List <ButtonForm> buttons = new ArrayList<ButtonForm>();
|
|
||||||
HashMap<String,String> newClassParams=new HashMap<String,String>();
|
|
||||||
String temp;
|
|
||||||
if ( (temp=vrequest.getParameter("ontologyUri")) != null) {
|
|
||||||
newClassParams.put("ontologyUri",temp);
|
|
||||||
}
|
|
||||||
ButtonForm newClassButton = new ButtonForm(Controllers.VCLASS_RETRY_URL,"buttonForm","Add new class",newClassParams);
|
|
||||||
buttons.add(newClassButton);
|
|
||||||
HashMap<String,String> hierClassParams=new HashMap<String,String>();
|
|
||||||
if ( (temp=vrequest.getParameter("ontologyUri")) != null) {
|
|
||||||
hierClassParams.put("ontologyUri",temp);
|
|
||||||
}
|
|
||||||
ButtonForm hierClassButton = new ButtonForm("showClassHierarchy","buttonForm","Class hierarchy",hierClassParams);
|
|
||||||
buttons.add(hierClassButton);
|
|
||||||
request.setAttribute("topButtons", buttons);
|
|
||||||
|
|
||||||
RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
|
|
||||||
try {
|
|
||||||
rd.forward(request,response);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void doPost(HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
doGet(request,response);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -69,9 +69,6 @@ public class GrefinePropertyListServlet extends VitroHttpServlet {
|
||||||
ServletOutputStream out = resp.getOutputStream();
|
ServletOutputStream out = resp.getOutputStream();
|
||||||
|
|
||||||
|
|
||||||
// *******
|
|
||||||
// methodology adopted from DatatypePropertiesListingController and ClassHierarchyListingController
|
|
||||||
// *******
|
|
||||||
VClassDao vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
|
VClassDao vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
|
||||||
DataPropertyDao dao = vreq.getUnfilteredWebappDaoFactory().getDataPropertyDao();
|
DataPropertyDao dao = vreq.getUnfilteredWebappDaoFactory().getDataPropertyDao();
|
||||||
String topUri = vreq.getParameter("type");
|
String topUri = vreq.getParameter("type");
|
||||||
|
|
Loading…
Add table
Reference in a new issue