From 30dd807f8efaf6eb4422ada77dc71f8869a07ad3 Mon Sep 17 00:00:00 2001 From: rjy7 Date: Fri, 4 Mar 2011 19:24:31 +0000 Subject: [PATCH] NIHVIVO-1554 Removed controllers and jsps that have been superceded by Freemarker controllers and templates --- productMods/WEB-INF/web.xml | 27 +--- .../setup/VivoMergedListFilteringSetup.java | 116 ------------------ 2 files changed, 1 insertion(+), 142 deletions(-) delete mode 100644 src/edu/cornell/mannlib/vitro/webapp/servlet/setup/VivoMergedListFilteringSetup.java diff --git a/productMods/WEB-INF/web.xml b/productMods/WEB-INF/web.xml index c1e933fb..90448ab4 100644 --- a/productMods/WEB-INF/web.xml +++ b/productMods/WEB-INF/web.xml @@ -198,9 +198,7 @@ --> - - edu.cornell.mannlib.vitro.webapp.servlet.setup.VivoMergedListFilteringSetup - + ontology diff --git a/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/VivoMergedListFilteringSetup.java b/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/VivoMergedListFilteringSetup.java deleted file mode 100644 index 973d1f43..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/VivoMergedListFilteringSetup.java +++ /dev/null @@ -1,116 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.servlet.setup; - -import javax.servlet.ServletContextEvent; - -import net.sf.jga.fn.UnaryFunctor; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.joda.time.DateTime; - -import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement; -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement; -import edu.cornell.mannlib.vitro.webapp.controller.EntityMergedPropertyListController; -import edu.cornell.mannlib.vitro.webapp.dao.filtering.IndividualFiltering; -import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFiltersImpl; - -/** - * This adds an object to the servlet context that will be used by - * EntityMergedPropertiesListController to convert the individual that - * is specified by the URI of the request to an individual that is filtered. - * The object is a function from an Individual to an Individual. The original - * Individual is wrapped in an object that will filter out any object property statements - * to Individuals of core:Position whos date is in the past. - * - * This is related to http://issues.library.cornell.edu/browse/NIHVIVO-984 - * - * @author bdc34 - * - */ -public class VivoMergedListFilteringSetup implements javax.servlet.ServletContextListener { - private static final Log log = LogFactory.getLog(VivoMergedListFilteringSetup.class); - - @Override - public void contextDestroyed(ServletContextEvent arg0) { - } - - @Override - public void contextInitialized(ServletContextEvent arg0) { - log.info("Setting up Vivo Merged List Filtering."); - - UnaryFunctor fn = new UnaryFunctor(){ - - @Override - public Individual fn(Individual subject) { - if( subject != null && subject.isVClass("http://xmlns.com/foaf/0.1/Organization")){ - return new IndividualFiltering(subject, new VitroFiltersImpl(){ - - // @Override - // public UnaryFunctor getIndividualFilter(){ - // return new UnaryFunctor(){ - // @Override - // public Boolean fn(Individual arg) { - // return ! isPast(arg); - // } - // }; - // } - - /** - * This returns true if we should keep the statement, false if we should get rid of the statement - */ - @Override - public UnaryFunctor getObjectPropertyStatementFilter(){ - return new UnaryFunctor(){ - @Override - public Boolean fn(ObjectPropertyStatement arg) { - if( "http://vivoweb.org/ontology/core#organizationForPosition".equals(arg.getPropertyURI())){ - return ! positionInPast(arg.getObject()); - }else{ - return true; - } - } - }; - } - - - }); - }else{ - return subject; - } - } - }; - - EntityMergedPropertyListController.setMergedPropertyListFilter(fn, arg0.getServletContext()); - } - - - private boolean positionInPast(Individual ind){ - - if( ind.isVClass( "http://vivoweb.org/ontology/core#Position" ) ){ - - //positionShortView.jsp does not check core:endDate -// for(DataPropertyStatement stmt : ind.getDataPropertyStatements("http://vivoweb.org/ontology/core#endDate")){ -// DateTime end = new DateTime( stmt.getData() ); -// if( end.isBeforeNow() ) -// return true; -// } - - for(DataPropertyStatement stmt : ind.getDataPropertyStatements("http://vivoweb.org/ontology/core#endYear")){ - int endYear = Integer.MAX_VALUE; - try{ - endYear = Integer.parseInt(stmt.getData()); - }catch(NumberFormatException nfe){ - log.warn("Could not parse year: " + stmt.getData()); - } - int nowYear = (new DateTime()).getYear(); - - //This should use the same logic as positionShortView.jsp - return nowYear > endYear; - } - } - return false; - } -}