From 2e7029b4202c54a61607c86f8ac5779e34e7d915 Mon Sep 17 00:00:00 2001 From: brianjlowe Date: Tue, 15 Nov 2011 19:57:59 +0000 Subject: [PATCH] remove obsolete classes --- .../mannlib/vitro/webapp/beans/Flagpole.java | 45 ----- .../mannlib/vitro/webapp/beans/Link.java | 62 ------- .../mannlib/vitro/webapp/beans/Linktype.java | 24 --- .../mannlib/vitro/webapp/beans/Namespace.java | 45 ----- .../controller/edit/CloneEntityServlet.java | 173 ------------------ .../edit/NamespaceRetryController.java | 141 -------------- .../edit/OntologyRetryController.java | 16 -- .../vitro/webapp/dao/NamespaceDao.java | 22 --- .../vitro/webapp/dao/WebappDaoFactory.java | 2 - .../filtering/WebappDaoFactoryFiltering.java | 5 - .../webapp/dao/jena/GraphSynchronizer.java | 98 ---------- .../webapp/dao/jena/ModelSynchronizer.java | 2 + .../webapp/dao/jena/NamespaceDaoJena.java | 47 ----- .../webapp/dao/jena/WebappDaoFactoryJena.java | 8 - .../dao/jena/{ => event}/CloseEvent.java | 2 +- .../vitro/webapp/utils/OpenUrlMaker.java | 94 ---------- .../webapp/dao/WebappDaoFactoryStub.java | 7 - 17 files changed, 3 insertions(+), 790 deletions(-) delete mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Flagpole.java delete mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Link.java delete mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Linktype.java delete mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Namespace.java delete mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/CloneEntityServlet.java delete mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/NamespaceRetryController.java delete mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/dao/NamespaceDao.java delete mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/GraphSynchronizer.java delete mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/NamespaceDaoJena.java rename webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/{ => event}/CloseEvent.java (75%) delete mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/utils/OpenUrlMaker.java diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Flagpole.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Flagpole.java deleted file mode 100644 index fafad08d4..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Flagpole.java +++ /dev/null @@ -1,45 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.beans; - -/** - * TODO: jc55, Please put a description of this class and its intended use here. - * - */ -public class Flagpole { - private int index=0; - - /** - * What is this the index of? - * @return - */ - public int getIndex() { return index;} - public void setIndex(int i) { index=i; } - - private int numeric=0; - public int getNumeric() { return numeric; } - public void setNumeric(int i) { numeric=i; } - - private String checkboxLabel=null; - public String getCheckboxLabel() { return checkboxLabel; } - public void setCheckboxLabel(String s) { checkboxLabel=s; } - - /** - * What is this the status of? - */ - private String status="normal"; - public String getStatus() { return status; } - public void setStatus(String s) { status=s; } - - /** - * What is i, n and cLable? - * @param i - * @param n - * @param cLabel - */ - public Flagpole(int i, int n, String cLabel) { - index =i; - numeric =n; - checkboxLabel=cLabel; - } -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Link.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Link.java deleted file mode 100644 index a61323560..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Link.java +++ /dev/null @@ -1,62 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.beans; - -// TODO bjl23 this is the link method, nothing to do here, just drawing your attention to it. - -public class Link extends BaseResourceBean { - private String url = null; - private String anchor = null; - private String entityURI = null; - private String typeURI = null; - private String displayRank = "-1"; - private ObjectPropertyStatement objectPropertyStatement = null; - - public String getAnchor() { - return anchor; - } - public void setAnchor(String anchor) { - this.anchor = anchor; - } - public String getEntityURI() { - return entityURI; - } - public void setEntityURI(String entityURI) { - this.entityURI = entityURI; - } - public String getTypeURI() { - return typeURI; - } - public void setTypeURI(String typeURI) { - this.typeURI = typeURI; - } - public String getUrl() { - return url; - } - public void setUrl(String url) { - this.url = url; - } - - public String getDisplayRank() { - return displayRank; - } - - public void setDisplayRank(int rank) { - this.displayRank = String.valueOf(rank); - } - public void setDisplayRank(String rank) { - this.displayRank = rank; - /* try { - this.displayRank = Integer.parseInt(rank); - } catch (NumberFormatException ex) { - this.displayRank = 10; - } */ - } - - public ObjectPropertyStatement getObjectPropertyStatement() { - return objectPropertyStatement; - } - public void setObjectPropertyStatement(ObjectPropertyStatement op) { - this.objectPropertyStatement = op; - } -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Linktype.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Linktype.java deleted file mode 100644 index 6dcb5740b..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Linktype.java +++ /dev/null @@ -1,24 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.beans; - -public class Linktype extends BaseResourceBean { - - private String type = null; - private String generic = null; - - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - - public String getGeneric() { - return generic; - } - public void setGeneric(String generic) { - this.generic = generic; - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Namespace.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Namespace.java deleted file mode 100644 index ad9a2af55..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Namespace.java +++ /dev/null @@ -1,45 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.beans; - -/** - * a class representing a namespace for URI construction - * @author bjl23 - * - */ -public class Namespace { - - private int id = -1; - private String name = null; - private String namespaceURI = null; - private String prefix = null; - - public int getId() { - return id; - } - public void setId(int id) { - this.id = id; - } - - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - public String getNamespaceURI() { - return namespaceURI; - } - public void setNamespaceURI(String nsuri) { - this.namespaceURI = nsuri; - } - - public String getPrefix() { - return prefix; - } - public void setPrefix(String prefix) { - this.prefix = prefix; - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/CloneEntityServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/CloneEntityServlet.java deleted file mode 100644 index 429116d3f..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/CloneEntityServlet.java +++ /dev/null @@ -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; - -import java.io.IOException; -import java.net.URLEncoder; -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.joda.time.DateTime; - -import edu.cornell.mannlib.vedit.beans.LoginStatusBean; -import edu.cornell.mannlib.vedit.controller.BaseEditController; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.EditIndividuals; -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance; -import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; -import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; -import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao; -import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; -import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; - -/** - * NOTE:does not work yet under semweb-align - gets tricky here - * Takes an entity and inserts a (nearly) identical entity with a matching properties list. - * NOTE (BJL23): This currently modifies the objects returned from the daos and calls inserts. - If we go to a system of persistent in-memory objects, this method will need to be updated. - * @author bjl23,jc55 - * */ -public class CloneEntityServlet extends BaseEditController { - private static final String NO_PROPERTY_RESTRICTION = null; - private static final int MIN_EDIT_ROLE=4; - private static final Log log = LogFactory.getLog(CloneEntityServlet.class.getName()); - - public void doPost(HttpServletRequest req, HttpServletResponse response) { - if (!isAuthorizedToDisplayPage(req, response, new Actions(new EditIndividuals()))) { - return; - } - - VitroRequest request = new VitroRequest(req); - try { - - //attempt to clone a tab but if we don't find the parameter 'tabId' the clone a entity - try{ - int id = doCloneTab(request, response); - if( id >= 0){ - response.sendRedirect("tabEdit?id=" + id); - return; - } - }catch(Exception ex){ - log.error("Could not clone tab: " + ex); - getServletConfig().getServletContext().getRequestDispatcher( - "/index.jsp").forward(request, - response); - return; - } - - String individualURI=request.getParameter("uri"); - if (individualURI == null || individualURI.equals("")){ - getServletConfig().getServletContext().getRequestDispatcher("/index.jsp").forward( request, response ); - return; - } - - LoginStatusBean loginBean = LoginStatusBean.getBean(request); - WebappDaoFactory myWebappDaoFactory = request.getFullWebappDaoFactory().getUserAwareDaoFactory(loginBean.getUserURI()); - IndividualDao individualDao = myWebappDaoFactory.getIndividualDao(); - PropertyInstanceDao propertyInstanceDao = myWebappDaoFactory.getPropertyInstanceDao(); - - Individual ind = individualDao.getIndividualByURI(individualURI); - if (ind == null){ log.error("Error retrieving individual "+individualURI); return; } - String newName = request.getParameter("name"); - if (newName != null && newName.length()>0) { - ind.setName(newName); - if (Character.isDigit(newName.charAt(0))) { - newName = "n"+newName; - } - if (ind.getNamespace() != null) { - ind.setURI(ind.getNamespace()+newName.replaceAll("\\W","")); - } else { - ind.setURI(VitroVocabulary.vitroURI + newName.replaceAll("\\W","")); - } - } else { - ind.setName("CLONE OF "+ind.getName()); - } - - String cloneURI=individualDao.insertNewIndividual(ind); - if (cloneURI == null){ log.error("Error inserting cloned individual"); return; } - - Collection PIColl=propertyInstanceDao.getExistingProperties(individualURI, NO_PROPERTY_RESTRICTION); - Iterator it=PIColl.iterator(); - while (it.hasNext()){ - PropertyInstance currPI=(PropertyInstance)it.next(); - currPI.setSubjectEntURI(cloneURI); - propertyInstanceDao.insertProp(currPI); - } - - String encodedCloneURI = URLEncoder.encode(cloneURI, "UTF-8"); - response.sendRedirect("entityEdit?uri="+encodedCloneURI); - //response.sendRedirect("entity?home="+portalIdStr+"&id="+newEntityId); - - } catch (Exception ex) { - log.error( ex.getMessage() ); - ex.printStackTrace(); - } -} - -public Date parseStringToDate(String str) { - if (str.trim() == "") return null; - int year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour; - try { - year = Integer.parseInt(str.substring(0,4)); - monthOfYear = Integer.parseInt(str.substring(5,7)); - dayOfMonth = Integer.parseInt(str.substring(8,10)); - hourOfDay = Integer.parseInt(str.substring(11,13)); - minuteOfHour = str.length()>13 ? Integer.parseInt(str.substring(14,16)) : 0; - if (str.length()>16) { - String suppStr = str.substring(17); - if (suppStr.equalsIgnoreCase("pm") || suppStr.equalsIgnoreCase("p.m.")) { - hourOfDay = hourOfDay < 12 ? hourOfDay + 12 : hourOfDay; - } - } - log.warn("parsed clone timekey ["+str+"] to year: "+year+", month: "+monthOfYear+", day: "+dayOfMonth+", hour: "+hourOfDay+", minute: "+minuteOfHour); - } catch (NumberFormatException ex) { - log.error("Could not parse string "+str+" based on expected format 'yyyy-mm-dd hh-mm'"); - return null; - } - return new DateTime(year,monthOfYear,dayOfMonth,hourOfDay,minuteOfHour,0,0).toDate(); -} - - -public void doGet(HttpServletRequest request, HttpServletResponse response) -throws ServletException, IOException { - doPost(request,response); -} - -/** - * Attempts to clone a tab. - * This will check for the parameter 'tabId' and if it exists - * this method will call cloneTabDb to do the actual database inserts. - * If no parameter is found then this method will return -1. - * - * @param request - * @param response - * @return tab id of newly cloned tab or -1 if no tabId parameter was found - * in the http request. - */ -private int doCloneTab(HttpServletRequest request, - HttpServletResponse response) throws Exception { - String tabIdStr = request.getParameter("tabId"); - if (tabIdStr == null) - return -1; - - int tabId = -1; - try { - tabId = Integer.parseInt(tabIdStr); - } catch (NumberFormatException ex) { - throw new Exception("error doCloneTab()-- could not parse " - + tabIdStr + " as an integer value"); - } - return 1; // getFacade().cloneTab(tabId); -} - - - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/NamespaceRetryController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/NamespaceRetryController.java deleted file mode 100644 index 9354d336d..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/NamespaceRetryController.java +++ /dev/null @@ -1,141 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.controller.edit; - -import java.io.IOException; - -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.EditProcessObject; -import edu.cornell.mannlib.vedit.beans.FormObject; -import edu.cornell.mannlib.vedit.controller.BaseEditController; -import edu.cornell.mannlib.vedit.forwarder.PageForwarder; -import edu.cornell.mannlib.vedit.util.FormUtils; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.UseMiscellaneousAdminPages; -import edu.cornell.mannlib.vitro.webapp.beans.Namespace; -import edu.cornell.mannlib.vitro.webapp.controller.Controllers; -import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; -import edu.cornell.mannlib.vitro.webapp.dao.NamespaceDao; - -public class NamespaceRetryController extends BaseEditController { - - private static final Log log = LogFactory.getLog(NamespaceRetryController.class.getName()); - - public void doPost (HttpServletRequest req, HttpServletResponse response) { - if (!isAuthorizedToDisplayPage(req, response, new Actions(new UseMiscellaneousAdminPages()))) { - return; - } - - VitroRequest request = new VitroRequest(req); - - //create an EditProcessObject for this and put it in the session - EditProcessObject epo = super.createEpo(request); - - /*for testing*/ - Namespace testMask = new Namespace(); - epo.setBeanClass(Namespace.class); - epo.setBeanMask(testMask); - - String action = "insert"; - if (request.getFullWebappDaoFactory() == null) - log.error("null CoreDaoFactory"); - NamespaceDao namespaceDao = request.getFullWebappDaoFactory().getNamespaceDao(); - //VitroFacade facade = getFacade(); - //epo.setFacade(facade); - - Namespace namespaceForEditing = null; - if (!epo.getUseRecycledBean()){ - if (request.getParameter("id") != null) { - int id = Integer.parseInt(request.getParameter("id")); - if (id > 0) { - try { - namespaceForEditing = namespaceDao.getNamespaceById(id); - action = "update"; - } catch (NullPointerException e) { - log.error("Need to implement 'record not found' error message."); - } - } - } else { - namespaceForEditing = new Namespace(); - } - epo.setOriginalBean(namespaceForEditing); - } else { - namespaceForEditing = (Namespace) epo.getNewBean(); - action = "update"; - log.error("using newBean"); - } - - //make a simple mask for the class's id - Object[] simpleMaskPair = new Object[2]; - simpleMaskPair[0]="Id"; - simpleMaskPair[1]=Integer.valueOf(namespaceForEditing.getId()); - epo.getSimpleMask().add(simpleMaskPair); - - //set up any listeners - - //make a postinsert pageforwarder that will send us to a new class's fetch screen - epo.setPostInsertPageForwarder(new NamespaceInsertPageForwarder()); - //make a postdelete pageforwarder that will send us to the list of classes - - //set the getMethod so we can retrieve a new bean after we've inserted it - try { - Class[] args = new Class[1]; - args[0] = int.class; - epo.setGetMethod(namespaceDao.getClass().getDeclaredMethod("getNamespaceById",args)); - } catch (NoSuchMethodException e) { - log.error("NamespaceRetryController could not find the namespaceById method in the facade"); - } - - - FormObject foo = new FormObject(); - - foo.setErrorMap(epo.getErrMsgMap()); - - epo.setFormObject(foo); - - FormUtils.populateFormFromBean(namespaceForEditing,action,foo,epo.getBadValueMap()); - - RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); - request.setAttribute("bodyJsp","/templates/edit/formBasic.jsp"); - request.setAttribute("formJsp","/templates/edit/specific/namespace_retry.jsp"); - request.setAttribute("scripts","/templates/edit/formBasic.js"); - request.setAttribute("title","Namespace Editing Form"); - request.setAttribute("_action",action); - request.setAttribute("unqualifiedClassName","Namespace"); - setRequestAttributes(request,epo); - - try { - rd.forward(request, response); - } catch (Exception e) { - log.error("NamespaceRetryController could not forward to view."); - log.error(e.getMessage()); - log.error(e.getStackTrace()); - } - - } - - public void doGet (HttpServletRequest request, HttpServletResponse response) { - doPost(request, response); - } - - class NamespaceInsertPageForwarder implements PageForwarder { - - public void doForward(HttpServletRequest request, HttpServletResponse response, EditProcessObject epo){ - String newNamespaceUrl = "fetch?queryspec=private_namespacev&postGenLimit=-1&linkwhere=namespaces.id="; - Namespace ns = (Namespace) epo.getNewBean(); - newNamespaceUrl += ns.getId(); - try { - response.sendRedirect(newNamespaceUrl); - } catch (IOException ioe) { - log.error("NamespaceInsertPageForwarder could not send redirect."); - } - } - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/OntologyRetryController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/OntologyRetryController.java index b4f0d3a8a..a814dda62 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/OntologyRetryController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/OntologyRetryController.java @@ -4,8 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.controller.edit; import java.io.IOException; import java.net.URLEncoder; -import java.util.HashMap; -import java.util.List; import javax.servlet.RequestDispatcher; import javax.servlet.http.HttpServletRequest; @@ -16,7 +14,6 @@ import org.apache.commons.logging.LogFactory; import edu.cornell.mannlib.vedit.beans.EditProcessObject; import edu.cornell.mannlib.vedit.beans.FormObject; -import edu.cornell.mannlib.vedit.beans.Option; import edu.cornell.mannlib.vedit.controller.BaseEditController; import edu.cornell.mannlib.vedit.forwarder.PageForwarder; import edu.cornell.mannlib.vedit.forwarder.impl.UrlForwarder; @@ -26,7 +23,6 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.EditOntolo import edu.cornell.mannlib.vitro.webapp.beans.Ontology; import edu.cornell.mannlib.vitro.webapp.controller.Controllers; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; -import edu.cornell.mannlib.vitro.webapp.dao.NamespaceDao; import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; public class OntologyRetryController extends BaseEditController { @@ -52,7 +48,6 @@ public class OntologyRetryController extends BaseEditController { OntologyDao oDao = request.getFullWebappDaoFactory().getOntologyDao(); epo.setDataAccessObject(oDao); - NamespaceDao nDao = request.getFullWebappDaoFactory().getNamespaceDao(); Ontology ontologyForEditing = null; if (!epo.getUseRecycledBean()){ @@ -98,17 +93,6 @@ public class OntologyRetryController extends BaseEditController { FormObject foo = new FormObject(); - HashMap optionMap = new HashMap(); - try { - List namespaceIdList = FormUtils.makeOptionListFromBeans(nDao.getAllNamespaces(),"Id","Name",Integer.valueOf(ontologyForEditing.getNamespaceId()).toString(),null,false); - namespaceIdList.add(0,new Option("-1","none", false)); - optionMap.put("NamespaceId", namespaceIdList); - } catch (Exception e) { - log.error(this.getClass().getName()); - e.printStackTrace(); - } - foo.setOptionLists(optionMap); - foo.setErrorMap(epo.getErrMsgMap()); epo.setFormObject(foo); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/NamespaceDao.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/NamespaceDao.java deleted file mode 100644 index 7598b3a5b..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/NamespaceDao.java +++ /dev/null @@ -1,22 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.dao; - -import edu.cornell.mannlib.vitro.webapp.beans.Namespace; - -import java.util.List; - -public interface NamespaceDao { - - public abstract List getAllNamespaces(); - - public abstract Namespace getNamespaceById(int namespaceId); - - int insertNewNamespace(Namespace namespace); - - void updateNamespace(Namespace ont); - - void deleteNamespace(int namespaceId); - - void deleteNamespace(Namespace namespace); -} \ No newline at end of file diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactory.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactory.java index 4bc12674f..eeeb844ad 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactory.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactory.java @@ -127,8 +127,6 @@ public interface WebappDaoFactory { public PropertyGroupDao getPropertyGroupDao(); - public NamespaceDao getNamespaceDao(); - public PropertyInstanceDao getPropertyInstanceDao(); public PageDao getPageDao(); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/WebappDaoFactoryFiltering.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/WebappDaoFactoryFiltering.java index e018d21b7..405421ddd 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/WebappDaoFactoryFiltering.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/WebappDaoFactoryFiltering.java @@ -14,7 +14,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao; import edu.cornell.mannlib.vitro.webapp.dao.DisplayModelDao; import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; import edu.cornell.mannlib.vitro.webapp.dao.MenuDao; -import edu.cornell.mannlib.vitro.webapp.dao.NamespaceDao; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao; import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; @@ -177,10 +176,6 @@ public class WebappDaoFactoryFiltering implements WebappDaoFactory { return innerWebappDaoFactory.getDatatypeDao(); } - public NamespaceDao getNamespaceDao() { - return innerWebappDaoFactory.getNamespaceDao(); - } - public OntologyDao getOntologyDao() { return innerWebappDaoFactory.getOntologyDao(); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/GraphSynchronizer.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/GraphSynchronizer.java deleted file mode 100644 index 841a92863..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/GraphSynchronizer.java +++ /dev/null @@ -1,98 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.dao.jena; - -import java.util.Iterator; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.hp.hpl.jena.graph.Graph; -import com.hp.hpl.jena.graph.GraphEvents; -import com.hp.hpl.jena.graph.GraphListener; -import com.hp.hpl.jena.graph.Triple; - -public class GraphSynchronizer implements GraphListener { - - private static final Log log = LogFactory.getLog(GraphSynchronizer.class.getName()); - - private Graph g; - - public GraphSynchronizer (Graph synchronizee) { - g = synchronizee; - } - - public void notifyAddArray(Graph arg0, Triple[] arg1) { - g.getBulkUpdateHandler().add(arg1); - } - - - public void notifyAddGraph(Graph arg0, Graph arg1) { - g.getBulkUpdateHandler().add(arg1); - - } - - - public void notifyAddIterator(Graph arg0, Iterator arg1) { - g.getBulkUpdateHandler().add(arg1); - } - - - public void notifyAddList(Graph arg0, List arg1) { - g.getBulkUpdateHandler().add(arg1); - } - - public void notifyAddTriple(Graph arg0, Triple arg1) { - g.add(arg1); - } - - - public void notifyDeleteArray(Graph arg0, Triple[] arg1) { - g.getBulkUpdateHandler().delete(arg1); - } - - - public void notifyDeleteGraph(Graph arg0, Graph arg1) { - g.getBulkUpdateHandler().delete(arg1); - } - - public void notifyDeleteIterator(Graph arg0, Iterator arg1) { - g.getBulkUpdateHandler().delete(arg1); - } - - public void notifyDeleteList(Graph arg0, List arg1) { - g.getBulkUpdateHandler().delete(arg1); - } - - public void notifyDeleteTriple(Graph arg0, Triple arg1) { - g.delete(arg1); - log.trace("Delete triple"); - if (arg1.getObject().isLiteral()) { - log.trace(arg1.getObject().getLiteralLexicalForm()); - } else if (arg1.getObject().isVariable()) { - log.trace("Triple object is variable"); - } else if (arg1.getObject().isURI()) { - log.trace(arg1.getObject().getURI()); - } else if (arg1.getObject().isBlank()) { - log.trace("Triple object is blank"); - } else if (arg1.getObject().isConcrete()) { - log.trace("Triple object is concrete"); - } - log.trace(arg1.getObject().toString()); - } - - public void notifyEvent(Graph arg0, Object arg1) { - // ontModel.removeAll(s,p,o) doesn't trigger a notifyDeleteTriple() !?! - // So, I'm doing this silly thing to make sure we see the deletion. - // What else is lurking around the corner? - if (arg1 instanceof GraphEvents) { - GraphEvents ge = ((GraphEvents) arg1); - Object content = ge.getContent(); - if (ge.getTitle().equals("remove") && content instanceof Triple) { - notifyDeleteTriple( arg0, (Triple) content ); - } - } - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ModelSynchronizer.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ModelSynchronizer.java index 76ebbe2d1..f4fcb14d4 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ModelSynchronizer.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ModelSynchronizer.java @@ -9,6 +9,8 @@ import com.hp.hpl.jena.rdf.model.ModelChangedListener; import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.rdf.model.StmtIterator; +import edu.cornell.mannlib.vitro.webapp.dao.jena.event.CloseEvent; + /** * Simple change listener to keep a model (the 'synchronizee') in synch with the model with which it is registered. * @author bjl23 diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/NamespaceDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/NamespaceDaoJena.java deleted file mode 100644 index 8b406f6c2..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/NamespaceDaoJena.java +++ /dev/null @@ -1,47 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.dao.jena; - -import edu.cornell.mannlib.vitro.webapp.beans.Namespace; -import edu.cornell.mannlib.vitro.webapp.dao.NamespaceDao; -import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; - -import java.util.HashSet; -import java.util.List; - -import com.hp.hpl.jena.ontology.OntModel; - -public class NamespaceDaoJena extends JenaBaseDao implements NamespaceDao { - - public NamespaceDaoJena(WebappDaoFactoryJena wadf) { - super(wadf); - } - - public void deleteNamespace(int namespaceId) { - // should be deprecated - } - - public void deleteNamespace(Namespace namespace) { - // may not need/want to implement this - } - - public List getAllNamespaces() { - // TODO Auto-generated method stub - return null; - } - - public Namespace getNamespaceById(int namespaceId) { - // should be deprecated - return null; - } - - public int insertNewNamespace(Namespace namespace) { - // may not need/want to implement this - return 0; - } - - public void updateNamespace(Namespace ont) { - // may not need/want to implement this - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/WebappDaoFactoryJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/WebappDaoFactoryJena.java index 98e3b4a63..aa7682f0e 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/WebappDaoFactoryJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/WebappDaoFactoryJena.java @@ -37,7 +37,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao; import edu.cornell.mannlib.vitro.webapp.dao.DisplayModelDao; import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; import edu.cornell.mannlib.vitro.webapp.dao.MenuDao; -import edu.cornell.mannlib.vitro.webapp.dao.NamespaceDao; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao; import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; @@ -349,13 +348,6 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { return individualDao; } - NamespaceDao namespaceDao = null; - public NamespaceDao getNamespaceDao() { - if( namespaceDao == null ) - namespaceDao = new NamespaceDaoJena(this); - return namespaceDao; - } - ObjectPropertyStatementDao objectPropertyStatementDao = null; public ObjectPropertyStatementDao getObjectPropertyStatementDao() { if( objectPropertyStatementDao == null ) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/CloseEvent.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/event/CloseEvent.java similarity index 75% rename from webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/CloseEvent.java rename to webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/event/CloseEvent.java index 17d8c78d9..ccaccdc70 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/CloseEvent.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/event/CloseEvent.java @@ -1,6 +1,6 @@ /* $This file is distributed under the terms of the license in /doc/license.txt$ */ -package edu.cornell.mannlib.vitro.webapp.dao.jena; +package edu.cornell.mannlib.vitro.webapp.dao.jena.event; public class CloseEvent { // used to close synchronized models via Jena's event system diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/OpenUrlMaker.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/OpenUrlMaker.java deleted file mode 100644 index d196eb18f..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/OpenUrlMaker.java +++ /dev/null @@ -1,94 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.utils; - -import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement; -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.Link; - -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * makes a cornell library openUrl for - * an entity using info found in DataProps. - * - * @author bdc34 - * - */ -public class OpenUrlMaker { - //These are datapropIds that are acceptable values for the given field - private int atitle[] = {36}; - private int spage[] = {39}; - private int aulast[] = {}; - private int issue[] = {53}; - private int volume[] = {54}; - private int auint[] = {}; - private int doi[] = {55}; - private int aufull[] = {44}; - - private Pattern spage_regex = Pattern.compile("[^0-9]*([0-9]+)[^0-9]*.*"); - //private Pattern spage_regex = Pattern.compile("([0-9]*)[^0-9]*([0-9]*)[^0-9]*.*"); - private Pattern aulast_regex = Pattern.compile("([^\\s]*)[\\s]*.*"); - private Pattern firstNumer_regex = Pattern.compile("[^0-9]*([0-9]+)[^0-9]*.*"); - /** - * Uses the DatatypeProperty objects for the Entity - * to make a OpenURL for the Cornell library resolver. - * - * @param ent - * @return returns Link object if one can be made, null otherwise. - */ - public Link makeOpenUrlForEntity(Individual ent){ - Link oUrl = null; - - String atitle = null; - String spage = null; - String aulast = null; - String issue = null; - String volume = null; - String auint = null; - String doi = null; - String aufull = null; - - List dataPropertyStmts = ent.getDataPropertyStatements(); - for( DataPropertyStatement dataPropertyStmt : dataPropertyStmts){ - if( found( this.atitle, dataPropertyStmt ) ){ - atitle = escape(dataPropertyStmt.getData()); - } else - if( found( this.spage, dataPropertyStmt ) ){ - Matcher m = this.spage_regex.matcher(dataPropertyStmt.getData()); - if( m.matches() && m.groupCount() > 0 ) - spage = m.group(1); - } else - if( found( this.aulast, dataPropertyStmt ) ){ - Matcher m = this.aulast_regex.matcher(dataPropertyStmt.getData()); - if( m.matches() && m.groupCount() > 0 ) - aulast = m.group(1); - } else - if( found( this.issue, dataPropertyStmt ) ){ - Matcher m = this.firstNumer_regex.matcher(dataPropertyStmt.getData()); - if( m.matches() && m.groupCount() > 0 ) - issue = m.group(1); - } else - if( found( this.volume, dataPropertyStmt ) ){ - - } else if( found( this.auint, dataPropertyStmt ) ){ - } else if( found( this.doi, dataPropertyStmt ) ){ - } else if( found( this.aufull, dataPropertyStmt ) ){ - } - } - - - - return oUrl; - } - - private boolean found( int[] ids, DataPropertyStatement dataPropertyStmt){ - return true; - } - - private String escape(String in){ - return in; - } -} diff --git a/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactoryStub.java b/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactoryStub.java index e9a36b2bb..48f749264 100644 --- a/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactoryStub.java +++ b/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactoryStub.java @@ -14,7 +14,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao; import edu.cornell.mannlib.vitro.webapp.dao.DisplayModelDao; import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; import edu.cornell.mannlib.vitro.webapp.dao.MenuDao; -import edu.cornell.mannlib.vitro.webapp.dao.NamespaceDao; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao; import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; @@ -200,12 +199,6 @@ public class WebappDaoFactoryStub implements WebappDaoFactory { "WebappDaoFactory.getPropertyGroupDao() not implemented."); } - @Override - public NamespaceDao getNamespaceDao() { - throw new RuntimeException( - "WebappDaoFactory.getNamespaceDao() not implemented."); - } - @Override public PropertyInstanceDao getPropertyInstanceDao() { throw new RuntimeException(