diff --git a/webapp/ontologies/system/vitro-0.7.owl b/webapp/ontologies/system/vitro-0.7.owl index 1050aee67..13fc4843c 100644 --- a/webapp/ontologies/system/vitro-0.7.owl +++ b/webapp/ontologies/system/vitro-0.7.owl @@ -52,8 +52,6 @@ xmlns:vitro="&vitro;" - - @@ -147,76 +145,11 @@ xmlns:vitro="&vitro;" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Tab.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Tab.java deleted file mode 100755 index e8ba9d570..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Tab.java +++ /dev/null @@ -1,363 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.beans; - -/** - * @version 1 2005-08-27 - * @authors Jon Corson-Rikert, Brian Caruso - * - * A tab is a browsing facet within the application. - * - * UPDATES - * BDC 2005-12-02 : updated to work with refactored db - * 2005-10-19 jc55 changed test on date of entity sunrise field to <= from < when looking at sunrise (a negative value in tab dayLimit) - * 2005-09-13 jc55 Added ability for tabs to have a mix of autolinked and manual entries - search for "mixed" - * 2005-09-01 jc55 Made entity.name the default sort for related entities (had been none) - * 2005-08-31 jc55 First version posted 8/31/05 - */ - -import edu.cornell.mannlib.vitro.webapp.dao.TabEntityFactory; - -import java.text.Collator; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; - -/** - Data Structure for a vitro display tab. - Tab is based on jcr's bean.TabBean. -*/ - - -public class Tab implements java.io.Serializable, Comparable { // class to hold a single tab's values - - private static final long serialVersionUID = 7042411727511586634L; - // this next is a klugey way to deal with tab flags while we work out how to get the same functionality via relationships - public final static int TAB_FILTER_FLAG2 =2; - public final static int TAB_FILTER_FLAG3 =3; - public final static int TAB_FILTER_FLAG_BOTH=5; - - /* tab types, hardcoded from tabtypes table */ - public final static int UNSPECIFIED = 0; - public final static int CATEGORY = 18; - public final static int SUBCOLLECTION = 20; - public final static int COLLECTION = 22; - public final static int SECONDARY_TAB = 24; - public final static int PRIMARY_TAB_CONTENT = 26; - public final static int PRIMARY_TAB = 28; - - public Tab(int id){ - tabId=id; - } - - public String getTabDepthName(){ - String name = "UNSPECIFIED"; - switch (getTabtypeId()){ - case PRIMARY_TAB: name = "primary"; break; - - case SECONDARY_TAB: - case PRIMARY_TAB_CONTENT: name = "secondary"; break; - - case CATEGORY: name = "category"; break; - case SUBCOLLECTION: name = "subcollection"; break; - case COLLECTION: name = "collection"; break; - - default: name = "unknownTabType"; - } - return name; - } -/* // system variables - private boolean initialized; - public boolean isInitialized() {return initialized;} - public void setInitialized(boolean val) {initialized=val;} - - private String sessionIdStr; - public void getSessionIdStr() {return sessionIdStr;} - public void setSessionIdStr(String val) {sessionIdStr=val;} - */ - // identifiers - private int tabId=0; // primary key - public void setTabId(int val) {tabId=val;} - public int getTabId() {return tabId;} - - private int tabtypeId=0; -// 0 unspecified, 28 primary tab,26 primary tab content,24 secondary tab,22 collection,20 subcollection,18 subcollection category - public void setTabtypeId(int val) {tabtypeId=val;} - public int getTabtypeId() {return tabtypeId;} - - private int userId=0; - public void setUserId(int val) {userId=val;} - public int getUserId() {return userId;} - - private int statusId=0; - // 0=visible to all,1=anonymous guests,2=registered user,3=individual user,4=system,5=webmaster - public void setStatusId(int val) {statusId=val;} - public int getStatusId() {return statusId;} - - // display controls - private int dayLimit = 0; // positive for days in the future, negative for days in the past - public void setDayLimit(int val) {dayLimit=val;} - public int getDayLimit() {return dayLimit;} - - private int galleryRows=0; // triggers display as a gallery; controls # of rows of images - public void setGalleryRows(int val) {galleryRows=val;} - public int getGalleryRows() {return galleryRows;} - - private int galleryCols=0; // controls number of columns of images - public void setGalleryCols(int val) {galleryCols=val;} - public int getGalleryCols() {return galleryCols;} - - private int imageWidth=150; // width of image display in pixels - public void setImageWidth(int val) {imageWidth=val;} - public int getImageWidth() {return imageWidth;} - - private String entitySortField=null; // which entity field to sort by; null assumes sort by entity name; timekey another frequent option - public void setEntitySortField(String val) {entitySortField=val;} - public String getEntitySortField() {return entitySortField;} - - private String entitySortDirection=null; // null for normal; "desc" for descending, as with timekey - public void setEntitySortDirection(String val) {entitySortDirection=val;} - public String getEntitySortDirection() {return entitySortDirection;} - - // filter controls - private String flag2Set=null; - public void setFlag2Set(String val) {flag2Set=val;} - public String getFlag2Set() {return flag2Set;} - - private int flag2Numeric=0; // calculate from flag2Set; not a database field - public void setFlag2Numeric(int val) {flag2Numeric=val;} - public int getFlag2Numeric() {return flag2Numeric;} - - private String flag2Mode="include"; // enum('include','omit') - public void setFlag2Mode(String val) {flag2Mode=val;} - public String getFlag2Mode() {return flag2Mode;} - - private String flag3Set=null; - public void setFlag3Set(String val) {flag3Set=val;} - public String getFlag3Set() {return flag3Set;} - - private int flag3Numeric=0; // calculate from flag3Set; not a database field - public void setFlag3Numeric(int val) {flag3Numeric=val;} - public int getFlag3Numeric() {return flag3Numeric;} - - private String flag3Mode="include"; // enum('include','omit') - public void setFlag3Mode(String val) {flag3Mode=val;} - public String getFlag3Mode() {return flag3Mode;} - - // content - private String title=null; - public void setTitle(String val) {title=val;} - public String getTitle() {return title;} - - private String moreTag=null; // shorter or more informal version of title for use in "More ___________" - public void setMoreTag(String val) {moreTag=val;} - public String getMoreTag() {return moreTag;} - - private String description=null; - public void setDescription(String val) {description=val;} - public String getDescription() {return description;} - - private String body=null; - public void setBody(String val) {body=val;} - public String getBody() {return body;} - - private String rssURL=null; - public void setRssURL(String val) {rssURL=val;} - public String getRssURL() {return rssURL;} - - private int displayRank = 0; - public void setDisplayRank(int dr) {displayRank=dr;} - public int getDisplayRank() {return displayRank;} - - /** - * entityLinkMethod indicates how entities should be associated with this tab. - * valid values are 'manual' 'auto' and 'mixed' - */ - private String entityLinkMethod="manual"; // enum('manual','auto','mixed') - public void setEntityLinkMethod(String val) {entityLinkMethod=val;} - public String getEntityLinkMethod() {return entityLinkMethod;} - - private int autolinkTypeCount=0; // a dynamic count of how many etypes are set to be linked to tab - public void setAutolinkTypeCount(int val) {autolinkTypeCount=val;} - public int getAutolinkTypeCount() {return autolinkTypeCount;} - - private int alphaFilteredEntityCount=0; // a count of how many entities are linked to tab, using alpha filters - public void setAlphaFilteredEntityCount(int val) {alphaFilteredEntityCount=val;} - public int getAlphaFilteredEntityCount() {return alphaFilteredEntityCount;} - - private int alphaUnfilteredEntityCount=0; // a count of how many entities are linked to tab, regardless of filters - public void setAlphaUnfilteredEntityCount(int val) {alphaUnfilteredEntityCount=val;} - public int getAlphaUnfilteredEntityCount() {return alphaUnfilteredEntityCount;} - - private Collection relatedEntityList=null; // an ArrayList of EntityBeans - - public void setRelatedEntityList(Collection val) {relatedEntityList=val;} - - public Collection getRelatedEntityList(String alpha){ - if (grabEntityFactory()==null && relatedEntityList == null) - return new LinkedList(); // BJL23 added to avoid ugly NPEs when creating new portals - else if( alpha != null && grabEntityFactory() != null) - return grabEntityFactory().getRelatedEntites(alpha); - else if(relatedEntityList != null ) - return relatedEntityList; - else - return grabEntityFactory().getRelatedEntites(null); - } - - public Collection getRelatedEntities(){ return getRelatedEntityList(null); } - - private Collection childTabList=null; - public void setChildTabs(Collection val) {childTabList=val;} - public Collection getChildTabs() {return childTabList;} - - private Collection getChildTabList(int tabType){ - LinkedList rv = new LinkedList(); - if( getChildTabs() != null ){ - Iterator it = getChildTabs().iterator(); - while(it.hasNext()){ - Tab sub = (Tab)it.next(); - if( sub.getTabtypeId() == tabType){ - rv.add(sub); - } - } - } - return rv; - } - - private TabEntityFactory entityFactory = null; - public TabEntityFactory grabEntityFactory() { - return entityFactory; - } - public void placeEntityFactory(TabEntityFactory entityFactory) { - this.entityFactory = entityFactory; - } - public String getEntityFactoryDesc(){ - if( grabEntityFactory() == null ) - return "entity factory for this tab is null"; - else - return grabEntityFactory().toString(); - } - - public boolean isGallery() { - if ( getGalleryCols() > 0 && getGalleryRows() > 0) - return true; - else - return false; - } - - /** Gets only children tabs of type SECONDARY_TAB. */ - public Collection filterChildrenForSubtabs(){ - Collection rv = new LinkedList(); - rv.addAll(getChildTabList(SECONDARY_TAB)); - rv.addAll(getChildTabList(SUBCOLLECTION)); - rv.addAll(getChildTabList(COLLECTION)); - rv.addAll(getChildTabList(CATEGORY)); - return rv; - } - - /** gets only children tabs of type PRIMARY_TAB_CONTENT. */ - public Collection filterChildrenForContentTabs(){ - return getChildTabList(PRIMARY_TAB_CONTENT); - } - - - // required parameter-less constructor - public Tab() { - // identifiers - tabId = -1; // primary key of tabs table is auto_increment so this could be 0; - tabtypeId = 0; - userId = 0; - statusId = 0; - - // display controls - dayLimit=0; - galleryRows=0; - galleryCols=0; - imageWidth=150; - entitySortField="name"; - entitySortDirection=null; - - // filter controls - flag2Set=null; - flag2Numeric=0; - flag2Mode="include"; - flag3Set=null; - flag3Numeric=0; - flag3Mode="include"; - - // content - title="untitled"; - moreTag=null; - description=null; - body=null; - rssURL=null; - - entityLinkMethod="auto"; - autolinkTypeCount=0; - alphaFilteredEntityCount=0; - alphaUnfilteredEntityCount=0; - relatedEntityList=null; - childTabList=null; - } - - public String toString(){ - return "Tab id " + getTabId() + " children: " + - (getChildTabs()!=null? getChildTabs().size(): "null"); - } - - public String toHTML() { - String output = "

Tab:

    "; - output += "
  • tab id: [" + tabId + "]
  • "; - output += "
  • tabtype id: [" + tabtypeId + "]
  • "; - output += "
  • user id: [" + userId + "]
  • "; - output += "
  • day limit: [" + dayLimit + "]
  • "; - output += "
  • gallery rows: [" + galleryRows + "]
  • "; - output += "
  • gallery columns: [" + galleryCols + "]
  • "; - output += "
  • image width [" + imageWidth + "]
  • "; - output += "
  • entity sort field: [" + entitySortField + "]
  • "; - output += "
  • entity sort direction [" + entitySortDirection + "]
  • "; - output += "
  • flag2Set: [" + flag2Set + "]
  • "; - output += "
  • flag2Numeric: [" + flag2Numeric + "]
  • "; - output += "
  • flag2Mode: [" + flag2Mode + "]
  • "; - output += "
  • flag3Set: [" + flag3Set + "]
  • "; - output += "
  • flag3Numeric: [" + flag3Numeric + "]
  • "; - output += "
  • flag3Mode: [" + flag3Mode + "]
  • "; - output += "
  • title: [" + title + "]
  • "; - output += "
  • moreTag: [" + moreTag + "]
  • "; - output += "
  • description: [" + description + "]
  • "; - output += "
  • body: [" + body + "]
  • "; - output += "
  • rssURL: [" + rssURL + "]
  • "; - output += "
  • entity link method: [" + entityLinkMethod + "]
  • "; - output += "
  • autolink type count: [" + autolinkTypeCount + "]
  • "; - output += "
  • alpha filtered entity count [" + alphaFilteredEntityCount + "]
  • "; - output += "
  • alpha UNfiltered entity count [" + alphaUnfilteredEntityCount + "]
  • "; - if (relatedEntityList!=null && relatedEntityList.size()>0) { - output += "
  • related entities [" + relatedEntityList.toString() + "]
  • "; - } - if (relatedEntityList!=null && relatedEntityList.size()>0) { - output += "
  • related entities [" + relatedEntityList.toString() + "]
  • "; - } - output += "

"; - return output; - } - public boolean isManualLinked() { - return "manual".equalsIgnoreCase(entityLinkMethod); - } - public boolean isAutoLinked(){ - return "auto".equalsIgnoreCase(entityLinkMethod); - } - public boolean isMixedLinked(){ - return "mixed".equalsIgnoreCase(entityLinkMethod); - } - - // sort by title - public int compareTo(Tab t2) { - Collator collator = Collator.getInstance(); - if (t2 == null) { - return 1; - } else { - return collator.compare(this.getTitle(),t2.getTitle()); - } - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/TabIndividualRelation.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/TabIndividualRelation.java deleted file mode 100644 index 508d3666a..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/TabIndividualRelation.java +++ /dev/null @@ -1,40 +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 TabIndividualRelation { - - private String uri = null; - private int tabId = -1; - private String entURI = null; - private int displayRank = -1; - - public String getURI() { - return uri; - } - public void setURI(String URI) { - this.uri = URI; - } - - public int getTabId() { - return tabId; - } - public void setTabId(int tabId) { - this.tabId = tabId; - } - - public String getEntURI() { - return entURI; - } - public void setEntURI(String entURI) { - this.entURI = entURI; - } - - public int getDisplayRank() { - return displayRank; - } - public void setDisplayRank(int displayRank) { - this.displayRank = displayRank; - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/TabVClassRelation.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/TabVClassRelation.java deleted file mode 100644 index f293b1b3e..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/TabVClassRelation.java +++ /dev/null @@ -1,32 +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 TabVClassRelation { - - private int id = -1; - private int tabId = -1; - private String vClassURI= null; - - public int getId() { - return id; - } - public void setId(int id) { - this.id = id; - } - - public int getTabId() { - return tabId; - } - public void setTabId(int tabId) { - this.tabId = tabId; - } - - public String getVClassURI() { - return vClassURI; - } - public void setVClassURI(String vClassURI) { - this.vClassURI = vClassURI; - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/JSONServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/JSONServlet.java index 35defa3b0..72c3ade99 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/JSONServlet.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/JSONServlet.java @@ -33,8 +33,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.DataProperty; import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; -import edu.cornell.mannlib.vitro.webapp.controller.TabEntitiesController.PageRecord; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController; +import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController.PageRecord; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabController.java deleted file mode 100755 index 9474980af..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabController.java +++ /dev/null @@ -1,178 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.controller; - -import java.io.IOException; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.jsp.JspException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; -import edu.cornell.mannlib.vitro.webapp.web.TabWebUtil; - -public class TabController extends VitroHttpServlet { - private static final long serialVersionUID = -5340982482787800013L; - private static final Log log = LogFactory.getLog(TabController.class.getName()); - - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException,IOException { - doGet(request, response); - } - - public void doGet( HttpServletRequest request, HttpServletResponse response ) - throws IOException, ServletException { - try { - //this will set up the portal - super.doGet(request,response); - VitroRequest vreq = new VitroRequest(request); - - if ( checkForNoPortal(request, response) ) - return; - - String viewParam = request.getParameter("view"); - String toJsp = Controllers.BASIC_JSP; - if(viewParam != null && viewParam.equals("atom")) toJsp = "/templates/tabs/tabAtom.jsp"; - if(viewParam != null && viewParam.equals("exhibit")) toJsp = "/templates/tabs/tabExhibit.jsp"; - // here we figure out what level tab this is requesting, - // what tab, and how that tab is laid out. - // armed with this info we then foist the handling of the - // request to some other code - - //get tab and subtabs. - Tab leadingTab = populateLeadingTab(request); - request.setAttribute("leadingTab",leadingTab); - - /* - if (leadingTab.getTabId()==portal.getRootTabId()) { - request.setAttribute("homePageRequested", "true"); - request.setAttribute("title", portal.getAppName()); - RequestDispatcher rd = request.getRequestDispatcher("/home"); - rd.forward(request, response); - return; - } - else { */ - request.setAttribute("title",leadingTab.getTitle()); - /* } */ - - String body = leadingTab.getBody(); - if( body != null && body.startsWith("JSPBody:") ) - request.setAttribute("bodyJsp", body.substring(body.indexOf(":")+1)); - else - request.setAttribute("bodyJsp", Controllers.TAB_PRIMARY_JSP); - - /* *** send it to a jsp to get rendered ***** */ - RequestDispatcher rd = request.getRequestDispatcher(toJsp); - rd.forward(request, response); - - } catch (Throwable e) { - request.setAttribute("javax.servlet.jsp.jspException",e); - RequestDispatcher rd = request.getRequestDispatcher("/error.jsp"); - rd.forward(request, response); - } - } - - /** - * bump users who come to research.cals.cornell.edu to research home page on CALS site - * @param request - * @param response - * @throws IOException - */ - public boolean checkForNoPortal(HttpServletRequest request, - HttpServletResponse response ) - throws ServletException, IOException{ - String requestURL=request.getRequestURL().toString(); - String queryString=request.getQueryString(); - - boolean bad = false; - -// HttpSession session = request.getSession(false); -// Object obj; -// if( session != null && (obj=session.getAttribute("currentPortalId"))!=null){ -// if(obj instanceof Integer){ -// Integer n = (Integer)obj; -// if( ( 2 <= n.intValue() <= 5 ) || n.intValue() == 60) -// return false; -// else -// bad = true; -// } -// } - String str = ""; - if( (str = (String)request.getAttribute("home")) != null){ - if("2".equals( str) || "3".equals( str) || "4".equals( str) || - "5".equals( str) || "60".equals(str) ){ - return false; - } - } - - if (requestURL.equalsIgnoreCase("http://research.cals.cornell.edu/") - && ( queryString==null || queryString.equals(""))) - bad = true; - if( requestURL.equalsIgnoreCase("http://research.cals.cornell.edu/index.jsp") - && ( queryString==null || queryString.equals(""))) - bad = true; - - if(bad){ - // sending a redirect HTTP header to avoid problems with browsers set to ignore meta-refresh - response.sendRedirect("http://research.cals.cornell.edu/?home=60"); - /* - ServletOutputStream out = response.getOutputStream(); - out.print( - ""+ - ""+ - "CALS Research"+ - ""+ - ""+ - ""+ - ""); - */ - return true; - } - return false; - } - - /** - * Return a tab bean the way that Index.jsp and beans.TabBean use to. - * This will get a tab and its subtabs. - * This pulls all the info it needs about what tabs and what portals - * from the HttpServletRequest. - * - * There is some leftover stuff related to filteringAlphabetically, maybe this - * should be stuck in request as an attribute? - * @param request - * @return - * @throws javax.servlet.jsp.JspException - */ - public Tab populateLeadingTab(HttpServletRequest request) throws JspException { - Tab tab = null; - VitroRequest vreq = new VitroRequest(request); - - ApplicationBean appBean= vreq.getAppBean(); - int leadingTabId = TabWebUtil.getTabIdFromRequest(vreq); - - // bdc34: not reading authorization out of user id presently - // where do we get that from? - int auth_level=0; - - // Now populate the tab data structure for this page, this will get subtabs - if (leadingTabId>0 && appBean != null) - tab = vreq.getWebappDaoFactory().getTabDao().getTab(leadingTabId,auth_level,appBean); - - if( tab == null ) { - tab = new Tab(); - tab.setTitle("Warning: tab not found ("+leadingTabId+")"); - //throw new JspException("TabWebUtil.populateLeadingTab() -" + - // " unable to find tab id: " + leadingTabId); - } - - return tab; - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabEntitiesController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabEntitiesController.java deleted file mode 100644 index 29320f477..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabEntitiesController.java +++ /dev/null @@ -1,555 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - - -package edu.cornell.mannlib.vitro.webapp.controller; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Random; - -import javax.servlet.RequestDispatcher; -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.apache.lucene.document.Document; -import org.apache.lucene.index.Term; -import org.apache.lucene.search.BooleanClause; -import org.apache.lucene.search.BooleanQuery; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.PrefixQuery; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.RangeQuery; -import org.apache.lucene.search.ScoreDoc; -import org.apache.lucene.search.Sort; -import org.apache.lucene.search.TermQuery; -import org.apache.lucene.search.TopDocs; -import org.joda.time.DateTime; - -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; -import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; -import edu.cornell.mannlib.vitro.webapp.dao.TabDao; -import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc; -import edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneIndexFactory; -import edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneIndexer; -import edu.cornell.mannlib.vitro.webapp.web.TabWebUtil; - -/** - * Produces the entity lists for tabs. - * - * @author bdc34 - * - */ -public class TabEntitiesController extends VitroHttpServlet { - private static final long serialVersionUID = -5340982482787800013L; - - private static final Log log = LogFactory.getLog(TabEntitiesController.class.getName()); - public static int TAB_DEPTH_CUTOFF = 3; - public static int MAX_PAGES = 40; //must be even - public static int DEFAULT_NUMBER_INDIVIDUALS_ON_TAB = 8; - private static int MAX_RESULTS=40000; - private static int NON_PAGED_LIMIT=1000; - private static Random random = new Random(); - - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doGet(request, response); - } - - /*********************************************** - Display a set of entities for a tab, these entities - may be manually linked, auto-linked, a mix of these two, - or a gallery. - - request.attributes - a Tab object for the tabId must be in the attributes. - It should have the key - - request.parameters - "tabId" id of the tab to do entities for - - "tabDepth" String that is the depth of the tab in the display for - which we are doing entities. - leadingTab = 1, child of leadingTab = 2, etc. - - "alpha" if set to a letter entities will be filtered - to have only that initial. - - bdc34 2006-01-12 created - bdc34 2010-09-17 modified to use lucene for some tasks. - */ -public void doGet( HttpServletRequest req, HttpServletResponse response ) - throws IOException, ServletException { - super.doGet(req,response); - - try{ - VitroRequest request = new VitroRequest(req); - TabDao tabDao = request.getWebappDaoFactory().getTabDao(); - - int depth = getTabDepth(request); - if( depth >= TAB_DEPTH_CUTOFF){ - String tabId = request.getParameter("tabId"); - log.debug("\ttab "+tabId+" is at, "+ depth+" below "+ TAB_DEPTH_CUTOFF); - return; - } - - String tabId = request.getParameter("tabId"); - if( tabId == null ){ - String e="TabEntitiesController expects that request parameter 'tabId' be set"; - throw new ServletException(e); - } - - Tab tab = TabWebUtil.findStashedTab(tabId,request); - if( tab == null ){ - String e="TabEntitiesController expects that tab"+tabId+" will be in the request attribute. " - +"It should have been placed there by a call to TabWebUtil.stashTabsInRequest in tabPrimary.jsp"; - throw new ServletException(e); - } - req.setAttribute("tabId", tab.getTabId()); - request.setAttribute("controllerParam","primary=" + tab.getTabId()); - - String alpha = request.getParameter("alpha"); - boolean doAlphaFilter = false; - if(( alpha != null && alpha.length() == 1) ){ - doAlphaFilter = true; - request.setAttribute("alpha", alpha.toUpperCase()); - } - - boolean doPagedFilter = request.getParameter("page") != null; - boolean showPaged = true; - if( tab.getGalleryRows() != 1 ){ - /* bjl23 20061006: The tab.getGalleryRows()>1 is a hack to use this field as a switch to turn on - * alpha filter display in non-gallery tabs. We need to add a db field for this. */ - request.setAttribute("showAlpha","1"); - showPaged = true; - } - - List manuallyLinkedUris = Collections.emptyList(); - List autoLinkedUris = Collections.emptyList(); - if( tab.isAutoLinked() || tab.isMixedLinked()) - autoLinkedUris = request.getWebappDaoFactory().getTabDao().getTabAutoLinkedVClassURIs(tab.getTabId()); - if( tab.isManualLinked() || tab.isMixedLinked()) - manuallyLinkedUris = request.getWebappDaoFactory().getTabDao().getTabManuallyLinkedEntityURIs(tab.getTabId()); - - //If a tab is not linked to any types or individuals, don't show alpha or page filter links - boolean tabNotLinked = tabNotLinked( tab, autoLinkedUris, manuallyLinkedUris); - if( tabNotLinked ){ - request.setAttribute("showAlpha", "0"); - showPaged = false; - } - - int page = getPage(request); - int entsPerTab = getSizeForNonGalleryTab(tab, showPaged); - - int size = 0; - if( ! tabNotLinked ){ - try{ - //a lot of the work happens in this next line - size = addLinkedIndividualsForTab (tab,request, autoLinkedUris, manuallyLinkedUris, - alpha, page, entsPerTab, depth, doAlphaFilter, doPagedFilter); - }catch(Exception e){ - log.warn(e,e); - } - } - - //only show page list when the tab is depth 1. - if( showPaged && depth == 1 && size > 0 && size > entsPerTab ){ - request.setAttribute("showPages",Boolean.TRUE); - //make a data structure to hold information about paged tabs - request.setAttribute("pages", makePagesList(size, entsPerTab, page )); - }else{ - request.setAttribute("showPages",Boolean.FALSE); - } - - if( tab.isAutoLinked() || tab.isGallery() ){ - if( doAlphaFilter ){ - doAlphaFiltered(alpha, tab, request, response, tabDao, size); - }else{ - doAutoLinked( tab, request, response, tabDao, size); - } - - }else if( tab.isMixedLinked() || tab.isManualLinked() ){ - doAutoLinked(tab,request,response,tabDao,size); - }else{ - log.debug("TabEntitiesController: doing none for tabtypeid: " - + tab.getTabtypeId() +" and link mode: " + tab.getEntityLinkMethod()); - } - - - } catch (Throwable e) { - req.setAttribute("javax.servlet.jsp.jspException",e); - RequestDispatcher rd = req.getRequestDispatcher("/error.jsp"); - rd.include(req, response); - } - } - - /** - * This build a lucene query for the tab, runs the query, gets individuals for that query, - * and adds the individuals to the tab. - * - * @param tab - this parameter is mutated by this method - * @param request - * @param autoLinkedUris - * @param manuallyLinkedUris - * @param alpha - letter for alpha filtering - * @param page - page for page filtering - * @param entsPerTab - * @param depth - * @param doAlphaFilter - * @param doPagedFilter - * @return total number of ents associated with tab regardless of filtering - */ - private int addLinkedIndividualsForTab(Tab tab, VitroRequest request, - List autoLinkedUris, List manuallyLinkedUris, - String alpha, int page, int entsPerTab, int depth, - boolean doAlphaFilter , boolean doPagedFilter) { - - //try to get the URIs of the required individuals from the lucene index - IndexSearcher index = LuceneIndexFactory.getIndexSearcher(getServletContext()); - - BooleanQuery query = null; - if( tab.isAutoLinked() ){ - query = getQuery(tab, autoLinkedUris, null, alpha); - }else if (tab.isManualLinked() ){ - query = getQuery(tab, null, manuallyLinkedUris, alpha); - }else if ( tab.isMixedLinked() ){ - query = getQuery(tab, autoLinkedUris, manuallyLinkedUris, alpha); - }else{ - log.error("Tab " + tab.getTabId() + " is neither manually, auto nor mixed. "); - } - - if( tab.getDayLimit() != 0 ){ - query = addDayLimit( query, tab ); - } - boolean onlyWithThumbImg = false; - if( depth > 1 && tab.getImageWidth() > 0 ){ - onlyWithThumbImg = true; - } - - IndividualDao indDao = request.getWebappDaoFactory().getIndividualDao(); - int size = 0; - - try { - String sortField = tab.getEntitySortField(); - Sort sort = null; - if( sortField != null && !doAlphaFilter && !doPagedFilter ){ - if( sortField.equalsIgnoreCase("timekey") || tab.getDayLimit() > 0){ - sort = new Sort(Entity2LuceneDoc.term.TIMEKEY); - }else if( sortField.equalsIgnoreCase("sunrise") || tab.getDayLimit() < 0 ){ - sort = new Sort(Entity2LuceneDoc.term.SUNRISE, true); - }else if( sortField.equalsIgnoreCase("sunset") ){ - sort = new Sort(Entity2LuceneDoc.term.SUNSET); - }else{ - sort = new Sort(Entity2LuceneDoc.term.NAMELOWERCASE); - } - } else { - sort = new Sort(Entity2LuceneDoc.term.NAMELOWERCASE); - } - - if( depth > 1 && "rand()".equalsIgnoreCase(sortField) ){ - sort = null; - } - - TopDocs docs; - if( sort != null ) - docs = index.search(query, null, MAX_RESULTS, sort); - else - docs = index.search(query, null, MAX_RESULTS); - - if( docs == null ){ - log.error("Search of lucene index returned null"); - return 0; - } - - size = docs.totalHits; - // don't get all the results, only get results for the requestedSize - List results = new ArrayList(entsPerTab); - int entsAddedToTab = 0; - int ii = (page-1)*entsPerTab; - boolean doingRandom = false; - if( !doAlphaFilter && !doPagedFilter && depth > 1 && size > 1 && "rand()".equalsIgnoreCase(tab.getEntitySortField())){ - doingRandom = true; - ii = random.nextInt( size ); - } - boolean looped = false; - while( entsAddedToTab < entsPerTab && ii < docs.scoreDocs.length ){ - ScoreDoc hit = docs.scoreDocs[ii]; - if (hit != null) { - Document doc = index.doc(hit.doc); - if (doc != null) { - if( onlyWithThumbImg && "0".equals(doc.getField(Entity2LuceneDoc.term.THUMBNAIL).stringValue()) ){ - //do Nothing - }else{ - String uri = doc.getField(Entity2LuceneDoc.term.URI).stringValue(); - Individual ind = indDao.getIndividualByURI( uri ); - results.add( ind ); - entsAddedToTab++; - } - } else { - log.warn("no document found for lucene doc id " + hit.doc); - } - } else { - log.debug("hit was null"); - } - if( doingRandom && ii >= docs.scoreDocs.length && ! looped){ - ii=0; - looped = true; - }else{ - ii++; - } - } - - //mutate state of tab - tab.setRelatedEntityList(results); - }catch(IOException ex){ - log.warn(ex,ex); - return size; - } - return size; - } - - private boolean tabNotLinked(Tab tab, List autoLinkedUris, - List manuallyLinkedUris) { - if( tab.isManualLinked() ) - return manuallyLinkedUris.isEmpty(); - else if( tab.isAutoLinked() ) - return autoLinkedUris.isEmpty(); - else - return autoLinkedUris.isEmpty() && manuallyLinkedUris.isEmpty(); - } - - private BooleanQuery addDayLimit(BooleanQuery query, Tab tab) { - DateTime now = new DateTime(); - if( tab.getDayLimit() > 0 ){ - String start = now.toString(LuceneIndexer.DATE_FORMAT); - String future = now.plusDays( tab.getDayLimit() ).toString(LuceneIndexer.DATE_FORMAT); - query.add( new RangeQuery(new Term(Entity2LuceneDoc.term.TIMEKEY,start),new Term(Entity2LuceneDoc.term.TIMEKEY,future), true) , BooleanClause.Occur.MUST); - }else{ - String end = now.toString(LuceneIndexer.DATE_FORMAT); - String past = now.minusDays( tab.getDayLimit() ).toString(LuceneIndexer.DATE_FORMAT); - query.add( new RangeQuery(new Term(Entity2LuceneDoc.term.SUNRISE,past),new Term(Entity2LuceneDoc.term.SUNRISE,end), true) , BooleanClause.Occur.MUST); - } - return query; - } - - private void doAlphaFiltered(String alpha, Tab tab, - VitroRequest request, HttpServletResponse response, TabDao tabDao, int size) - throws ServletException, IOException { - log.debug("in doAlphaFitlered"); - - request.setAttribute("entities", tab.getRelatedEntities()); - request.setAttribute("alpha", alpha); - request.setAttribute("count", Integer.toString(size) ); - request.setAttribute("tabParam",tab.getTabDepthName()+"="+tab.getTabId()); - request.setAttribute("letters",Controllers.getLetters()); - //request.setAttribute("letters",tab.grabEntityFactory().getLettersOfEnts()); - request.setAttribute("servlet",Controllers.TAB); - String jsp = Controllers.ENTITY_LIST_FOR_TABS_JSP; - RequestDispatcher rd = - request.getRequestDispatcher(jsp); - rd.include(request, response); - } - - private void doAutoLinked(Tab tab, VitroRequest request, HttpServletResponse response, TabDao tabDao, int size) - throws ServletException, IOException { - log.debug("in doAutoLinked"); - - request.setAttribute("entities", tab.getRelatedEntities()); - request.setAttribute("count", Integer.toString(size)); - request.setAttribute("tabParam",tab.getTabDepthName()+"="+tab.getTabId()); - request.setAttribute("letters",Controllers.getLetters()); - request.setAttribute("servlet",Controllers.TAB); - String jsp = Controllers.ENTITY_LIST_FOR_TABS_JSP; - RequestDispatcher rd = - request.getRequestDispatcher(jsp); - rd.include(request, response); - } - - private int getPage(VitroRequest request) { - String p = request.getParameter("page") ; - if( p == null ) - return 1; - try{ - return Integer.parseInt(p); - }catch(Exception e){ - return 1; - } - } - - /** - * Mixed and auto linked tabs get their individuals via - * a query to the lucene index. This is to allow sorting and alpha - * filtering of the combined list. Manually linked tabs do not - * get their individuals using lucene, see doManual(). - * - */ - private BooleanQuery getQuery(Tab tab, List vclassUris, List manualUris, String alpha){ - BooleanQuery query = new BooleanQuery(); - try{ - - //make the type query if needed - BooleanQuery typeQuery = null; - if( tab.isAutoLinked() || tab.isMixedLinked() ){ - typeQuery = new BooleanQuery(); - BooleanQuery queryForTypes = new BooleanQuery(); - //setup up type queries in their own sub query - for( String vclassUri : vclassUris ){ - if( vclassUri != null && !"".equals(vclassUri)){ - queryForTypes.add( - new TermQuery( new Term(Entity2LuceneDoc.term.RDFTYPE, vclassUri)), - BooleanClause.Occur.SHOULD ); - } - } - typeQuery.add(queryForTypes, BooleanClause.Occur.MUST); - - } - - //make query for manually linked individuals - BooleanQuery manualQuery = null; - boolean foundManual = false; - if( tab.isManualLinked() || tab.isMixedLinked()){ - manualQuery = new BooleanQuery(); - BooleanQuery queryForManual = new BooleanQuery(); - for( String indURI : manualUris){ - if( indURI != null ){ - queryForManual.add( - new TermQuery( new Term(Entity2LuceneDoc.term.URI, indURI)), - BooleanClause.Occur.SHOULD ); - foundManual = true; - } - - } - if( foundManual ) - manualQuery.add( queryForManual, BooleanClause.Occur.MUST); - } - - - - if( tab.isAutoLinked() || !foundManual ){ - query = typeQuery; - }else if ( tab.isManualLinked() ){ - query = manualQuery; - }else{ - BooleanQuery orQuery = new BooleanQuery(); - orQuery.add( typeQuery, BooleanClause.Occur.SHOULD); - orQuery.add( manualQuery, BooleanClause.Occur.SHOULD); - query.add( orQuery, BooleanClause.Occur.MUST); - } - - //Add alpha filter if it is needed - Query alphaQuery = null; - if( alpha != null && !"".equals(alpha) && alpha.length() == 1){ - alphaQuery = - new PrefixQuery(new Term(Entity2LuceneDoc.term.NAMELOWERCASE, alpha.toLowerCase())); - query.add(alphaQuery,BooleanClause.Occur.MUST); - } - - - log.debug("Query for tab " + tab.getTabId() + ": " + query); - return query; - }catch (Exception ex){ - log.error(ex,ex); - return new BooleanQuery(); - } - } - - private int getSizeForGalleryTab(Tab tab){ - int rows = tab.getGalleryRows() != 0 ? tab.getGalleryRows() : 8; - int col = tab.getGalleryCols() != 0 ? tab.getGalleryCols() : 8; - return rows * col; - } - - private int getSizeForNonGalleryTab(Tab tab, boolean showPaged ){ - if( showPaged ) - if( tab.getGalleryCols() == 0 || tab.getGalleryRows() == 0 ) - return 8; - else - return getSizeForGalleryTab(tab); - else - return NON_PAGED_LIMIT; - } - - private int getTabDepth(VitroRequest request){ - String obj = null; - try { - obj = request.getParameter("tabDepth"); - if( obj == null ){ - String e="TabEntitesController expects that request parameter 'tabDepth' be set" - +", use 1 as the leading tab's depth."; - throw new ServletException(e); - } - return Integer.parseInt((String)obj); - }catch(Exception ex){ - return 1; - } - } - - public static List makePagesList( int count, int pageSize, int selectedPage){ - - List records = new ArrayList( MAX_PAGES + 1 ); - int requiredPages = count/pageSize ; - int remainder = count % pageSize ; - if( remainder > 0 ) - requiredPages++; - - if( selectedPage < MAX_PAGES && requiredPages > MAX_PAGES ){ - //the selected pages is within the first maxPages, just show the normal pages up to maxPages. - for(int page = 1; page < requiredPages && page <= MAX_PAGES ; page++ ){ - records.add( new PageRecord( "page=" + page, Integer.toString(page), Integer.toString(page), selectedPage == page ) ); - } - records.add( new PageRecord( "page="+ (MAX_PAGES+1), Integer.toString(MAX_PAGES+1), "more...", false)); - }else if( requiredPages > MAX_PAGES && selectedPage+1 > MAX_PAGES && selectedPage < requiredPages - MAX_PAGES){ - //the selected pages is in the middle of the list of page - int startPage = selectedPage - MAX_PAGES / 2; - int endPage = selectedPage + MAX_PAGES / 2; - for(int page = startPage; page <= endPage ; page++ ){ - records.add( new PageRecord( "page=" + page, Integer.toString(page), Integer.toString(page), selectedPage == page ) ); - } - records.add( new PageRecord( "page="+ endPage+1, Integer.toString(endPage+1), "more...", false)); - }else if ( requiredPages > MAX_PAGES && selectedPage > requiredPages - MAX_PAGES ){ - //the selected page is in the end of the list - int startPage = requiredPages - MAX_PAGES; - double max = Math.ceil(count/pageSize); - for(int page = startPage; page <= max; page++ ){ - records.add( new PageRecord( "page=" + page, Integer.toString(page), Integer.toString(page), selectedPage == page ) ); - } - }else{ - //there are fewer than maxPages pages. - for(int i = 1; i <= requiredPages; i++ ){ - records.add( new PageRecord( "page=" + i, Integer.toString(i), Integer.toString(i), selectedPage == i ) ); - } - } - return records; - } - - public static class PageRecord { - public PageRecord(String param, String index, String text, boolean selected) { - this.param = param; - this.index = index; - this.text = text; - this.selected = selected; - } - public String param; - public String index; - public String text; - public boolean selected=false; - - public String getParam() { - return param; - } - public String getIndex() { - return index; - } - public String getText() { - return text; - } - public boolean getSelected(){ - return selected; - } - } -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/TabEditController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/TabEditController.java deleted file mode 100644 index 5bba8827c..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/TabEditController.java +++ /dev/null @@ -1,217 +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.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.collections.map.ListOrderedMap; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import edu.cornell.mannlib.vedit.beans.Checkbox; -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.util.FormUtils; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.ManageTabs; -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; -import edu.cornell.mannlib.vitro.webapp.beans.TabIndividualRelation; -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.IndividualDao; -import edu.cornell.mannlib.vitro.webapp.dao.TabDao; -import edu.cornell.mannlib.vitro.webapp.dao.TabIndividualRelationDao; -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 TabEditController extends BaseEditController { - - private static final Log log = LogFactory.getLog(TabEditController.class.getName()); - private static final int NUM_COLS = 11; - - @Override - public void doPost (HttpServletRequest request, HttpServletResponse response) { - if (!isAuthorizedToDisplayPage(request, response, new Actions(new ManageTabs()))) { - return; - } - - VitroRequest vreq = new VitroRequest(request); - - // we need to extract the keyword id from a Fetch parameter - String tabIdStr = request.getParameter("id"); - int tabId = -1; - try { - tabId = Integer.decode(tabIdStr); - } catch (NumberFormatException e) { - try { - throw new ServletException(this.getClass().getName()+" expects tab id in 'id' request parameter"); - } catch (ServletException f) { - f.printStackTrace(); - } - } - - TabDao tDao = vreq.getFullWebappDaoFactory().getTabDao(); - VClassDao vcDao = vreq.getFullWebappDaoFactory().getVClassDao(); - VClassGroupDao vcgDao = vreq.getFullWebappDaoFactory().getVClassGroupDao(); - IndividualDao eDao = vreq.getFullWebappDaoFactory().getIndividualDao(); - Tab t = vreq.getFullWebappDaoFactory().getTabDao().getTab(tabId); - - request.setAttribute("tabId",tabId); - - ArrayList results = new ArrayList(); - results.add("title"); - results.add("tab id"); - results.add("description"); - results.add("tab type"); - results.add("entity link method"); - results.add("display rank"); - results.add("day limit"); - results.add("sort field"); - results.add("sort direction"); - results.add("flag2mode"); - results.add("flag2set"); - - results.add(t.getTitle()!=null ? t.getTitle() : "no title specified"); - results.add(String.valueOf(t.getTabId())); - results.add(t.getDescription()!=null ? t.getDescription() : "no description specified"); - /* from TabRetryController.java - static final int[] tabtypeIds = {0,18,20,22,24,26,28}; - static final String[] tabtypeNames = {"unspecified", "subcollection category", - "subcollection", "collection", "secondary tab", - "primary tab content", "primary tab"}; - */ - HashMap tabTypes = new HashMap(); - tabTypes.put(18,"subcollection category"); - tabTypes.put(20,"subcollection"); - tabTypes.put(22,"collection"); - tabTypes.put(24,"secondary tab"); - tabTypes.put(26,"primary tab content"); - tabTypes.put(28,"primary tab"); - - String tabtype = tabTypes.get(t.getTabtypeId()); - results.add(tabtype!=null ? tabtype : "unspecified"); - results.add(t.getEntityLinkMethod()!=null ? t.getEntityLinkMethod() : "unspecified"); - results.add(String.valueOf(t.getDisplayRank())); - results.add(String.valueOf(t.getDayLimit())); - results.add(t.getEntitySortField()!=null ? t.getEntitySortField() : "unspecified"); - results.add(t.getEntitySortDirection()!=null ? t.getEntitySortDirection() : "unspecified"); - results.add(t.getFlag2Mode()!=null ? t.getFlag2Mode() : "unspecified"); - results.add(t.getFlag2Set()!=null ? t.getFlag2Set() : "unspecified"); - - request.setAttribute("results", results); - request.setAttribute("columncount", new Integer(NUM_COLS)); - request.setAttribute("suppressquery", "true"); - - // make form stuff - - EditProcessObject epo = super.createEpo(request); - FormObject foo = new FormObject(); - - // parent tabs - EditProcessObject tabHierarchyEpo = super.createEpo(request); - tabHierarchyEpo.setReferer(request.getRequestURI()+"?"+request.getQueryString()); - request.setAttribute("tabHierarchyEpoKey", tabHierarchyEpo.getKey()); - List parentList = new LinkedList(); - Iterator parentIt = tDao.getParentTabs(t).iterator(); - while (parentIt.hasNext()) { - Tab parent = parentIt.next(); - Checkbox cb = new Checkbox(); - //cb.setBody(parent.getTitle()); - cb.setBody(""+parent.getTitle()+""); - cb.setValue(Integer.toString(parent.getTabId())); - cb.setChecked(false); - parentList.add(cb); - } - foo.getCheckboxLists().put("parentTabs",parentList); - - // child tabs - List childList = new LinkedList(); - Iterator childIt = tDao.getChildTabs(t).iterator(); - while (childIt.hasNext()) { - Tab child = childIt.next(); - Checkbox cb = new Checkbox(); - cb.setValue(Integer.toString(child.getTabId())); - //cb.setBody(child.getTitle()); - cb.setBody(""+child.getTitle()+""); - cb.setChecked(false); - childList.add(cb); - } - foo.getCheckboxLists().put("childTabs",childList); - - HashMap OptionMap = new HashMap(); - List classGroups = vcgDao.getPublicGroupsWithVClasses(true,false,false); // order by displayRank, include uninstantiated classes, don't get the counts of individuals - ListOrderedMap optGroupMap = new ListOrderedMap(); - for (VClassGroup group : classGroups) { - List classes = group.getVitroClassList(); - optGroupMap.put(group.getPublicName(),FormUtils.makeOptionListFromBeans(classes,"URI","Name",null,null,false)); - } - OptionMap.put("VClassURI", optGroupMap); - foo.setOptionLists(OptionMap); - epo.setFormObject(foo); - - List types = new LinkedList(); - List typeURIs = tDao.getTabAutoLinkedVClassURIs(tabId); - Iterator typeURIt = typeURIs.iterator(); - while (typeURIt.hasNext()) { - String typeURI = typeURIt.next(); - VClass type = vcDao.getVClassByURI(typeURI); - if (type != null) { - types.add(type); - } - } - request.setAttribute("affilTypes",types); - - TabIndividualRelationDao tirDao = vreq.getFullWebappDaoFactory().getTabs2EntsDao(); - List tirs = tirDao.getTabIndividualRelationsByTabURI(((WebappDaoFactory)request.getSession().getServletContext().getAttribute("webappDaoFactory")).getDefaultNamespace()+"tab"+tabId); - List checkboxList = new ArrayList(); - Iterator tirsIt = tirs.iterator(); - while (tirsIt.hasNext()) { - TabIndividualRelation tir = tirsIt.next(); - Individual ind = eDao.getIndividualByURI(tir.getEntURI()); - if (ind != null) { - Checkbox cb = new Checkbox(); - cb.setBody(ind.getName()); - cb.setValue(tir.getURI()); - cb.setChecked(false); - checkboxList.add(cb); - } - } - foo.getCheckboxLists().put("affilEnts",checkboxList); - - RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); - request.setAttribute("epo",epo); - request.setAttribute("epoKey",epo.getKey()); - request.setAttribute("tab", t); - request.setAttribute("bodyJsp","/templates/edit/specific/tabs_edit.jsp"); - request.setAttribute("title","Tab Control Panel"); - request.setAttribute("css", ""); - - try { - rd.forward(request, response); - } catch (Exception e) { - log.error("TabEditController could not forward to view."); - log.error(e.getMessage()); - log.error(e.getStackTrace()); - } - - } - - public void doGet (HttpServletRequest request, HttpServletResponse response) { - doPost(request,response); - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/TabHierarchyOperationController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/TabHierarchyOperationController.java deleted file mode 100644 index b816f2a83..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/TabHierarchyOperationController.java +++ /dev/null @@ -1,105 +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.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import edu.cornell.mannlib.vedit.beans.EditProcessObject; -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.ManageTabs; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; -import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; -import edu.cornell.mannlib.vitro.webapp.dao.TabDao; - -public class TabHierarchyOperationController extends BaseEditController { - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) { - doPost(request, response); - } - - @Override - public void doPost(HttpServletRequest req, HttpServletResponse response) { - if (!isAuthorizedToDisplayPage(req, response, new Actions(new ManageTabs()))) { - return; - } - - VitroRequest request = new VitroRequest(req); - String defaultLandingPage = getDefaultLandingPage(request); - TabDao tDao = request.getFullWebappDaoFactory().getTabDao(); - - if (request.getParameter("_cancel") == null) { - - String action = request.getParameter("primaryAction"); - if (action == null) { - if (request.getParameter("_insert") != null) { - action = "_insert"; - } - } - - String[] childIdStr = request.getParameterValues("ChildId"); - String[] parentIdStr = request.getParameterValues("ParentId"); - - if (action.equals("_remove") && childIdStr != null && parentIdStr != null) { - if (childIdStr.length>1 || (childIdStr.length==1 && parentIdStr.length==1)) { - try { - int parentId = Integer.decode(parentIdStr[0]); - Tab parent = tDao.getTab(parentId); - for (int childIndex=0; childIndex 0)) { - for (int i=0; i 0) { - try { - tabForEditing = tDao.getTab(id); - action = "update"; - } catch (NullPointerException e) { - log.error("Need to implement 'record not found' error message."); - } - } - } else { - tabForEditing = new Tab(); - } - epo.setOriginalBean(tabForEditing); - } else { - tabForEditing = (Tab) epo.getNewBean(); - action = "update"; - log.error("using newBean"); - } - - //make a postinsert pageforwarder that will send us to a new class's fetch screen - epo.setPostInsertPageForwarder(new TabInsertPageForwarder()); - //make a postdelete pageforwarder that will send us to the list of properties - epo.setPostDeletePageForwarder(new UrlForwarder("listTabs")); - - //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(tDao.getClass().getDeclaredMethod("getTab",args)); - } catch (NoSuchMethodException e) { - log.error("TabRetryController could not find the getPortalById method in the facade"); - } - - - FormObject foo = new FormObject(); - foo.setErrorMap(epo.getErrMsgMap()); - - HashMap optionMap = new HashMap(); - // TODO: userId - List tabtypeList = new LinkedList(); - for (int i=0; i tabList = tDao.getAllManuallyLinkableTabs(1); - Collections.sort(tabList); - optionMap.put("TabId", FormUtils.makeOptionListFromBeans(tabList, "TabId", "Title", Integer.toString(objectForEditing.getTabId()), null)); - if (objectForEditing.getEntURI() != null) { - Individual ent = eDao.getIndividualByURI(objectForEditing.getEntURI()); - List l = new LinkedList(); - l.add(new Option(ent.getURI(),ent.getName(),true)); - optionMap.put("EntId", l); - } else try { - String vclassUri = request.getParameter("VClassUri"); - VClass scratch = new VClass(); - scratch.setURI(vclassUri); - List individualsInClass = eDao.getIndividualsByVClass(scratch); - Collections.sort(individualsInClass); - optionMap.put("EntId", FormUtils.makeOptionListFromBeans(individualsInClass, "URI", "Name", objectForEditing.getEntURI(), null, false)); - } catch (Exception e){ - try { - String entityUri = request.getParameter("entityUri"); - Individual entity = eDao.getIndividualByURI(entityUri); - List l = new LinkedList(); - l.add(new Option(entity.getURI(),entity.getName(),true)); - optionMap.put("EntId", l); - } catch (Exception f) { - List l = new LinkedList(); - l.add(new Option("-1","Error: VClass must be specified", true)); - optionMap.put("EntId", l); - } - } - FormObject foo = new FormObject(); - foo.setOptionLists(optionMap); - - epo.setFormObject(foo); - - String html = FormUtils.htmlFormFromBean(objectForEditing,action,foo); - - RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); - request.setAttribute("formHtml",html); - request.setAttribute("bodyJsp","/templates/edit/formBasic.jsp"); - request.setAttribute("formJsp","/templates/edit/specific/tabs2ents_retry.jsp"); - request.setAttribute("scripts","/templates/edit/formBasic.js"); - request.setAttribute("title","Tab-Individual Association Editing Form"); - request.setAttribute("_action",action); - request.setAttribute("unqualifiedClassName","Tabs2Ents"); - setRequestAttributes(request,epo); - - try { - rd.forward(request, response); - } catch (Exception e) { - log.error("Tabs2EntsRetryController could not forward to view."); - log.error(e.getMessage()); - log.error(e.getStackTrace()); - } - - } - - public void doGet (HttpServletRequest request, HttpServletResponse response) { - doPost(request, response); - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/Tabs2TabsRetryController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/Tabs2TabsRetryController.java deleted file mode 100644 index b4202cf57..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/Tabs2TabsRetryController.java +++ /dev/null @@ -1,106 +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.util.HashMap; -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.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.util.FormUtils; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.ManageTabs; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; -import edu.cornell.mannlib.vitro.webapp.controller.Controllers; -import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; -import edu.cornell.mannlib.vitro.webapp.dao.TabDao; - -public class Tabs2TabsRetryController extends BaseEditController { - - private static final Log log = LogFactory.getLog(Tabs2TabsRetryController.class.getName()); - - @Override - public void doPost (HttpServletRequest req, HttpServletResponse response) { - if (!isAuthorizedToDisplayPage(req, response, new Actions(new ManageTabs()))) { - return; - } - - VitroRequest request = new VitroRequest(req); - - //create an EditProcessObject for this and put it in the session - EditProcessObject epo = super.createEpo(request); - FormObject foo = new FormObject(); - epo.setFormObject(foo); - - String action = "insert"; - - TabDao tDao = request.getFullWebappDaoFactory().getTabDao(); - - Tab child = null; - Tab parent = null; - - if (request.getParameter("ChildId") != null) { - try { - int childId = Integer.decode(request.getParameter("ChildId")); - child = tDao.getTab(childId); - } catch (NumberFormatException e) {} - } - - if (request.getParameter("ParentId") != null) { - try { - int parentId = Integer.decode(request.getParameter("ParentId")); - parent = tDao.getTab(parentId); - } catch (NumberFormatException e) {} - } - - HashMap hash = new HashMap(); - foo.setOptionLists(hash); - if (parent != null ) { - hash.put("ChildId", FormUtils.makeOptionListFromBeans(tDao.getTabsForPortalByTabtypes(1,false, parent.getTabtypeId()),"TabId","Title",null,null)); - List parentList = new LinkedList(); - parentList.add(new Option(Integer.toString(parent.getTabId()),parent.getTitle(),true)); - hash.put("ParentId", parentList); - } else if (child != null){ - hash.put("ParentId", FormUtils.makeOptionListFromBeans(tDao.getTabsForPortalByTabtypes(1,true,child.getTabtypeId()),"TabId","Title",null,null)); - List childList = new LinkedList(); - childList.add(new Option(Integer.toString(child.getTabId()),child.getTitle(),true)); - hash.put("ChildId", childList); - } - - epo.setFormObject(foo); - - RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); - - request.setAttribute("epoKey",epo.getKey()); - request.setAttribute("epo",epo); - request.setAttribute("bodyJsp","/templates/edit/specific/tabs2tabs_retry.jsp"); - request.setAttribute("scripts","/templates/edit/formBasic.js"); - request.setAttribute("title","Super/Subtab Editing Form"); - request.setAttribute("_action",action); - setRequestAttributes(request,epo); - - try { - rd.forward(request, response); - } catch (Exception e) { - log.error("Tabs2TabsRetryController could not forward to view."); - log.error(e.getMessage()); - log.error(e.getStackTrace()); - } - - } - - public void doGet (HttpServletRequest request, HttpServletResponse response) { - doPost(request, response); - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/Tabs2TypesOperationController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/Tabs2TypesOperationController.java deleted file mode 100644 index ba3a3debb..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/Tabs2TypesOperationController.java +++ /dev/null @@ -1,110 +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.util.HashMap; - -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.controller.BaseEditController; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.ManagePortals; -import edu.cornell.mannlib.vitro.webapp.beans.TabVClassRelation; -import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; -import edu.cornell.mannlib.vitro.webapp.dao.TabVClassRelationDao; - -public class Tabs2TypesOperationController extends BaseEditController { - - private static final Log log = LogFactory.getLog(Tabs2TypesOperationController.class.getName()); - - public void doGet(HttpServletRequest req, HttpServletResponse response) { - if (!isAuthorizedToDisplayPage(req, response, new Actions(new ManagePortals()))) { - return; - } - - VitroRequest request = new VitroRequest(req); - String defaultLandingPage = getDefaultLandingPage(request); - - HashMap epoHash = null; - EditProcessObject epo = null; - try { - epoHash = (HashMap) request.getSession().getAttribute("epoHash"); - epo = (EditProcessObject) epoHash.get(request.getParameter("_epoKey")); - } catch (NullPointerException e) { - //session or edit process expired - try { - response.sendRedirect(defaultLandingPage); - } catch (IOException f) { - e.printStackTrace(); - } - return; - } - - if (epo == null) { - log.error("null epo"); - try { - response.sendRedirect(defaultLandingPage); - } catch (IOException e) { - e.printStackTrace(); - } - return; - } - - TabVClassRelationDao dao = request.getFullWebappDaoFactory().getTabs2TypesDao(); - - if (request.getParameter("_cancel") == null) { - try { - if (request.getParameter("operation").equals("remove")) { - String[] typeURIstrs = request.getParameterValues("TypeURI"); - if ((typeURIstrs != null) && (typeURIstrs.length > 0)) { - String tabIdStr = request.getParameter("TabId"); - if (tabIdStr != null) { - for (int i=0; i 0) { - try { - // objectForEditing = t2tDao.getTabs2TypesById(id); - action = "update"; - } catch (NullPointerException e) { - log.error("Need to implement 'record not found' error message."); - } - } - } else { - objectForEditing = new TabVClassRelation(); - String vClassIdStr = request.getParameter("vClassId"); - if (vClassIdStr != null) { - try { - objectForEditing.setVClassURI(vClassIdStr); - } catch (NumberFormatException e) { - // not really an integer. - } - } - String tabIdStr = request.getParameter("tabId"); - if (tabIdStr != null) { - try { - objectForEditing.setTabId(Integer.decode(tabIdStr)); - } catch (NumberFormatException e) { - // not really an integer. - } - } - } - - epo.setOriginalBean(objectForEditing); - - // populateBeanFromParams(objectForEditing, request); - - //set up any listeners - //List changeListenerList = new LinkedList(); - //epo.setChangeListenerList(changeListenerList); - - //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(t2tDao.getClass().getDeclaredMethod("getTabs2TypesById",args)); -// } catch (NoSuchMethodException e) { -// log.error("Tabs2TypesRetryController could not find the getTabs2TypesById method in the facade"); -// } - - HashMap optionMap = new HashMap(); - List tabList = tDao.getAllAutolinkableTabs(1); - Collections.sort(tabList); - optionMap.put("TabId", FormUtils.makeOptionListFromBeans(tabList, "TabId", "Title", request.getParameter("TabId"), null)); - List classGroups = cgDao.getPublicGroupsWithVClasses(true); // order by displayRank - Iterator classGroupIt = classGroups.iterator(); - ListOrderedMap optGroupMap = new ListOrderedMap(); - while (classGroupIt.hasNext()) { - VClassGroup group = (VClassGroup)classGroupIt.next(); - List classes = group.getVitroClassList(); - if (classes.size() > 0) - optGroupMap.put(group.getPublicName(),FormUtils.makeOptionListFromBeans(classes,"URI","Name",objectForEditing.getVClassURI(),null,false)); - } - optionMap.put("VClassId", optGroupMap); - FormObject foo = new FormObject(); - foo.setOptionLists(optionMap); - - epo.setFormObject(foo); - - String html = FormUtils.htmlFormFromBean(objectForEditing,action,foo); - - RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); - request.setAttribute("formHtml",html); - request.setAttribute("bodyJsp","/templates/edit/formBasic.jsp"); - request.setAttribute("formJsp","/templates/edit/specific/tabs2types_retry.jsp"); - request.setAttribute("scripts","/templates/edit/formBasic.js"); - request.setAttribute("title","Tab-VClass Autolink Editing Form"); - request.setAttribute("_action",action); - request.setAttribute("unqualifiedClassName","Tabs2Types"); - setRequestAttributes(request,epo); - - try { - rd.forward(request, response); - } catch (Exception e) { - log.error("Tabs2TypesRetryController could not forward to view."); - log.error(e.getMessage()); - log.error(e.getStackTrace()); - } - - } - - public void doGet (HttpServletRequest request, HttpServletResponse response) { - doPost(request, response); - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/AllTabsForPortalListingController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/AllTabsForPortalListingController.java deleted file mode 100644 index fe55f612a..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/listing/AllTabsForPortalListingController.java +++ /dev/null @@ -1,111 +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.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -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.requestedAction.Actions; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.ManageTabs; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; -import edu.cornell.mannlib.vitro.webapp.controller.Controllers; -import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; -import edu.cornell.mannlib.vitro.webapp.dao.TabDao; - -public class AllTabsForPortalListingController extends BaseEditController { - public static final Actions REQUIRED_ACTIONS = new Actions(new ManageTabs()); - - private static final int NUM_COLS = 11; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) { - if (!isAuthorizedToDisplayPage(request, response, REQUIRED_ACTIONS)) { - return; - } - - VitroRequest vrequest = new VitroRequest(request); - - HashMap types = new HashMap(); - types.put(18,"subcollection category"); - types.put(20,"subcollection"); - types.put(22,"collection"); - types.put(24,"secondary tab"); - types.put(26,"primary tab content"); - types.put(28,"primary tab"); - - TabDao dao = vrequest.getFullWebappDaoFactory().getTabDao(); - List tabs = dao.getTabsForPortal(1); - Collections.sort(tabs, new TabComparator()); - - ArrayList results = new ArrayList(); - results.add("XX"); - results.add("title"); - results.add("tab id"); - results.add("tab type"); - //results.add("description"); - results.add("display rank"); - results.add("entity links"); - results.add("day limit"); - results.add("sort field"); - results.add("sort dir"); - results.add("flag2mode"); - results.add("flag2set"); - - - if (tabs != null) { - for (Tab tab : tabs) { - results.add("XX"); - if (tab.getTitle() != null) - results.add(""+tab.getTitle()+""); - else - results.add(""); - results.add(String.valueOf(tab.getTabId())); - String tabtype = types.get(tab.getTabtypeId()); - results.add(tabtype!=null ? tabtype : "-"); - //results.add(tab.getDescription()!=null ? tab.getDescription() : "-"); - results.add(Integer.valueOf(tab.getDisplayRank()).toString()); - results.add(tab.getEntityLinkMethod()!=null ? tab.getEntityLinkMethod() : "-"); - results.add(Integer.valueOf(tab.getDayLimit()).toString()); - results.add(tab.getEntitySortField()!=null ? tab.getEntitySortField() : "-"); - results.add(tab.getEntitySortDirection()!=null ? tab.getEntitySortDirection() : "-"); - results.add(tab.getFlag2Mode()!=null ? tab.getFlag2Mode() : "-"); - results.add(tab.getFlag2Set()!=null ? tab.getFlag2Set() : "-"); - } - request.setAttribute("results",results); - } - - request.setAttribute("columncount",new Integer(NUM_COLS)); - request.setAttribute("suppressquery","true"); - request.setAttribute("title","Tabs"); - request.setAttribute("bodyJsp", Controllers.HORIZONTAL_JSP); - request.setAttribute("horizontalJspAddButtonUrl", Controllers.RETRY_URL); - request.setAttribute("horizontalJspAddButtonText", "Add new tab"); - request.setAttribute("horizontalJspAddButtonControllerParam", "Tab"); - RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); - try { - rd.forward(request,response); - } catch (Throwable t) { - t.printStackTrace(); - } - - } - - private class TabComparator implements Comparator { - @Override - public int compare (Tab tab1, Tab tab2) { - if(tab1 == null && tab2 == null) return 0; - int diff = tab1.getTabId() - tab2.getTabId(); // tab1.getDisplayRank() - tab2.getDisplayRank() - if(diff == 0) - return tab1.getTitle().compareToIgnoreCase(tab2.getTitle()); - return diff; - } - } -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java index 4c3e44260..0118c1173 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java @@ -33,11 +33,9 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Rdf import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; -import edu.cornell.mannlib.vitro.webapp.web.BreadCrumbsUtil; import edu.cornell.mannlib.vitro.webapp.web.templatemodels.Tags; import edu.cornell.mannlib.vitro.webapp.web.templatemodels.User; import edu.cornell.mannlib.vitro.webapp.web.templatemodels.menu.MainMenu; -import edu.cornell.mannlib.vitro.webapp.web.templatemodels.menu.TabMenu; import freemarker.ext.beans.BeansWrapper; import freemarker.template.Configuration; import freemarker.template.DefaultObjectWrapper; @@ -354,7 +352,6 @@ public class FreemarkerHttpServlet extends VitroHttpServlet { map.putAll(getDirectives()); map.putAll(getMethods()); - map.put("tabMenu", getTabMenu(vreq)); map.put("menu", getDisplayModelMenu(vreq)); map.put("user", new User(vreq)); @@ -363,7 +360,6 @@ public class FreemarkerHttpServlet extends VitroHttpServlet { map.put("copyright", getCopyrightInfo(appBean)); map.put("siteTagline", appBean.getShortHand()); - map.put("breadcrumbs", BreadCrumbsUtil.getBreadCrumbsDiv(vreq)); // This value is used only in stylesheets.ftl and already contains the context path. map.put("stylesheetPath", UrlBuilder.getUrl(themeDir + "/css")); @@ -393,10 +389,6 @@ public class FreemarkerHttpServlet extends VitroHttpServlet { // since we don't get here on other tabs. return (name.length() == 0 || name.equals("index.jsp")) ? "home" : name; } - - private TabMenu getTabMenu(VitroRequest vreq) { - return new TabMenu(vreq, 1); - } protected MainMenu getDisplayModelMenu(VitroRequest vreq){ String url = vreq.getRequestURI().substring(vreq.getContextPath().length()); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/HomePageController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/HomePageController.java index 5e5b551a5..8d7bfc2e6 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/HomePageController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/HomePageController.java @@ -8,7 +8,6 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; @@ -42,22 +41,9 @@ public class HomePageController extends FreemarkerHttpServlet { if(pageData != null) body.putAll(pageData); } - - // Get the home tab content for themes that display deprecated tabs - body.put("homeTabContent", getHomeTabContent(vreq)); return new TemplateResponseValues(BODY_TEMPLATE, body); } - - // Get the home tab content for themes that display deprecated tabs - private String getHomeTabContent(VitroRequest vreq) { - Tab tab = vreq.getWebappDaoFactory().getTabDao().getTab(1,0,vreq.getAppBean()); - String body = tab.getBody(); - if (body == null) { - body = ""; - } - return body; - } @Override protected String getTitle(String siteName, VitroRequest vreq) { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java index ad6e63d3e..c3c4b3874 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java @@ -31,8 +31,6 @@ import org.apache.lucene.search.TopDocs; import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; -import edu.cornell.mannlib.vitro.webapp.controller.TabEntitiesController; -import edu.cornell.mannlib.vitro.webapp.controller.TabEntitiesController.PageRecord; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; @@ -54,6 +52,7 @@ public class IndividualListController extends FreemarkerHttpServlet { public static final int ENTITY_LIST_CONTROLLER_MAX_RESULTS = 30000; public static final int INDIVIDUALS_PER_PAGE = 30; + public static final int MAX_PAGES = 40; //must be even private static final String TEMPLATE_DEFAULT = "individualList.ftl"; @@ -230,7 +229,7 @@ public class IndividualListController extends FreemarkerHttpServlet { if( size > INDIVIDUALS_PER_PAGE ){ rvMap.put("showPages", Boolean.TRUE); - List pageRecords = TabEntitiesController.makePagesList(size, INDIVIDUALS_PER_PAGE, page); + List pageRecords = makePagesList(size, INDIVIDUALS_PER_PAGE, page); rvMap.put("pages", pageRecords); }else{ rvMap.put("showPages", Boolean.FALSE); @@ -271,4 +270,68 @@ public class IndividualListController extends FreemarkerHttpServlet { } } + public static List makePagesList( int count, int pageSize, int selectedPage){ + + List records = new ArrayList( MAX_PAGES + 1 ); + int requiredPages = count/pageSize ; + int remainder = count % pageSize ; + if( remainder > 0 ) + requiredPages++; + + if( selectedPage < MAX_PAGES && requiredPages > MAX_PAGES ){ + //the selected pages is within the first maxPages, just show the normal pages up to maxPages. + for(int page = 1; page < requiredPages && page <= MAX_PAGES ; page++ ){ + records.add( new PageRecord( "page=" + page, Integer.toString(page), Integer.toString(page), selectedPage == page ) ); + } + records.add( new PageRecord( "page="+ (MAX_PAGES+1), Integer.toString(MAX_PAGES+1), "more...", false)); + }else if( requiredPages > MAX_PAGES && selectedPage+1 > MAX_PAGES && selectedPage < requiredPages - MAX_PAGES){ + //the selected pages is in the middle of the list of page + int startPage = selectedPage - MAX_PAGES / 2; + int endPage = selectedPage + MAX_PAGES / 2; + for(int page = startPage; page <= endPage ; page++ ){ + records.add( new PageRecord( "page=" + page, Integer.toString(page), Integer.toString(page), selectedPage == page ) ); + } + records.add( new PageRecord( "page="+ endPage+1, Integer.toString(endPage+1), "more...", false)); + }else if ( requiredPages > MAX_PAGES && selectedPage > requiredPages - MAX_PAGES ){ + //the selected page is in the end of the list + int startPage = requiredPages - MAX_PAGES; + double max = Math.ceil(count/pageSize); + for(int page = startPage; page <= max; page++ ){ + records.add( new PageRecord( "page=" + page, Integer.toString(page), Integer.toString(page), selectedPage == page ) ); + } + }else{ + //there are fewer than maxPages pages. + for(int i = 1; i <= requiredPages; i++ ){ + records.add( new PageRecord( "page=" + i, Integer.toString(i), Integer.toString(i), selectedPage == i ) ); + } + } + return records; + } + + public static class PageRecord { + public PageRecord(String param, String index, String text, boolean selected) { + this.param = param; + this.index = index; + this.text = text; + this.selected = selected; + } + public String param; + public String index; + public String text; + public boolean selected=false; + + public String getParam() { + return param; + } + public String getIndex() { + return index; + } + public String getText() { + return text; + } + public boolean getSelected(){ + return selected; + } + } + } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SiteAdminController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SiteAdminController.java index fae4f0aa7..51b9c8570 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SiteAdminController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SiteAdminController.java @@ -24,7 +24,6 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.SeeSiteAdm import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.UseAdvancedDataToolsPages; import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; -import edu.cornell.mannlib.vitro.webapp.controller.edit.listing.AllTabsForPortalListingController; import edu.cornell.mannlib.vitro.webapp.controller.edit.listing.UsersListingController; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; @@ -119,10 +118,6 @@ public class SiteAdminController extends FreemarkerHttpServlet { Map map = new HashMap(); Map urls = new HashMap(); - - if (PolicyHelper.isAuthorizedForActions(vreq, AllTabsForPortalListingController.REQUIRED_ACTIONS)) { - urls.put("tabs", urlBuilder.getPortalUrl("/listTabs")); - } // TODO remove this when the UserAccounts are fully implemented. -- jblake if (PolicyHelper.isAuthorizedForActions(vreq, UsersListingController.REQUIRED_ACTIONS)) { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/TabDao.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/TabDao.java deleted file mode 100644 index af315b01d..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/TabDao.java +++ /dev/null @@ -1,88 +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.ApplicationBean; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; - -import java.util.List; - -/** - * Created by IntelliJ IDEA. - * User: bdc34 - * Date: Apr 18, 2007 - * Time: 11:18:28 PM - * To change this template use File | Settings | File Templates. - */ -public interface TabDao { - - void addParentTab(Tab tab, Tab parent); - - void addParentTab(String tabURI, String parentURI); - - void removeParentTab(Tab tab, Tab parent); - - void removeParentTab(String tabURI, String parentURI); - - List getParentTabs(Tab tab); - - List getParentTabs(String tabURI); - - List getChildTabs(Tab tab); - - List getChildTabs(String tabURI); - -// void addAutolinkedVClass(Tab tab, VClass vclass); -// -// void addAutolinkedVClass(String tabURI, String vclassURI); -// -// void removeAutolinkedVClass(Tab tab, VClass vclass); -// -// void removeAutolinkedVClass(String tabURI, String vclassURI); -// -// List /* of Tab */ getAutolinkedVClasses(Tab tab); -// -// List /* of Tab */ getAutolinkedVClasses(String tabURI); - - - - Tab getTab(int tab_id, int auth_level, ApplicationBean app); - - Tab getTab(int tab_id, int auth_level, ApplicationBean app, int depth ); - - int insertTab(Tab tab); - - void updateTab(Tab tab); - - void deleteTab(Tab tab); - - Tab getTab(int tab_id); - - List getTabAutoLinkedVClassURIs(int tab_id); - - List getTabManuallyLinkedEntityURIs(int tab_id); - - Tab getTabByName(String tabName); - - List getPrimaryTabs(int portalId ); - - List getSecondaryTabs(int primaryTabId); - - List getTabsForPortal(int portalId); - - List getTabsForPortalByTabtypes(int portalId, boolean direction, int tabtypeId); - - int cloneTab(int tabId) throws Exception; - - String getNameForTabId(int tabId); - - List getTabHierarchy(int tabId, int rootTab); - - int getRootTabId(int portalId); - - List getAllAutolinkableTabs(int portalId); - - List getAllManuallyLinkableTabs(int portalId); - - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/TabEntityFactory.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/TabEntityFactory.java deleted file mode 100644 index f6c8eef17..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/TabEntityFactory.java +++ /dev/null @@ -1,42 +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.Individual; - -import java.util.List; -/** - * This class defines a minimum that we can expect a - * TabEntityFactory to have for methods. - * - * @author bdc34 - * - */ -public interface TabEntityFactory { - - /** - * Expected to return a list of entities to be displayed on the tab. - * The standard meaning of the alpha parameters is that the tab - * should only include entities that have names that start with that - * letter. - * - * @param alpha - * @return - */ - public List getRelatedEntites(String alpha); - - /** - * Gets a count of entities that would be displayed on the tab. - * @return - */ - public int getRelatedEntityCount(); - - /** - * Returns a list of letters for which there are entities. - * Each string should have a single letter. - * - * @return - */ - public List getLettersOfEnts(); - -} \ No newline at end of file diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/TabIndividualRelationDao.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/TabIndividualRelationDao.java deleted file mode 100644 index ccbd084d3..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/TabIndividualRelationDao.java +++ /dev/null @@ -1,34 +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.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; -import edu.cornell.mannlib.vitro.webapp.beans.TabIndividualRelation; - -import java.util.List; - -/** - * Created by IntelliJ IDEA. - * User: bdc34 - * Date: Apr 18, 2007 - * Time: 4:35:01 PM - * To change this template use File | Settings | File Templates. - */ -public interface TabIndividualRelationDao { - TabIndividualRelation getTabIndividualRelationByURI(String uri); - - List getTabIndividualRelationsByIndividualURI(String individualURI); - - List getTabIndividualRelationsByTabURI(String individualURI); - - int insertNewTabIndividualRelation(TabIndividualRelation t2e ); - - void updateTabIndividualRelation(TabIndividualRelation t2e); - - void deleteTabIndividualRelation(TabIndividualRelation t2e); - - void insertTabIndividualRelation(Tab tab, Individual ent); - - boolean tabIndividualRelationExists(Tab tab, Individual ent); -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/TabVClassRelationDao.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/TabVClassRelationDao.java deleted file mode 100644 index 9d8012d33..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/TabVClassRelationDao.java +++ /dev/null @@ -1,20 +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.TabVClassRelation; - -/** - * Created by IntelliJ IDEA. - * User: bdc34 - * Date: Apr 18, 2007 - * Time: 3:20:27 PM - * To change this template use File | Settings | File Templates. - */ -public interface TabVClassRelationDao { - - int insertTabVClassRelation(TabVClassRelation t2t ); - - void deleteTabVClassRelation(TabVClassRelation t2t); - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/VitroVocabulary.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/VitroVocabulary.java index abd40115d..53fc1f43b 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/VitroVocabulary.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/VitroVocabulary.java @@ -147,7 +147,6 @@ public class VitroVocabulary { // ================== Vitro Portal vocabulary =========================== public static final String PORTAL = vitroURI+"Portal"; - public static final String PORTAL_ROOTTAB = vitroURI+"rootTab"; public static final String PORTAL_THEMEDIR = vitroURI+"themeDir"; public static final String PORTAL_BANNERIMAGE = vitroURI+"bannerImage"; public static final String PORTAL_CONTACTMAIL = vitroURI+"contactMail"; @@ -168,44 +167,6 @@ public class VitroVocabulary { // reusing displayRank property above public static final String PORTAL_URLPREFIX = vitroURI + "urlPrefix"; - // ================ Vitro Tab vocabulary ================================ - - public static final String TAB = vitroURI+"Tab"; - public static final String TAB_AUTOLINKABLETAB = vitroURI+"AutoLinkableTab"; - public static final String TAB_MANUALLYLINKABLETAB = vitroURI+"ManuallyLinkableTab"; - public static final String TAB_MIXEDTAB = vitroURI+"MixedTab"; - public static final String TAB_PRIMARYTAB = vitroURI+"PrimaryTab"; - public static final String TAB_SUBCOLLECTIONCATEGORY = vitroURI+"SubcollectionCategory"; - public static final String TAB_SECONDARYTAB = vitroURI+"SecondaryTab"; - public static final String TAB_PRIMARYTABCONTENT = vitroURI+"PrimaryTabContent"; - public static final String TAB_SUBCOLLECTION = vitroURI+"Subcollection"; - public static final String TAB_SUBTABOF = vitroURI+"subTabOf"; - public static final String TAB_COLLECTION = vitroURI+"Collection"; - - public static final String TAB_INDIVIDUALRELATION= vitroURI+"TabIndividualRelation"; - public static final String TAB_INDIVIDUALRELATION_INVOLVESINDIVIDUAL= vitroURI+"involvesIndividual"; - public static final String TAB_INDIVIDUALRELATION_INVOLVESTAB = vitroURI+"involvesTab"; - - - public static final String TAB_AUTOLINKEDTOTAB = vitroURI + "autoLinkedToTab"; // annotation on class - public static final String TAB_TABTYPE = vitroURI+"tabType"; - public static final String TAB_STATUSID = vitroURI+"statusId"; - public static final String TAB_DAYLIMIT = vitroURI+"dayLimit"; - public static final String TAB_BODY = vitroURI+"tabBody"; - public static final String TAB_GALLERYROWS = vitroURI+"galleryRows"; - public static final String TAB_GALLERYCOLS = vitroURI+"galleryCols"; - public static final String TAB_MORETAG = vitroURI+"moreTag"; - public static final String TAB_IMAGEWIDTH = vitroURI+"imageWidth"; - public static final String TAB_PORTAL = vitroURI+"inPortal"; - public static final String TAB_ENTITYSORTFIELD = vitroURI+"individualSortField"; - public static final String TAB_ENTITYSORTDIRECTION = vitroURI+"individualSortDirection"; - public static final String TAB_ENTITYLINKMETHOD = vitroURI+"individualLinkMethod"; - public static final String TAB_RSSURL = vitroURI+"rssUrl"; - public static final String TAB_FLAG2SET = vitroURI+"flag2Set"; - public static final String TAB_FLAG3SET = vitroURI+"flag3Set"; - public static final String TAB_FLAG2MODE = vitroURI+"flag2Mode"; - public static final String TAB_FLAG3MODE = vitroURI+"flag3Mode"; - // =============== Vitro User vocabulary ================================= // TODO - these go away when the UserAccount stuff is fully implemented - jblake 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 3c1f5d8a7..d5127f86e 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactory.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactory.java @@ -112,10 +112,6 @@ public interface WebappDaoFactory { public ApplicationDao getApplicationDao(); - public TabDao getTabDao(); - public TabIndividualRelationDao getTabs2EntsDao(); - public TabVClassRelationDao getTabs2TypesDao(); - public KeywordIndividualRelationDao getKeys2EntsDao(); public KeywordDao getKeywordDao(); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/TabDaoFiltering.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/TabDaoFiltering.java deleted file mode 100644 index 67dee5792..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/TabDaoFiltering.java +++ /dev/null @@ -1,218 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.dao.filtering; - -import java.util.Collection; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; -import edu.cornell.mannlib.vitro.webapp.dao.ApplicationDao; -import edu.cornell.mannlib.vitro.webapp.dao.TabDao; -import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.FiltersForTabs; -import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilterUtils; -import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters; -import edu.cornell.mannlib.vitro.webapp.dao.filtering.tabFactory.TabEntityFactoryFiltering; - -public class TabDaoFiltering extends BaseFiltering implements TabDao{ - - final TabDao innerDao; - final VitroFilters filters; - private ApplicationDao applicationDao; - - public TabDaoFiltering(TabDao tabDao, ApplicationDao applicationDao, VitroFilters filters) { - this.innerDao = tabDao; - this.applicationDao = applicationDao; - this.filters = filters; - } - - public void addParentTab(Tab tab, Tab parent) { - innerDao.addParentTab(tab, parent); - } - - public void addParentTab(String tabURI, String parentURI) { - innerDao.addParentTab(tabURI, parentURI); - } - - public void removeParentTab(Tab tab, Tab parent) { - innerDao.removeParentTab(tab, parent); - } - - public void removeParentTab(String tabURI, String parentURI) { - innerDao.removeParentTab(tabURI, parentURI); - } - - public int insertTab(Tab tab) { - return innerDao.insertTab(tab); - } - - public void updateTab(Tab tab) { - innerDao.updateTab(tab); - } - - public int cloneTab(int tabId) throws Exception { - return innerDao.cloneTab(tabId); - } - - public void deleteTab(Tab tab) { - innerDao.deleteTab(tab); - } - - - public List getParentTabs(Tab tab) { - return setupFilteringTabs(innerDao.getParentTabs(tab)); - } - - public List getParentTabs(String tabURI) { - return setupFilteringTabs(innerDao.getParentTabs(tabURI)); - } - - public List getChildTabs(Tab tab) { - return setupFilteringTabs(innerDao.getChildTabs(tab)); - } - - public List getChildTabs(String tabURI) { - return setupFilteringTabs(innerDao.getChildTabs(tabURI)); - } - - public List getAllAutolinkableTabs(int portalId) { - return setupFilteringTabs(filter(innerDao.getAllAutolinkableTabs(portalId),filters.getTabFilter())); - } - - public List getAllManuallyLinkableTabs(int portalId) { - return setupFilteringTabs(filter(innerDao.getAllManuallyLinkableTabs(portalId),filters.getTabFilter())); - } - - public String getNameForTabId(int tabId) { - return innerDao.getNameForTabId(tabId); - } - - public List getPrimaryTabs(int portalId) { - return setupFilteringTabs(filter(innerDao.getPrimaryTabs(portalId),filters.getTabFilter())); - } - - public int getRootTabId(int portalId) { - return innerDao.getRootTabId(portalId); - } - - public List getSecondaryTabs(int primaryTabId) { - return filter(innerDao.getSecondaryTabs(primaryTabId),filters.getTabFilter()); - } - - public Tab getTab(int tab_id, int auth_level, ApplicationBean app) { - int NO_DEPTH_LIMIT = -1; - return this.getTab(tab_id, auth_level, app, NO_DEPTH_LIMIT); - } - - /** note that sub tabs are not filtered */ - public Tab getTab(int tab_id, int auth_level, ApplicationBean app, int depth) { - Tab t = innerDao.getTab(tab_id, auth_level, app, depth); - if( t != null && filters.getTabFilter().fn(t)) - return setupFilteringTab(t); - else - return null; - } - - public Tab getTab(int tab_id) { - Tab t = innerDao.getTab(tab_id); - if( t != null && filters.getTabFilter().fn(t)) - return setupFilteringTab(t); - else - return null; - } - - public Tab getTabByName(String tabName) { - Tab t = innerDao.getTabByName(tabName); - if( t != null && filters.getTabFilter().fn(t)) - return setupFilteringTab(t); - else - return null; - } - - /** note not currently filtered */ - public List getTabAutoLinkedVClassURIs(int tab_id) { - return innerDao.getTabAutoLinkedVClassURIs(tab_id); - } - - - /** note not currently filtered */ - public List getTabHierarchy(int tabId, int rootTab) { - return innerDao.getTabHierarchy(tabId, rootTab); - } - - /** note not currently filtered */ - public List getTabManuallyLinkedEntityURIs(int tab_id) { - return innerDao.getTabManuallyLinkedEntityURIs(tab_id); - } - - public List getTabsForPortal(int portalId) { - return setupFilteringTabs(filter(innerDao.getTabsForPortal(portalId),filters.getTabFilter())); - } - - public List getTabsForPortalByTabtypes(int portalId, boolean direction, - int tabtypeId) { - return setupFilteringTabs( - filter(innerDao.getTabsForPortalByTabtypes(portalId, direction, tabtypeId), - filters.getTabFilter()) ); - } - - /** - * Setup the filtering of the TabEntityFactory for the given Tab. - */ - private Tab setupFilteringTab(Tab in){ - return setupFilteringTabCarefully(in, new HashSet()); - } - - private List setupFilteringTabs( Collection tabs ){ - if( tabs == null ) return null; - LinkedList tabsOut = new LinkedList(); - Set visitedTabIds = new HashSet(); - for( Tab tab : tabs){ - tabsOut.add( setupFilteringTabCarefully( tab, visitedTabIds) ); - } - return tabsOut; - } - - private List setupFilteringTabs(Collection tabs, Set visitedTabIds){ - if( tabs == null ) return null; - LinkedList tabsOut = new LinkedList(); - for( Tab tab : tabs){ - tabsOut.add( setupFilteringTabCarefully( tab, visitedTabIds) ); - } - return tabsOut; - } - - /** Sets up filtering on tab and sub-tabs and keeps track of what tabs have - * already been visited*/ - private Tab setupFilteringTabCarefully( Tab in, Set visitedTabIds){ - if( visitedTabIds.contains( in.getTabId() )) { - return in; - } else { - //set up TabEntityFactory for in tab - if( in.grabEntityFactory() == null ) - return in; - else{ - - /* NOTICE: this does not use the individualFilter that was passed in the constructor - it uses one based on the parameters of the tab. */ - boolean ascendingSort = !"desc".equalsIgnoreCase(in.getEntitySortDirection()); - TabEntityFactoryFiltering filteringFact = - new TabEntityFactoryFiltering( - in.grabEntityFactory(), - FiltersForTabs.getFilterForTab( in, false ), - new VitroFilterUtils.EntitySortTransform( in.getEntitySortField(),ascendingSort)); - in.placeEntityFactory(filteringFact); - } - } - //deal with children - List children = setupFilteringTabs( in.getChildTabs(), visitedTabIds); - in.setChildTabs( children ); - - return in; - } - - -} \ No newline at end of file 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 020cd89be..15fe0a643 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 @@ -26,9 +26,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; import edu.cornell.mannlib.vitro.webapp.dao.PageDao; import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao; -import edu.cornell.mannlib.vitro.webapp.dao.TabDao; -import edu.cornell.mannlib.vitro.webapp.dao.TabIndividualRelationDao; -import edu.cornell.mannlib.vitro.webapp.dao.TabVClassRelationDao; import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao; import edu.cornell.mannlib.vitro.webapp.dao.UserDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; @@ -72,7 +69,6 @@ public class WebappDaoFactoryFiltering implements WebappDaoFactory { transient private ObjectPropertyStatementDao filteringObjectPropertyStatementDao=null; transient private VClassDao filteringVClassDao=null; - transient private TabDao filteringTabDao=null; transient private UserDao filteringUserDao=null; // TODO This goes away when the UserAccounts stuff is fully implemented - jblake. transient private UserAccountsDao filteringUserAccountsDao=null; transient private VClassGroupDao filteringVClassGroupDao=null; @@ -132,13 +128,6 @@ public class WebappDaoFactoryFiltering implements WebappDaoFactory { return filteringIndividualDao; } - public TabDao getTabDao() { - if( filteringTabDao == null) - filteringTabDao = - new TabDaoFiltering(innerWebappDaoFactory.getTabDao(),innerWebappDaoFactory.getApplicationDao(),filters); - return filteringTabDao; - } - // TODO This goes away when the UserAccounts stuff is fully implemented - jblake. public UserDao getUserDao() { if( filteringUserDao == null) @@ -190,14 +179,6 @@ public class WebappDaoFactoryFiltering implements WebappDaoFactory { return innerWebappDaoFactory.getUserURI(); } - public TabIndividualRelationDao getTabs2EntsDao() { - return innerWebappDaoFactory.getTabs2EntsDao(); - } - - public TabVClassRelationDao getTabs2TypesDao() { - return innerWebappDaoFactory.getTabs2TypesDao(); - } - public FlagDao getFlagDao() { return innerWebappDaoFactory.getFlagDao(); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/FiltersForTabs.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/FiltersForTabs.java deleted file mode 100644 index 3067f4445..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/FiltersForTabs.java +++ /dev/null @@ -1,260 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.dao.filtering.filters; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Comparator; -import java.util.Date; -import java.util.List; - -import net.sf.jga.algorithms.Sort; -import net.sf.jga.algorithms.Transform; -import net.sf.jga.algorithms.Unique; -import net.sf.jga.fn.UnaryFunctor; - -import org.joda.time.DateTime; - -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; - -/** - * Static methods to help create commonly used filters. - * - * User: bdc34 - * Date: Oct 19, 2007 - * Time: 11:56:18 AM - */ -public class FiltersForTabs { - public static final UnaryFunctor firstLetterOfName = new FirstLetterOfEnt(); - public static UnaryFunctor getFilterForTab( final Tab tab, final boolean isFlag1Filtering ){ - - DateTime now = new DateTime(); - UnaryFunctor entFilter = getTimeFilter(tab, now); - - /* need more? - entFilter = AdaptorFunctors.and( getSomeFilter(tab), entFilter); - entFilter = AdaptorFunctors.and( getOtherFilter(tab), entFilter); - */ - return entFilter; - } - - /** - * Create a filter for the entities based on the specifications of the tab. - */ - public static UnaryFunctor getTimeFilter(final Tab tab, final DateTime now){ - UnaryFunctor out = null; - - if( tab.getDayLimit() == 0){ - out = getSunsetWindowFilter( now.toDate() ).getIndividualFilter(); - - } else if( tab.getDayLimit() > 0 ) { - out = new UnaryFunctor(){ - public Boolean fn(Individual arg){ - if( arg.getTimekey() == null ) return Boolean.FALSE; - - DateTime timekey = new DateTime(arg.getTimekey()); - DateTime startShowingDate = timekey.minusDays( tab.getDayLimit() ); - - /* This is the filtering for events in the future */ - return now.isAfter( startShowingDate ) && now.isBefore( timekey ); - } - public String toString(){ return "DayLimit Filter: is timekey after now (" + now.toString() - + ") and timekey + daylimit is before now?"; - } - }; - - } else if ( tab.getDayLimit() < 0){ - out = new UnaryFunctor(){ - public Boolean fn(Individual arg){ - if( arg.getSunrise() == null ) return Boolean.FALSE; - - DateTime sunrise = new DateTime(arg.getSunrise()); - DateTime stopShowingDate = sunrise.plusDays( Math.abs( tab.getDayLimit() ) ); - - /* This is the filtering for press releases */ - return ( sunrise.isBefore( now ) || sunrise.isEqual( now ) ) - && now.isBefore( stopShowingDate ); - } - public String toString(){ return "Sunrise Filter: is sunrise before now and" + - " days between now and sunrise greater than or eq to daylimit?"; - } - }; - } - - return out; - } - - - /** - * Create a filter to pass only entities with labels that start with the given letter. - */ - public static UnaryFunctor getAlphaFilter(final String letter){ - return new UnaryFunctor(){ - public Boolean fn(Individual individual) { - return new Boolean( letter.equalsIgnoreCase( individual.getName() ) ); - } - public String toString(){ return "AlphaFilter on '" + letter - + "' for individual.name";} - }; - } -// -// /** -// * Sorts the entities in the way the tab specifies. -// * @param tab -// * @return -// */ -// public static UnaryFunctor, List> -// getTabOrderTransform(Tab tab){ -// boolean desc = "desc".equalsIgnoreCase( tab.getEntitySortDirection() ); -// return new VitroFilterFactory.EntitySortTransform( tab.getEntitySortField(),!desc); -// } - - /** - * Gets a transform that will return take a list of entities and return a - * list of first letters. - * @param tab - * @return - */ - public static UnaryFunctor,Collection> - getLetersOfEntsTransform(){ - return new UnaryFunctor,Collection>(){ - public Collection fn(Collection individuals) { - Iterablei = - Sort.sort( - Unique.unique( - Transform.transform( individuals, - VitroFilterUtils.FirstLetterOfIndividuals() ) - ) - ); - - ArrayList out = new ArrayList(26); - for( String str : i){ - out.add(str); - } - return out; - } - }; - } - - @SuppressWarnings("unchecked") - public static List getLettersOfEnts(List ents) { - Comparator comp = new Comparator(){ - public int compare(String o1, String o2) { - return o1.compareTo(o2); - }; - }; - Iterablei = - Unique.unique( - Sort.sort( - Transform.transform( ents ,firstLetterOfName ), - comp - ) - ); - - ArrayList out = new ArrayList(26); - for( String str : i){ - out.add(str); - } - return out; - } - - @SuppressWarnings("serial") - class FirstLetterFilter extends UnaryFunctor{ - String firstLetter; - public FirstLetterFilter(String alpha){ - firstLetter = alpha; - } - @Override - public Boolean fn(Individual arg){ - if( arg.getName() == null ) - return Boolean.FALSE; - else - return new Boolean( firstLetter.equalsIgnoreCase( arg.getName().substring(0,1) ) ); - } - } - - @SuppressWarnings("serial") - private static class FirstLetterOfEnt extends UnaryFunctor{ - @Override - public String fn(Individual arg) { - if( arg != null && arg.getName() != null && arg.getName().length() > 0 ){ - return arg.getName().substring(0,1).toUpperCase(); - } else { - return "?"; - } - } - } - - /** this filter accepts only objects which have sunset dates of the given date or - * earlier and sunset dates after the given date. sunrise <= givenDate < sunset. - * - * It is no longer in general use. It is only used by FitlersForTabs. - * @param givenDate - if null, use current date. - * */ - @SuppressWarnings("unchecked") - public static VitroFilters getSunsetWindowFilter(final Date givenDate ){ - - UnaryFunctor fn = - new UnaryFunctor(){ - Date given = givenDate; - //@Override - public Boolean fn(Individual arg) { - if( arg == null) return true; - return checkSunriseSunset(givenDate, arg.getSunrise(), arg.getSunset()); - } - public String toString(){ return "Individual time window filter " + given; }; - }; - - UnaryFunctor objPropfn = - new UnaryFunctor(){ - Date given = givenDate; - - //@Override - public Boolean fn(ObjectPropertyStatement arg) { - if( arg == null) return true; - if( checkSunriseSunset(givenDate, arg.getSunrise(), arg.getSunset()) == false) - return false; - - if( arg.getObject() != null ) { - Individual obj = arg.getObject(); - if( checkSunriseSunset(givenDate, obj.getSunrise(), obj.getSunset()) == false) - return false; - } - if( arg.getSubject() != null ){ - Individual sub = arg.getSubject(); - if( checkSunriseSunset(givenDate, sub.getSunrise(), sub.getSunset()) == false ) - return false; - } - return true; - } - public String toString(){ return "ObjectPropertyStatement time window filter " + given; }; - }; - - //we need these casts because of javac - VitroFiltersImpl vfilter = VitroFilterUtils.getNoOpFilter(); - vfilter.setIndividualFilter( fn ); - vfilter.setObjectPropertyStatementFilter(objPropfn); - return vfilter; - } - - - private static boolean checkSunriseSunset( Date now, Date sunrise, Date sunset){ - if( sunrise == null && sunset == null ) - return true; - - DateTime nowDt = (now!=null?new DateTime(now):new DateTime()); - DateTime sunriseDt = (sunrise != null ? new DateTime(sunrise): nowDt.minusDays(356)); - DateTime sunsetDt = (sunset != null ? new DateTime(sunset) : nowDt.plusDays(356)); - - if( ( nowDt.isBefore( sunsetDt ) ) - && - ( nowDt.isAfter( sunriseDt ) - || nowDt.toDateMidnight().isEqual( sunriseDt.toDateMidnight())) - ) - return true; - else - return false; - } -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/VitroFilters.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/VitroFilters.java index ef42e7cc2..5ce76f052 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/VitroFilters.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/VitroFilters.java @@ -9,7 +9,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty; import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement; import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; import edu.cornell.mannlib.vitro.webapp.beans.User; import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; @@ -37,14 +36,12 @@ public interface VitroFilters { public UnaryFunctor getClassFilter(); - public UnaryFunctor getTabFilter(); - - public UnaryFunctor getVClassGroupFilter(); // TODO This goes away when the UserAccounts stuff is fully implemented -- jb public UnaryFunctor getUserFilter(); + public UnaryFunctor getPropertyGroupFilter(); } \ No newline at end of file diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/VitroFiltersBase.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/VitroFiltersBase.java index b1c303891..1ff4fded0 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/VitroFiltersBase.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/VitroFiltersBase.java @@ -18,7 +18,6 @@ public abstract class VitroFiltersBase implements VitroFilters { AdaptorFunctors.and(this.getDataPropertyStatementFilter(),other.getDataPropertyStatementFilter()), AdaptorFunctors.and(this.getObjectPropertyStatementFilter(),other.getObjectPropertyStatementFilter()), AdaptorFunctors.and(this.getClassFilter(),other.getClassFilter()), - AdaptorFunctors.and(this.getTabFilter(),other.getTabFilter()), AdaptorFunctors.and(this.getVClassGroupFilter(),other.getVClassGroupFilter()), AdaptorFunctors.and(this.getUserFilter(), other.getUserFilter()), AdaptorFunctors.and(this.getPropertyGroupFilter(), other.getPropertyGroupFilter()) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/VitroFiltersImpl.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/VitroFiltersImpl.java index ac9572ced..efd70e5b4 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/VitroFiltersImpl.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/VitroFiltersImpl.java @@ -2,9 +2,17 @@ package edu.cornell.mannlib.vitro.webapp.dao.filtering.filters; -import edu.cornell.mannlib.vitro.webapp.beans.*; import net.sf.jga.fn.UnaryFunctor; import net.sf.jga.fn.adaptor.AdaptorFunctors; +import edu.cornell.mannlib.vitro.webapp.beans.DataProperty; +import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement; +import edu.cornell.mannlib.vitro.webapp.beans.Individual; +import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty; +import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement; +import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup; +import edu.cornell.mannlib.vitro.webapp.beans.User; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; /** * A object to hold all the filters commonly used by the vitro webapp. @@ -32,9 +40,6 @@ public class VitroFiltersImpl extends VitroFiltersBase { UnaryFunctor classFilter; /* *************** filters only used by Webapp ******************* */ - /** filter for Tab objects */ - UnaryFunctor tabFilter; - /** filter for VClassGroup objects */ UnaryFunctor vClassGroupFilter; @@ -58,7 +63,6 @@ public class VitroFiltersImpl extends VitroFiltersBase { dataPropertyStatementFilter = FILTER_OUT_NOTHING; objectPropertyStatementFilter= FILTER_OUT_NOTHING; classFilter= FILTER_OUT_NOTHING; - tabFilter= FILTER_OUT_NOTHING; vClassGroupFilter = FILTER_OUT_NOTHING; userFilter= FILTER_OUT_NOTHING; propertyGroupFilter = FILTER_OUT_NOTHING; @@ -71,7 +75,6 @@ public class VitroFiltersImpl extends VitroFiltersBase { UnaryFunctor dataPropertyStatementFilter, UnaryFunctor objectPropertyStatementFilter, UnaryFunctor classFilter, - UnaryFunctor tabFilter, UnaryFunctor classGroupFilter, UnaryFunctor userFilter, UnaryFunctorpropertyGroupFilter) { @@ -82,7 +85,6 @@ public class VitroFiltersImpl extends VitroFiltersBase { this.dataPropertyStatementFilter = dataPropertyStatementFilter; this.objectPropertyStatementFilter = objectPropertyStatementFilter; this.classFilter = classFilter; - this.tabFilter = tabFilter; vClassGroupFilter = classGroupFilter; this.userFilter = userFilter; this.propertyGroupFilter = propertyGroupFilter; @@ -165,18 +167,6 @@ public class VitroFiltersImpl extends VitroFiltersBase { return this; } - /* (non-Javadoc) - * @see edu.cornell.mannlib.vitro.webapp.dao.filtering.VitroFilters#getTabFilter() - */ - public UnaryFunctor getTabFilter() { - return tabFilter; - } - - public VitroFilters setTabFilter(UnaryFunctor tabFilter) { - this.tabFilter = tabFilter; - return this; - } - /* (non-Javadoc) * @see edu.cornell.mannlib.vitro.webapp.dao.filtering.VitroFilters#getVClassGroupFilter() */ diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/tabFactory/TabEntityFactoryFiltering.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/tabFactory/TabEntityFactoryFiltering.java deleted file mode 100644 index 6c8b27d27..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/tabFactory/TabEntityFactoryFiltering.java +++ /dev/null @@ -1,76 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.dao.filtering.tabFactory; - -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.dao.TabEntityFactory; -import edu.cornell.mannlib.vitro.webapp.dao.filtering.BaseFiltering; -import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.FiltersForTabs; -import net.sf.jga.algorithms.*; -import net.sf.jga.fn.UnaryFunctor; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -public class TabEntityFactoryFiltering extends BaseFiltering implements TabEntityFactory { - - TabEntityFactory _innerTabFactory; - UnaryFunctor _entityFilter; - List _innerEnts; - List _filteredEnts; - UnaryFunctor,List> _sorting; - - public TabEntityFactoryFiltering(TabEntityFactory factory, - UnaryFunctor filter, - UnaryFunctor,List> sorting) { - super(); - _innerTabFactory = factory; - _entityFilter = filter; - _sorting = sorting; - } - - @SuppressWarnings("unchecked") - public List getLettersOfEnts() { - ArrayList out = new ArrayList(); - List ents = getInnerEnts(); - filter(ents,_entityFilter); - return FiltersForTabs.getLettersOfEnts( ents); - } - - /** Get entities from innerTabFactory filtered by entityFilter. */ - @SuppressWarnings("unchecked") - public List getRelatedEntites(String alpha) { - List ents = _innerTabFactory.getRelatedEntites( alpha ); - if( ents == null ) return Collections.EMPTY_LIST; - - - List outEnts = new LinkedList(); - if(_entityFilter != null) - Filter.filter( ents , _entityFilter , outEnts); - if( _sorting != null ) - outEnts = _sorting.fn( outEnts ); - - if( alpha != null && ! "all".equals(alpha)) - filter(outEnts, FiltersForTabs.getAlphaFilter(alpha)); - - return outEnts; - } - - public int getRelatedEntityCount() { - return (int)Summarize.count(getInnerEnts(), _entityFilter); - } - - @SuppressWarnings("unchecked") - protected List getInnerEnts(){ - if( _innerEnts == null ) - _innerEnts = _innerTabFactory.getRelatedEntites("all"); - return _innerEnts; - } - - public String toString(){ - return "TabEntityFactoryFiltering: " + (_entityFilter == null ? "null" : _entityFilter.toString()) + - " innerDao: " + (_innerTabFactory == null ? "null" : _innerTabFactory.toString()); - } -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoJena.java index cf1185231..732d40891 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoJena.java @@ -875,8 +875,6 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao { String type = typeRes.getURI(); // brute forcing this until we implement a better strategy if (VitroVocabulary.PORTAL.equals(type) || - VitroVocabulary.TAB.equals(type) || - VitroVocabulary.TAB_INDIVIDUALRELATION.equals(type) || VitroVocabulary.LINK.equals(type) || VitroVocabulary.KEYWORD.equals(type) || VitroVocabulary.KEYWORD_INDIVIDUALRELATION.equals(type) || diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoSDB.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoSDB.java index 466aaa044..9604599bd 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoSDB.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoSDB.java @@ -114,7 +114,8 @@ public class IndividualDaoSDB extends IndividualDaoJena { "SELECT DISTINCT ?ind ?label ?moniker " + "WHERE " + "{ \n" + - "{ \n" + + "{ ?ind a <" + theClass.getURI() + "> } \n" + + "UNION { \n" + " ?ind a <" + theClass.getURI() + "> . \n" + " ?ind <" + RDFS.label.getURI() + "> ?label \n" + "} \n" + diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaBaseDaoCon.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaBaseDaoCon.java index fa319b6a5..dcf86672d 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaBaseDaoCon.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaBaseDaoCon.java @@ -119,7 +119,6 @@ public class JenaBaseDaoCon { // protected DatatypeProperty APPLICATION_MAXPORTALID = null; protected OntClass PORTAL = _constModel.createClass(VitroVocabulary.PORTAL); - protected ObjectProperty PORTAL_ROOTTAB = _constModel.createObjectProperty(VitroVocabulary.PORTAL_ROOTTAB); protected DatatypeProperty APPLICATION_THEMEDIR = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_THEMEDIR); protected DatatypeProperty PORTAL_BANNERIMAGE = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_BANNERIMAGE); //protected DatatypeProperty PORTAL_FLAG2VALUES = null; @@ -142,40 +141,6 @@ public class JenaBaseDaoCon { protected DatatypeProperty PORTAL_IMAGETHUMBWIDTH = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_IMAGETHUMBWIDTH); protected DatatypeProperty PORTAL_URLPREFIX = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_URLPREFIX); - protected OntClass TAB = _constModel.createClass(VitroVocabulary.TAB); - protected OntClass TAB_AUTOLINKABLETAB = _constModel.createClass(VitroVocabulary.TAB_AUTOLINKABLETAB); - protected OntClass TAB_MANUALLYLINKABLETAB = _constModel.createClass(VitroVocabulary.TAB_MANUALLYLINKABLETAB); - protected OntClass TAB_MIXEDTAB = _constModel.createClass(VitroVocabulary.TAB_MIXEDTAB); - protected OntClass TAB_PRIMARYTAB = _constModel.createClass(VitroVocabulary.TAB_PRIMARYTAB); - protected OntClass TAB_SUBCOLLECTIONCATEGORY = _constModel.createClass(VitroVocabulary.TAB_SUBCOLLECTIONCATEGORY); - protected OntClass TAB_SECONDARYTAB = _constModel.createClass(VitroVocabulary.TAB_SECONDARYTAB); - protected OntClass TAB_PRIMARYTABCONTENT = _constModel.createClass(VitroVocabulary.TAB_PRIMARYTABCONTENT); - protected OntClass TAB_SUBCOLLECTION = _constModel.createClass(VitroVocabulary.TAB_SUBCOLLECTION); - protected ObjectProperty TAB_SUBTABOF = _constModel.createObjectProperty(VitroVocabulary.TAB_SUBTABOF); - protected OntClass TAB_COLLECTION = _constModel.createClass(VitroVocabulary.TAB_COLLECTION); - // protected ObjectProperty TAB_LINKEDENTITY = null; - protected AnnotationProperty TAB_AUTOLINKEDTOTAB = _constModel.createAnnotationProperty(VitroVocabulary.TAB_AUTOLINKEDTOTAB); - protected DatatypeProperty TAB_STATUSID = _constModel.createDatatypeProperty(VitroVocabulary.TAB_STATUSID); - protected DatatypeProperty TAB_DAYLIMIT = _constModel.createDatatypeProperty(VitroVocabulary.TAB_DAYLIMIT); - protected DatatypeProperty TAB_BODY = _constModel.createDatatypeProperty(VitroVocabulary.TAB_BODY); - protected DatatypeProperty TAB_GALLERYROWS = _constModel.createDatatypeProperty(VitroVocabulary.TAB_GALLERYROWS); - protected DatatypeProperty TAB_GALLERYCOLS = _constModel.createDatatypeProperty(VitroVocabulary.TAB_GALLERYCOLS); - protected DatatypeProperty TAB_MORETAG = _constModel.createDatatypeProperty(VitroVocabulary.TAB_MORETAG); - protected DatatypeProperty TAB_IMAGEWIDTH = _constModel.createDatatypeProperty(VitroVocabulary.TAB_IMAGEWIDTH); - protected ObjectProperty TAB_PORTAL = _constModel.createObjectProperty(VitroVocabulary.TAB_PORTAL); - protected DatatypeProperty TAB_ENTITYSORTFIELD = _constModel.createDatatypeProperty(VitroVocabulary.TAB_ENTITYSORTFIELD); - protected DatatypeProperty TAB_ENTITYSORTDIRECTION = _constModel.createDatatypeProperty(VitroVocabulary.TAB_ENTITYSORTDIRECTION); - //protected DatatypeProperty TAB_ENTITYLINKMETHOD = null; - protected DatatypeProperty TAB_RSSURL = _constModel.createDatatypeProperty(VitroVocabulary.TAB_RSSURL); - protected DatatypeProperty TAB_FLAG2SET = _constModel.createDatatypeProperty(VitroVocabulary.TAB_FLAG2SET); - protected DatatypeProperty TAB_FLAG3SET = _constModel.createDatatypeProperty(VitroVocabulary.TAB_FLAG3SET); - protected DatatypeProperty TAB_FLAG2MODE = _constModel.createDatatypeProperty(VitroVocabulary.TAB_FLAG2MODE); - protected DatatypeProperty TAB_FLAG3MODE = _constModel.createDatatypeProperty(VitroVocabulary.TAB_FLAG3MODE); - - protected OntClass TAB_INDIVIDUALRELATION = _constModel.createClass(VitroVocabulary.TAB_INDIVIDUALRELATION); - protected ObjectProperty TAB_INDIVIDUALRELATION_INVOLVESINDIVIDUAL = _constModel.createObjectProperty(VitroVocabulary.TAB_INDIVIDUALRELATION_INVOLVESINDIVIDUAL); - protected ObjectProperty TAB_INDIVIDUALRELATION_INVOLVESTAB = _constModel.createObjectProperty(VitroVocabulary.TAB_INDIVIDUALRELATION_INVOLVESTAB); - protected AnnotationProperty ONTOLOGY_PREFIX_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.ONTOLOGY_PREFIX_ANNOT); protected OntClass FS_FILE = _constModel.createClass(VitroVocabulary.FS_FILE_CLASS); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/TabDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/TabDaoJena.java deleted file mode 100644 index bb6e05ae0..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/TabDaoJena.java +++ /dev/null @@ -1,887 +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.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.hp.hpl.jena.ontology.Individual; -import com.hp.hpl.jena.ontology.ObjectProperty; -import com.hp.hpl.jena.ontology.OntClass; -import com.hp.hpl.jena.ontology.OntModel; -import com.hp.hpl.jena.rdf.model.Property; -import com.hp.hpl.jena.rdf.model.RDFNode; -import com.hp.hpl.jena.rdf.model.Resource; -import com.hp.hpl.jena.rdf.model.ResourceFactory; -import com.hp.hpl.jena.rdf.model.Statement; -import com.hp.hpl.jena.shared.Lock; -import com.hp.hpl.jena.util.iterator.ClosableIterator; - -import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; -import edu.cornell.mannlib.vitro.webapp.beans.TabIndividualRelation; -import edu.cornell.mannlib.vitro.webapp.dao.TabDao; -import edu.cornell.mannlib.vitro.webapp.dao.TabEntityFactory; -import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; -import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; -import edu.cornell.mannlib.vitro.webapp.dao.jena.tabFactory.TabEntityFactoryAutoJena; -import edu.cornell.mannlib.vitro.webapp.dao.jena.tabFactory.TabEntityFactoryGalleryJena; -import edu.cornell.mannlib.vitro.webapp.dao.jena.tabFactory.TabEntityFactoryManualJena; -import edu.cornell.mannlib.vitro.webapp.dao.jena.tabFactory.TabEntityFactoryMixedJena; - -public class TabDaoJena extends JenaBaseDao implements TabDao { - - public TabDaoJena(WebappDaoFactoryJena wadf) { - super(wadf); - try { - entityLinkMethods = new HashMap(); - entityLinkMethods.put("auto",TAB_AUTOLINKABLETAB); - entityLinkMethods.put("manual",TAB_MANUALLYLINKABLETAB); - List mixedTypes = new LinkedList(); - mixedTypes.add(TAB_MIXEDTAB); - mixedTypes.add(TAB_AUTOLINKABLETAB); - mixedTypes.add(TAB_MANUALLYLINKABLETAB); - entityLinkMethods.put("mixed", mixedTypes); - tabtypes = new HashMap(); - tabtypes.put(18, TAB_SUBCOLLECTIONCATEGORY); - tabtypes.put(20, TAB_SUBCOLLECTION); - tabtypes.put(22, TAB_COLLECTION); - tabtypes.put(24, TAB_SECONDARYTAB); - tabtypes.put(26, TAB_PRIMARYTABCONTENT); - tabtypes.put(28, TAB_PRIMARYTAB); - } catch (Exception e) { - log.error("error constructing convenience HashMaps in TabDaoJena() constructor "+e.getStackTrace()); - } - } - - private static final Log log = LogFactory.getLog(TabDaoJena.class.getName()); - - /* constant to use when calling recursiveAddChildTabs to get all children */ - final static int NO_DEPTH_LIMIT = -1; - - /* gets portal id from portal's uri */ - Pattern portalIdFromUriPattern = Pattern.compile("^.*portal(.*)$"); - - private HashMap entityLinkMethods = null; - private HashMap tabtypes = null; - - @Override - protected OntModel getOntModel() { - return getOntModelSelector().getApplicationMetadataModel(); - } - - private class TabAlphabetizer implements java.util.Comparator { - public int compare (Object o1, Object o2) { - return (((Tab)o1).getTitle()).compareTo(((Tab)o2).getTitle()); - } - } - - public void addParentTab(Tab tab, Tab parent) { - addParentTab(tab,parent,getOntModel()); - } - - public void addParentTab(Tab tab, Tab parent, OntModel ontModel) { - ontModel.enterCriticalSection(Lock.WRITE); - try { - Resource childRes = ontModel.getResource(DEFAULT_NAMESPACE+"tab"+tab.getTabId()); - Resource parentRes = ontModel.getResource(DEFAULT_NAMESPACE+"tab"+parent.getTabId()); - if (childRes != null && parentRes != null && TAB_SUBTABOF != null) { - ontModel.add(childRes, TAB_SUBTABOF, parentRes); - } - } finally { - ontModel.leaveCriticalSection(); - } - } - - public void addParentTab(String tabURI, String parentURI) { - - } - - public void removeParentTab(Tab tab, Tab parent) { - removeParentTab(tab,parent,getOntModel()); - } - - public void removeParentTab(Tab tab, Tab parent, OntModel ontModel) { - ontModel.enterCriticalSection(Lock.WRITE); - try { - Resource childRes = ontModel.getResource(DEFAULT_NAMESPACE+"tab"+tab.getTabId()); - Resource parentRes = ontModel.getResource(DEFAULT_NAMESPACE+"tab"+parent.getTabId()); - if (childRes != null && parentRes != null && TAB_SUBTABOF != null) { - ontModel.remove(childRes, TAB_SUBTABOF, parentRes); - } - } finally { - ontModel.leaveCriticalSection(); - } - } - - public void removeParentTab(String tabURI, String parentURI) { - - } - - public List getParentTabs(Tab tab) { - return getParentTabs(DEFAULT_NAMESPACE+"tab"+tab.getTabId()); - } - - public List getParentTabs(String tabURI) { - List parentList = new ArrayList(); - com.hp.hpl.jena.ontology.Individual tabInd = getOntModel().getIndividual(tabURI); - ClosableIterator stmtIt = getOntModel().listStatements(tabInd, TAB_SUBTABOF, (Resource)null); - try { - while (stmtIt.hasNext()) { - Statement stmt = (Statement) stmtIt.next(); - Resource parentRes = (Resource) stmt.getObject(); - if (parentRes != null) { - com.hp.hpl.jena.ontology.Individual parentInd = getOntModel().getIndividual(parentRes.getURI()); - parentList.add(tabFromTabIndividual(parentInd)); - } - } - } finally { - stmtIt.close(); - } - return parentList; - } - - public List getChildTabs(Tab tab) { - return getChildTabs(DEFAULT_NAMESPACE+"tab"+tab.getTabId()); - } - - public List getChildTabs(String tabURI) { - List childList = new ArrayList(); - com.hp.hpl.jena.ontology.Individual tabInd = getOntModel().getIndividual(tabURI); - ClosableIterator stmtIt = getOntModel().listStatements(null, TAB_SUBTABOF, tabInd); - try { - while (stmtIt.hasNext()) { - Statement stmt = (Statement) stmtIt.next(); - Resource childRes = stmt.getSubject(); - if (childRes != null) { - com.hp.hpl.jena.ontology.Individual childInd = getOntModel().getIndividual(childRes.getURI()); - childList.add(tabFromTabIndividual(childInd)); - } - } - } finally { - stmtIt.close(); - } - return childList; - } - - public int cloneTab(int tabId) throws Exception { - // TODO Auto-generated method stub - return 0; - } - - public void deleteTab(Tab tab) { - deleteTab(tab,getOntModel()); - } - - public void deleteTab(Tab tab, OntModel ontModel) { - ontModel.enterCriticalSection(Lock.WRITE); - try { - Individual tabInd = ontModel.getIndividual(DEFAULT_NAMESPACE+"tab"+tab.getTabId()); - if (tabInd != null) - tabInd.remove(); - } finally { - ontModel.leaveCriticalSection(); - } - } - - public List getAllAutolinkableTabs(int portalId) { - List tabs = new ArrayList(); - getOntModel().enterCriticalSection(Lock.READ); - try { - ClosableIterator tabIt = getOntModel().listIndividuals(TAB_AUTOLINKABLETAB); - try { - while (tabIt.hasNext()) { - tabs.add(tabFromTabIndividual((Individual) tabIt.next())); - } - } finally { - tabIt.close(); - } - } finally { - getOntModel().leaveCriticalSection(); - } - return tabs; - } - - public List getAllManuallyLinkableTabs(int portalId) { - List tabs = new LinkedList(); - getOntModel().enterCriticalSection(Lock.READ); - try { - ClosableIterator tabIt = getOntModel().listIndividuals(TAB_MANUALLYLINKABLETAB); - try { - while (tabIt.hasNext()) { - tabs.add(tabFromTabIndividual((Individual) tabIt.next())); - } - } finally { - tabIt.close(); - } - } finally { - getOntModel().leaveCriticalSection(); - } - return tabs; - } - - /** - * returns a list of URI strings of VClasses auto-affiliated with tab (tabId) - */ - public List getTabAutoLinkedVClassURIs(int tabId) { - List typeURIs = new LinkedList(); - getOntModel().enterCriticalSection(Lock.READ); - try { - Resource tab = getOntModel().getResource(DEFAULT_NAMESPACE+"tab"+tabId); - if (tab != null && TAB_AUTOLINKEDTOTAB != null) { - ClosableIterator typeIt = getOntModel().listStatements(null, TAB_AUTOLINKEDTOTAB, tab); - try { - while (typeIt.hasNext()) { - Statement st = (Statement) typeIt.next(); - Resource type = st.getSubject(); - if (type != null) { - typeURIs.add(type.getURI()); - } - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - typeIt.close(); - } - } - } finally { - getOntModel().leaveCriticalSection(); - } - return typeURIs; - } - - /** - * returns a list of URI strings of Entities manually linked to tab (tabId) - */ - public List getTabManuallyLinkedEntityURIs(int tab_id) { - List entityURIs = new LinkedList(); - TabIndividualRelationDaoJena tabToIndDao = new TabIndividualRelationDaoJena( getWebappDaoFactory() ); - List tabsToInd = tabToIndDao.getTabIndividualRelationsByTabURI( DEFAULT_NAMESPACE+"tab"+tab_id ); - if( tabsToInd != null ){ - for( TabIndividualRelation rel : tabsToInd){ - if( rel != null && rel.getEntURI() != null) - entityURIs.add( rel.getEntURI() ); - } - } - return entityURIs; - } - - public String getNameForTabId(int tabId) { - getOntModel().enterCriticalSection(Lock.READ); - try { - Individual tabInd = getOntModel().getIndividual(DEFAULT_NAMESPACE+"tab"+tabId); - if (tabInd != null) { - return getLabelOrId(tabInd); - } else { - return null; - } - } finally { - getOntModel().leaveCriticalSection(); - } - } - - /** - * Get an ordered list of primary tabs for a given portal. - */ - public List getPrimaryTabs(int portalId){ - getOntModel().enterCriticalSection(Lock.READ); - try { - List primaryTabs = new LinkedList(); - ClosableIterator tabIt = getOntModel().listIndividuals(TAB_PRIMARYTAB); - try { - while (tabIt.hasNext()) { - Individual tabInd = (Individual) tabIt.next(); - ObjectProperty inPortal = TAB_PORTAL; - if (inPortal == null) - return null; - Statement stmt = tabInd.getProperty(inPortal); - if (stmt != null) { - Resource portal = (Resource) stmt.getObject(); - if (portal != null) { - int tabPortalId = (Integer.decode(portal.getLocalName().substring(6))).intValue(); - if (portalId == tabPortalId) { - primaryTabs.add(tabFromTabIndividual(tabInd)); - } - } - } - } - } finally { - tabIt.close(); - } - Collections.sort(primaryTabs, new TabComparator()); - return primaryTabs; - } finally { - getOntModel().leaveCriticalSection(); - } - } - - public int getRootTabId(int portalId) { - getOntModel().enterCriticalSection(Lock.READ); - try { - Individual portalInd = getOntModel().getIndividual(DEFAULT_NAMESPACE+"portal"+portalId); - if (portalInd == null) - return -1; - Resource rootTabResource = (Resource) portalInd.getProperty(PORTAL_ROOTTAB).getObject(); - if (rootTabResource == null) - return -1; - String id = rootTabResource.getLocalName().substring(3); - return Integer.decode(id); - } finally { - getOntModel().leaveCriticalSection(); - } - } - - public List getSecondaryTabs(int primaryTabId) { - getOntModel().enterCriticalSection(Lock.READ); - try { - Individual primaryTabInd = getOntModel().getIndividual(DEFAULT_NAMESPACE+"tab"+primaryTabId); - if (primaryTabInd != null) { - ObjectProperty subTabOf = TAB_SUBTABOF; - if (subTabOf != null) { - List secondaryTabs = new ArrayList(); - Iterator stmtIt = getOntModel().listStatements(null, subTabOf, primaryTabInd); - while (stmtIt.hasNext()) { - // I think there's a better way of doing the next line - Individual secondaryTabInd = getOntModel().getIndividual(((Resource)((Statement)stmtIt.next()).getSubject()).getURI()); - if (secondaryTabInd != null) { - Iterator typesIt = secondaryTabInd.listRDFTypes(false); - while (typesIt.hasNext()) { - Resource type = (Resource) typesIt.next(); - if (type.getURI().equals(VitroVocabulary.TAB_SECONDARYTAB)) { - secondaryTabs.add(tabFromTabIndividual(secondaryTabInd)); - break; - } - } - } - } - Collections.sort(secondaryTabs, new TabComparator()); - return secondaryTabs; - } else { - return null; - } - } else { - return null; - } - } finally { - getOntModel().leaveCriticalSection(); - } - } - - private class TabComparator implements Comparator { - public int compare (Object o1, Object o2) { - return ((Tab)o1).getDisplayRank()-((Tab)o2).getDisplayRank(); - } - } - - /************************************************************* - * This makes a new tab, sets up the TabEntityFactory - * and gets all children tabs (excluding cycles). - * - * - @param tab_id - int: tab to retrieve from database - @param auth_level - int: if <0, don't check entity statusId; - otherwise filter to entities whose statusId<=auth_level - @param app - ApplicationBean with info about flags and time filtering. - @return a tab object; - **/ - public Tab getTab(int tab_id, int auth_level, ApplicationBean app) { - Tab tab = getTabWithEntityFact(tab_id, auth_level,app); - recursiveAddChildTabs(tab,null,auth_level,app ,NO_DEPTH_LIMIT); - return tab; - } - - /************************************************************* - * This makes a new tab, sets up the TabEntityFactory - * and gets all children tabs (excluding cycles). - * - * - @param tab_id - int: tab to retrieve from database - @param auth_level - int: if <0, don't check entity statusId; - otherwise filter to entities whose statusId<=auth_level - @param app - ApplicationBean with info about flags and time filtering. - @param depth - depth of child tabs to get. 0==none, 1==first generation, - 2==child and grandchild tabs, etc. passing -1 here will get all children. - @return a tab object; - */ - public Tab getTab(int tab_id, int auth_level, ApplicationBean app, int depth) { - Tab tab = getTabWithEntityFact(tab_id, auth_level,app); - recursiveAddChildTabs(tab,null,auth_level,app ,depth ); - return tab; - } - - public Tab getTab(int tab_id) { - getOntModel().enterCriticalSection(Lock.READ); - try { - Individual tabInd = getOntModel().getIndividual(DEFAULT_NAMESPACE+"tab"+tab_id); - if (tabInd != null) - return tabFromTabIndividual(tabInd); - else - return null; - } finally { - getOntModel().leaveCriticalSection(); - } - } - - //doesn't seem to be used anywhere - public Tab getTabByName(String tabName) { - // TODO Auto-generated method stub - return null; - } - - /** - * Gets the tab hierarchy above a tab as a list of tab Ids. - * Boradest tab id is first, requested tabId is last in list. - * If you want the portals root tab to be the first in the list - * you can put the id for that tab in rootTab. Otherwise the list - * returned only goes up the first tab with no broader tab. - * @param tabId - * @param rootTab if > 0 prepend as root - * @return List of Integer objects - */ - public List getTabHierarchy(int tabId, int rootTab){ - List hier = new LinkedList(); - hier.add(0,new Integer(tabId)); - int current = tabId; - Integer broader = null; - boolean keepChecking = true; - while ( keepChecking ){ - broader = getBroaderTabId( current ); - if( broader != null ){ - keepChecking = true; - current = broader.intValue(); - hier.add(0,broader);//stick on front of list - }else{ - keepChecking = false; - } - } - - //append root tab if it is not redundent or negative - if(rootTab > 0 && rootTab != tabId && rootTab != current) - hier.add(0,new Integer(rootTab)); - return hier; - } - - private Integer getBroaderTabId(int tabId){ - getOntModel().enterCriticalSection(Lock.READ); - try { - Integer i = null; - Individual narrowerTab = getOntModel().getIndividual(DEFAULT_NAMESPACE+"tab"+tabId); - if (narrowerTab != null) { - ObjectProperty subTabOf = TAB_SUBTABOF; - if (subTabOf != null) { - Iterator stmtIt = narrowerTab.listProperties(subTabOf); - if (stmtIt.hasNext()) { - return Integer.decode(((Resource)((Statement)stmtIt.next()).getObject()).getLocalName().substring(3)); - } - } - } - return i; - } finally { - getOntModel().leaveCriticalSection(); - } - } - - public List getTabsForPortal(int portalId) { - List tabsForPortal = new ArrayList(); - getOntModel().enterCriticalSection(Lock.READ); - try { - Individual thePortal = getOntModel().getIndividual(DEFAULT_NAMESPACE+"portal"+portalId); - if (thePortal != null){ - Iterator stmtIt = getOntModel().listStatements(null, TAB_PORTAL, thePortal); - while (stmtIt.hasNext()) { - Individual tabInd = (Individual)((Resource)((Statement)stmtIt.next()).getSubject()).as(Individual.class); - tabsForPortal.add(tabFromTabIndividual(tabInd)); - } - try { - Collections.sort(tabsForPortal, new TabAlphabetizer()); - } catch (Exception e) { - log.error(this.getClass().getName()+".getTabsForPortal(): error sorting tab list"); - } - } - return tabsForPortal; - } finally { - getOntModel().leaveCriticalSection(); - } - } - - public List getTabsForPortalByTabtypes(int portalId, boolean direction, - int tabtypeId) { - List filtered = new LinkedList(); - Iterator allIt = this.getTabsForPortal(portalId).iterator(); - while (allIt.hasNext()) { - Tab t = (Tab) allIt.next(); - if (direction) { - if (t.getTabtypeId() > tabtypeId) { - filtered.add(t); - } - } else { - if (t.getTabtypeId() < tabtypeId) { - filtered.add(t); - } - } - } - return filtered; - } - - public int insertTab(Tab tab) { - return insertTab(tab, getOntModel()); - } - - public int insertTab(Tab tab, OntModel ontModel) { - String nameStr = tab.getTitle(); - Individual tabInd = null; - if (tab.getTabId() < 0) - tab.setTabId(Math.abs((nameStr).hashCode())); - boolean inserted=false; - while (!inserted) { - ontModel.enterCriticalSection(Lock.READ); - Individual dupTestInd = null; - try { - dupTestInd = ontModel.getIndividual(DEFAULT_NAMESPACE+tab.getTabId()); - } finally { - ontModel.leaveCriticalSection(); - } - if (dupTestInd != null) { - nameStr+="a"; - tab.setTabId(Math.abs((nameStr).hashCode())); - } else { - ontModel.enterCriticalSection(Lock.WRITE); - try { - tabInd = ontModel.createIndividual(DEFAULT_NAMESPACE+"tab"+tab.getTabId(), this.TAB); - inserted = true; - } finally { - ontModel.leaveCriticalSection(); - } - } - } - ontModel.enterCriticalSection(Lock.WRITE); - try { - try { - tabInd.setLabel(tab.getTitle(), (String) getDefaultLanguage()); - } catch (Exception e) {log.error("error setting label for "+tabInd.getURI());} - addPropertyStringValue(tabInd, DESCRIPTION, tab.getDescription(), ontModel); - addPropertyNonNegativeIntValue(tabInd, TAB_STATUSID, tab.getStatusId(), ontModel); - addPropertyStringValue(tabInd, TAB_BODY, tab.getBody(), ontModel); - addPropertyNonNegativeIntValue(tabInd, DISPLAY_RANK, tab.getDisplayRank(), ontModel); - addPropertyIntValue(tabInd, TAB_DAYLIMIT, tab.getDayLimit(), ontModel); - addPropertyNonNegativeIntValue(tabInd, TAB_GALLERYROWS, tab.getGalleryRows(), ontModel); - addPropertyNonNegativeIntValue(tabInd, TAB_GALLERYCOLS, tab.getGalleryCols(), ontModel); - addPropertyStringValue(tabInd, TAB_MORETAG, tab.getMoreTag(), ontModel); - addPropertyNonNegativeIntValue(tabInd, TAB_IMAGEWIDTH, tab.getImageWidth(), ontModel); - addPropertyStringValue(tabInd, TAB_ENTITYSORTFIELD, tab.getEntitySortField(), ontModel); - addPropertyStringValue(tabInd, TAB_ENTITYSORTDIRECTION, tab.getEntitySortDirection(), ontModel); - addPropertyStringValue(tabInd, TAB_FLAG2MODE, tab.getFlag2Mode(), ontModel); - addPropertyStringValue(tabInd, TAB_FLAG2SET, tab.getFlag2Set(), ontModel); - try { - Object o = entityLinkMethods.get(tab.getEntityLinkMethod()); - if (o instanceof List) { - for (Object type : (List) o) { - tabInd.addRDFType((Resource) type); - } - } else { - tabInd.addRDFType((Resource) o); - } - } catch (Exception e) {log.error("error setting entityLinkType for tab "+tabInd.getURI());} - try { - Resource tabTypeRes = (Resource)tabtypes.get(tab.getTabtypeId()); - if (tabTypeRes != null) { - tabInd.addRDFType(tabTypeRes); - } - } catch (Exception e) {log.error("error setting tabtype for tab "+tabInd.getURI());} - return tab.getTabId(); - } finally { - ontModel.leaveCriticalSection(); - } - } - - public void updateTab(Tab tab) { - updateTab(tab,getOntModel()); - } - - public void updateTab(Tab tab, OntModel ontModel) { - ontModel.enterCriticalSection(Lock.WRITE); - try { - if (tab.getTabId() > -1) { - Individual tabInd = ontModel.getIndividual(DEFAULT_NAMESPACE+"tab"+tab.getTabId()); - if (tabInd != null) { - try { - tabInd.setLabel(tab.getTitle(), (String) getDefaultLanguage()); - } catch (Exception e) {log.error("Error updating title for tab "+tab.getTabId());} - updatePropertyStringValue(tabInd, DESCRIPTION, tab.getDescription(), ontModel); - updatePropertyNonNegativeIntValue(tabInd, TAB_STATUSID, tab.getStatusId(), ontModel); - updatePropertyStringValue(tabInd, TAB_BODY, tab.getBody(), ontModel); - updatePropertyNonNegativeIntValue(tabInd, DISPLAY_RANK, tab.getDisplayRank(), ontModel); - updatePropertyIntValue(tabInd, TAB_DAYLIMIT, tab.getDayLimit(), ontModel); - updatePropertyNonNegativeIntValue(tabInd, TAB_GALLERYROWS, tab.getGalleryRows(), ontModel); - updatePropertyNonNegativeIntValue(tabInd, TAB_GALLERYCOLS, tab.getGalleryCols(), ontModel); - updatePropertyStringValue(tabInd, TAB_MORETAG, tab.getMoreTag(), ontModel); - updatePropertyNonNegativeIntValue(tabInd, TAB_IMAGEWIDTH, tab.getImageWidth(), ontModel); - updatePropertyStringValue(tabInd, TAB_ENTITYSORTFIELD, tab.getEntitySortField(), ontModel); - updatePropertyStringValue(tabInd, TAB_ENTITYSORTDIRECTION, tab.getEntitySortDirection(), ontModel); - updatePropertyStringValue(tabInd, TAB_FLAG2MODE, tab.getFlag2Mode(), ontModel); - updatePropertyStringValue(tabInd, TAB_FLAG2SET, tab.getFlag2Set(), ontModel); - Iterator types = tabInd.listRDFTypes(false); - List typesToRemove = new ArrayList(); - while (types.hasNext()) { - typesToRemove.add((Resource)types.next()); - } - Iterator typesToRemoveIt = typesToRemove.iterator(); - while (typesToRemoveIt.hasNext()) { - tabInd.removeRDFType((Resource)typesToRemoveIt.next()); - } - tabInd.addRDFType(TAB); - try { - Object o = entityLinkMethods.get(tab.getEntityLinkMethod()); - if (o instanceof List) { - for (Object type : (List) o) { - tabInd.addRDFType((Resource) type); - } - } else { - tabInd.addRDFType((Resource) o); - } - } catch (Exception e) {log.error("error setting entityLinkType for tab "+tabInd.getURI());} - try { - Resource tabTypeRes = (Resource)tabtypes.get(tab.getTabtypeId()); - if (tabTypeRes != null) { - tabInd.addRDFType(tabTypeRes); - } - } catch (Exception e) {log.error("error setting tabtype for tab "+tabInd.getURI());} - } - } - } finally { - ontModel.leaveCriticalSection(); - } - } - - private Tab tabFromTabIndividual(Individual tabInd) { - OntModel om = getOntModel(); - Tab tab = new Tab(); - tab.setTabId(Integer.decode(tabInd.getLocalName().substring(3)).intValue()); - try { - if (tabInd.getLabel(null) != null) - tab.setTitle(tabInd.getLabel(null)); - else - tab.setTitle(tabInd.getLocalName()); - } catch (Exception e) {log.error("Error in TabDaoJena.tabFromTabIndividual - setTitle");} - tab.setDescription(getPropertyStringValue(tabInd, DESCRIPTION)); - tab.setStatusId(getPropertyNonNegativeIntValue(tabInd, TAB_STATUSID)); - tab.setBody(getPropertyStringValue(tabInd, TAB_BODY)); - tab.setDisplayRank(getPropertyNonNegativeIntValue(tabInd, DISPLAY_RANK)); - tab.setDayLimit(getPropertyNonNegativeIntValue(tabInd, TAB_DAYLIMIT)); - tab.setGalleryRows(getPropertyNonNegativeIntValue(tabInd, TAB_GALLERYROWS)); - tab.setGalleryCols(getPropertyNonNegativeIntValue(tabInd, TAB_GALLERYCOLS)); - tab.setMoreTag(getPropertyStringValue(tabInd, TAB_MORETAG)); - tab.setImageWidth(getPropertyNonNegativeIntValue(tabInd, TAB_IMAGEWIDTH)); - tab.setEntitySortField(getPropertyStringValue(tabInd, TAB_ENTITYSORTFIELD)); - tab.setEntitySortDirection(getPropertyStringValue(tabInd, TAB_ENTITYSORTDIRECTION)); - tab.setFlag2Mode(getPropertyStringValue(tabInd, TAB_FLAG2MODE)); - tab.setFlag2Set(getPropertyStringValue(tabInd, TAB_FLAG2SET)); - try { - Iterator typesIt = tabInd.listRDFTypes(false); - while (typesIt.hasNext()) { - Resource type = (Resource) typesIt.next(); - if (type.getURI().equals(VitroVocabulary.TAB_PRIMARYTAB)) { - tab.setTabtypeId(Tab.PRIMARY_TAB); - } else - if (type.getURI().equals(VitroVocabulary.TAB_PRIMARYTABCONTENT)) { - tab.setTabtypeId(Tab.PRIMARY_TAB_CONTENT); - } else - if (type.getURI().equals(VitroVocabulary.TAB_SECONDARYTAB)) { - tab.setTabtypeId(Tab.SECONDARY_TAB); - } else - if (type.getURI().equals(VitroVocabulary.TAB_SUBCOLLECTION)) { - tab.setTabtypeId(Tab.SUBCOLLECTION); - } else - if (type.getURI().equals(VitroVocabulary.TAB_COLLECTION)) { - tab.setTabtypeId(Tab.COLLECTION); - } else - if (type.getURI().equals(VitroVocabulary.TAB_SUBCOLLECTIONCATEGORY)) { - tab.setTabtypeId(Tab.CATEGORY); - } - if (type.getURI().equals(VitroVocabulary.TAB_MIXEDTAB)) { - tab.setEntityLinkMethod("mixed"); - } else - if (!tab.getEntityLinkMethod().equals("mixed") && type.getURI().equals(VitroVocabulary.TAB_AUTOLINKABLETAB)) { - tab.setEntityLinkMethod("auto"); - } else - if (!tab.getEntityLinkMethod().equals("mixed") && type.getURI().equals(VitroVocabulary.TAB_MANUALLYLINKABLETAB)) { - tab.setEntityLinkMethod("manual"); - } - } - } catch (Exception e) {log.error("Error in TabDaoJena.tabFromIndividual - setTabtypeId"); } - return tab; - } - - - private int makePortalIdFromIndividual(Individual tabInd){ - int portalId = -8723; - OntModel model = getOntModel(); - model.enterCriticalSection(Lock.READ); - try{ - ClosableIterator stmts = model.listStatements( tabInd, TAB_PORTAL, (RDFNode)null); - try{ - boolean portalFound = false; - /* NOTICE: this use the portaId from the first ObjectPropertyStatement encountered */ - /* this might not be the correct thing to do if there are multiple portals associated - /* with a tab */ - while( stmts.hasNext()){ - Statement stmt = (Statement) stmts.next(); - String portalUri = stmt.getObject().asNode().getURI(); - Matcher match = portalIdFromUriPattern.matcher( portalUri); - if( match.matches() ){ - portalId = Integer.parseInt( match.group( 1 ) ); - portalFound = true; - break; - } - } - if( portalFound == false && log.isErrorEnabled() ) - log.error("tab " + tabInd.getURI() + " is not associated with any portals"); - } finally { - stmts.close(); - } - } finally { - model.leaveCriticalSection(); - } - return portalId; - } - - /** - * Gets a tab with its entity factory set up correctly. - * The returned tab will have no child tabs. - * - * @param tab_id - id of the tab - * @param auth_level - authorization level - * @param app - state of the application - * @return tab with entity factory, but no children. - */ - private Tab getTabWithEntityFact(int tab_id, int auth_level, ApplicationBean app) { - Tab tab = getTab(tab_id); - - //this is where the tab gets an object for finding associated Entities. - assignTabEntityFactory( tab, app, auth_level); - return tab; - } - - /** - * Adds an object to the Tab which defines the method to get entity object - * that are associated with the Tab. - */ - private void assignTabEntityFactory( Tab tab, - ApplicationBean appBean, - int auth_level) { - if( tab == null ) return; - - TabEntityFactory factory = null; - String linkMethod = tab.getEntityLinkMethod(); - - if( "auto".equalsIgnoreCase( linkMethod ) ){ - factory = new TabEntityFactoryAutoJena(tab, auth_level, appBean, getWebappDaoFactory()); - } else if ( "manual".equalsIgnoreCase( linkMethod ) ){ - factory = new TabEntityFactoryManualJena(tab, auth_level, appBean, getWebappDaoFactory()); - } else if( "mixed".equalsIgnoreCase( linkMethod )){ - factory = new TabEntityFactoryMixedJena(tab, auth_level, appBean, getWebappDaoFactory()); - }else{ - log.debug("TabDao.assignTabEntityFactory(): tab "+tab.getTabId()+" " + - "is UNKNOWN, LinkMethod:" + linkMethod + " tabTypeId: " + tab.getTabtypeId()); - } - - if (tab.getGalleryRows()>0 && tab.getGalleryCols()>0) { - factory = new TabEntityFactoryGalleryJena(factory, tab, auth_level, appBean, getWebappDaoFactory()); - } - - tab.placeEntityFactory(factory); - } - - /** - * recursively add all child tabs. - * @param depth -1 == no depth limit, 0== no children, 1 == direct children, - * 2 == 2 generations of children, etc. - */ - @SuppressWarnings("unchecked") - private void recursiveAddChildTabs(Tab tab, Set visitedIds, int auth_level, - ApplicationBean appBean, int depth ){ - if(tab == null || depth == 0 ) return; - - if(visitedIds == null ) - visitedIds = new HashSet(); - - if(visitedIds.contains(String.valueOf(tab.getTabId()))) - return; - - visitedIds.add( String.valueOf(tab.getTabId()) ); - - getChildTabs(tab, auth_level, appBean); - if( tab.getChildTabs() != null ){ - Iterator it = tab.getChildTabs().iterator(); - while(it.hasNext()){ - int newDepth = depth - 1; - if( depth == NO_DEPTH_LIMIT ) - newDepth = NO_DEPTH_LIMIT; - - //make a new HashSet each call so we only avoid cycles in paths, - //not duplicates in the tree. - recursiveAddChildTabs((Tab)it.next(), new HashSet(visitedIds), - auth_level, appBean, newDepth ); - } - } - } - - /** - * Gets the direct children of the tab. - * Depending on level: - * 28 primary tab, - * 26 primary tab content, - * 24 secondary tab, - * 22 collection, - * 20 subcollection, - * 18 subcollection category - * - * primary tabs can have either secondary tabs (which are displayed without entities) - * or content tabs, whose entities are displayed - * look first for heading tabs - */ - private void getChildTabs(Tab tab, int auth_level, ApplicationBean appBean){ - Property subTabOf = ResourceFactory.createProperty(VitroVocabulary.TAB_SUBTABOF); - Individual parentTabInd = getOntModel().getIndividual(DEFAULT_NAMESPACE+"tab"+tab.getTabId()); - if (parentTabInd == null) - return; - Iterator stmtIt = getOntModel().listStatements(null, subTabOf, parentTabInd); - List childIds = new ArrayList(); - while (stmtIt.hasNext()) { - Statement stmt = (Statement) stmtIt.next(); - Resource child = (Resource) stmt.getSubject(); - childIds.add(Integer.decode(child.getLocalName().substring(3))); - } - Iterator childIdIt = childIds.iterator(); - Tab childTab = null; - List childTabList = null; - while (childIdIt.hasNext()) { - if (childTabList==null) - childTabList=new ArrayList(); - - int childTabId=((Integer)childIdIt.next()); - // do not pass alpha_qualifier down to next generation - // may want to switch so can return non-null childErrorMessage with - // otherwise successful return - childTab=getTabWithEntityFact(childTabId,auth_level,appBean); - if (childTab != null) - childTabList.add(childTab); - } - if (childTabList != null) - Collections.sort(childTabList,new TabComparator()); - tab.setChildTabs(childTabList); - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/TabIndividualRelationDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/TabIndividualRelationDaoJena.java deleted file mode 100644 index 83aa6be1c..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/TabIndividualRelationDaoJena.java +++ /dev/null @@ -1,216 +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.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.hp.hpl.jena.ontology.OntClass; -import com.hp.hpl.jena.ontology.OntModel; -import com.hp.hpl.jena.rdf.model.Resource; -import com.hp.hpl.jena.rdf.model.Statement; -import com.hp.hpl.jena.shared.Lock; -import com.hp.hpl.jena.util.iterator.ClosableIterator; -import com.hp.hpl.jena.vocabulary.RDF; - -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; -import edu.cornell.mannlib.vitro.webapp.beans.TabIndividualRelation; -import edu.cornell.mannlib.vitro.webapp.dao.TabIndividualRelationDao; -import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; - -public class TabIndividualRelationDaoJena extends JenaBaseDao implements TabIndividualRelationDao { - - private static final Log log = LogFactory.getLog(TabIndividualRelationDaoJena.class.getName()); - - public TabIndividualRelationDaoJena(WebappDaoFactoryJena wadf) { - super(wadf); - } - - @Override - protected OntModel getOntModel() { - return getOntModelSelector().getApplicationMetadataModel(); - } - - public void deleteTabIndividualRelation(TabIndividualRelation tir) { - deleteTabIndividualRelation(tir,getOntModel()); - } - - public void deleteTabIndividualRelation(TabIndividualRelation t2e, OntModel ontModel) { - com.hp.hpl.jena.ontology.Individual tirInd = ontModel.getIndividual(t2e.getURI()); - if (tirInd != null) { - tirInd.remove(); - } - } - - public TabIndividualRelation getTabIndividualRelationByURI(String uri) { - com.hp.hpl.jena.ontology.Individual tirInd = getOntModel().getIndividual(uri); - if (tirInd != null) { - return tabIndividualRelationFromIndividual(tirInd); - } else { - return null; - } - } - - public List getTabIndividualRelationsByIndividualURI(String individualURI) { - List tirList = new ArrayList(); - getOntModel().enterCriticalSection(Lock.READ); - try { - com.hp.hpl.jena.ontology.Individual individual = getOntModel().getIndividual(individualURI); - if (individual != null) { - ClosableIterator stmtIt = getOntModel().listStatements(null, TAB_INDIVIDUALRELATION_INVOLVESINDIVIDUAL, individual); - try { - while (stmtIt.hasNext()) { - Statement stmt = (Statement) stmtIt.next(); - Resource tirRes = stmt.getSubject(); - if (tirRes != null) { - boolean checked = false; - ClosableIterator checkIt = tirRes.listProperties(RDF.type); - try { - while (checkIt.hasNext()) { - Statement chk = (Statement) checkIt.next(); - if (((Resource)chk.getObject()).getURI().equals(TAB_INDIVIDUALRELATION.getURI())) { - checked = true; - break; - } - } - } finally { - checkIt.close(); - } - if (checked) { - com.hp.hpl.jena.ontology.Individual tirInd = getOntModel().getIndividual(tirRes.getURI()); - tirList.add(tabIndividualRelationFromIndividual(tirInd)); - } - } - } - } finally { - stmtIt.close(); - } - } - } finally { - getOntModel().leaveCriticalSection(); - } - return tirList; - } - - public List getTabIndividualRelationsByTabURI(String tabURI) { - List tirList = new ArrayList(); - getOntModel().enterCriticalSection(Lock.READ); - try { - com.hp.hpl.jena.ontology.Individual tab = getOntModel().getIndividual(tabURI); - if (tab != null) { - ClosableIterator stmtIt = getOntModel().listStatements(null, TAB_INDIVIDUALRELATION_INVOLVESTAB, tab); - try { - while (stmtIt.hasNext()) { - Statement stmt = (Statement) stmtIt.next(); - Resource tirRes = stmt.getSubject(); - if (tirRes != null) { - boolean checked = false; - ClosableIterator checkIt = tirRes.listProperties(RDF.type); - try { - while (checkIt.hasNext()) { - Statement chk = (Statement) checkIt.next(); - if (((Resource)chk.getObject()).getURI().equals(TAB_INDIVIDUALRELATION.getURI())) { - checked = true; - break; - } - } - } finally { - checkIt.close(); - } - if (checked) { - com.hp.hpl.jena.ontology.Individual tirInd = getOntModel().getIndividual(tirRes.getURI()); - tirList.add(tabIndividualRelationFromIndividual(tirInd)); - } - } - } - } finally { - stmtIt.close(); - } - } - } finally { - getOntModel().leaveCriticalSection(); - } - return tirList; - } - - public int insertNewTabIndividualRelation(TabIndividualRelation t2e) { - insertNewTabIndividualRelation(t2e,getOntModel()); - return 0; - } - - public void insertNewTabIndividualRelation( TabIndividualRelation tir, OntModel ontModel ) { - ontModel.enterCriticalSection(Lock.WRITE); - try { - Resource individual = ontModel.getResource(tir.getEntURI()); - Resource tab = ontModel.getResource(DEFAULT_NAMESPACE+"tab"+tir.getTabId()); - String uriToUse = null; - if (tir.getURI() != null) { - uriToUse = tir.getURI(); - } else { - String dedup = DEFAULT_NAMESPACE+"tabIndividualRelation_"+tir.getTabId()+"_"+individual.getLocalName(); - //while (ontModel.getResource(dedup) != null) { - // dedup += "a"; - //} - uriToUse = dedup; - } - OntClass TabIndividualRelationOntClass = ontModel.getOntClass(VitroVocabulary.TAB_INDIVIDUALRELATION); - if (TabIndividualRelationOntClass != null) { - com.hp.hpl.jena.ontology.Individual tirInd = TabIndividualRelationOntClass.createIndividual(uriToUse); - addPropertyResourceValue(tirInd, TAB_INDIVIDUALRELATION_INVOLVESTAB, tab); - addPropertyResourceValue(tirInd, TAB_INDIVIDUALRELATION_INVOLVESINDIVIDUAL, individual); - addPropertyNonNegativeIntValue(tirInd, DISPLAY_RANK, tir.getDisplayRank(), ontModel); - } else { - log.error(VitroVocabulary.TAB_INDIVIDUALRELATION+" class not found"); - } - } finally { - ontModel.leaveCriticalSection(); - } - } - - public void insertTabIndividualRelation(Tab tab, Individual ent) { - TabIndividualRelation tir = new TabIndividualRelation(); - tir.setTabId(tab.getTabId()); - tir.setEntURI(ent.getURI()); - insertNewTabIndividualRelation(tir); - } - - public boolean tabIndividualRelationExists(Tab tab, Individual ent) { - // TODO Auto-generated method stub - return false; - } - - public void updateTabIndividualRelation(TabIndividualRelation t2e) { - updateTabIndividualRelation(t2e,getOntModel()); - } - - public void updateTabIndividualRelation(TabIndividualRelation tir, OntModel ontModel) { - ontModel.enterCriticalSection(Lock.WRITE); - try { - com.hp.hpl.jena.ontology.Individual tirInd = ontModel.getIndividual(tir.getURI()); - Resource individual = ontModel.getResource(tir.getEntURI()); - Resource tab = ontModel.getResource(DEFAULT_NAMESPACE+"tab"+tir.getTabId()); - updatePropertyResourceValue(tirInd, TAB_INDIVIDUALRELATION_INVOLVESTAB, tab); - updatePropertyResourceValue(tirInd, TAB_INDIVIDUALRELATION_INVOLVESINDIVIDUAL, individual); - updatePropertyNonNegativeIntValue(tirInd, DISPLAY_RANK, tir.getDisplayRank(), ontModel); - } finally { - ontModel.leaveCriticalSection(); - } - } - - private TabIndividualRelation tabIndividualRelationFromIndividual(com.hp.hpl.jena.ontology.Individual ind) { - TabIndividualRelation tir = new TabIndividualRelation(); - tir.setURI(ind.getURI()); - try { - tir.setEntURI(((Resource)ind.getPropertyValue(TAB_INDIVIDUALRELATION_INVOLVESINDIVIDUAL)).getURI()); - } catch (Exception e) {/* TODO log */} - try { - //tir.setTabId(((Resource)ind.getPropertyValue(TAB_INDIVIDUALRELATION_INVOLVESTAB)).getURI()); - } catch (Exception e) {/* TODO log */} - return tir; - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/TabVClassRelationDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/TabVClassRelationDaoJena.java deleted file mode 100644 index 61ea24ca4..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/TabVClassRelationDaoJena.java +++ /dev/null @@ -1,71 +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 com.hp.hpl.jena.ontology.OntModel; -import com.hp.hpl.jena.rdf.model.Property; -import com.hp.hpl.jena.rdf.model.Resource; -import com.hp.hpl.jena.shared.Lock; -import edu.cornell.mannlib.vitro.webapp.beans.TabVClassRelation; -import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; -import edu.cornell.mannlib.vitro.webapp.dao.TabVClassRelationDao; -import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; - -public class TabVClassRelationDaoJena extends JenaBaseDao implements TabVClassRelationDao { - - public TabVClassRelationDaoJena(WebappDaoFactoryJena wadf) { - super(wadf); - } - - @Override - protected OntModel getOntModel() { - return getOntModelSelector().getApplicationMetadataModel(); - } - - public void deleteTabVClassRelation( TabVClassRelation t2t ) { - deleteTabs2Types(t2t,getOntModel()); - } - - public void deleteTabs2Types( TabVClassRelation t2t, OntModel ontModel ) - { - ontModel.enterCriticalSection(Lock.WRITE); - try { - Property typeLinkedToTab = ontModel.getProperty(VitroVocabulary.TAB_AUTOLINKEDTOTAB); - Resource type = ontModel.getResource(t2t.getVClassURI()); - Resource tab = ontModel.getResource(DEFAULT_NAMESPACE+"tab"+t2t.getTabId()); - if ((typeLinkedToTab != null) && (tab != null) && (type != null)) { - ontModel.removeAll(type, typeLinkedToTab, tab); - } else { - log.error("No good - something was null"); - } - } finally { - ontModel.leaveCriticalSection(); - } - } - - public int insertTabVClassRelation( TabVClassRelation t2t ) { - insertNewTabs2Types(t2t,getOntModel()); - return 0; - } - - public void insertNewTabs2Types( TabVClassRelation t2t, OntModel ontModel ) - { - ontModel.enterCriticalSection(Lock.WRITE); - try { - Property typeLinkedToTab = ontModel.getProperty(VitroVocabulary.TAB_AUTOLINKEDTOTAB); - Resource type = ontModel.getResource(t2t.getVClassURI()); - Resource tab = ontModel.getResource(DEFAULT_NAMESPACE+"tab"+t2t.getTabId()); - if ((typeLinkedToTab != null) && (tab != null) && (type != null)) { - ontModel.add(type, typeLinkedToTab, tab); - } - } finally { - ontModel.leaveCriticalSection(); - } - } - - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassGroupDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassGroupDaoJena.java index 7cba836b7..0744904d1 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassGroupDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassGroupDaoJena.java @@ -36,7 +36,7 @@ import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch; public class VClassGroupDaoJena extends JenaBaseDao implements VClassGroupDao { - private static final Log log = LogFactory.getLog(TabDaoJena.class.getName()); + private static final Log log = LogFactory.getLog(VClassGroupDao.class.getName()); public VClassGroupDaoJena(WebappDaoFactoryJena wadf) { super(wadf); 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 6c8d61f46..5d524d6a9 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 @@ -53,9 +53,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; import edu.cornell.mannlib.vitro.webapp.dao.PageDao; import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao; -import edu.cornell.mannlib.vitro.webapp.dao.TabDao; -import edu.cornell.mannlib.vitro.webapp.dao.TabIndividualRelationDao; -import edu.cornell.mannlib.vitro.webapp.dao.TabVClassRelationDao; import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao; import edu.cornell.mannlib.vitro.webapp.dao.UserDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; @@ -74,10 +71,6 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { protected LinksDao linksDao; protected LinktypeDao linktypeDao; protected ApplicationDaoJena applicationDao; - protected TabDao tabDao; - protected TabIndividualRelationDao tabs2EntsDao; - - protected TabVClassRelationDao tabs2TypesDao; protected UserDao userDao; // TODO This goes away when the UserAccounts stuff is fully implemented -- jb protected UserAccountsDao userAccountsDao; protected VClassGroupDao vClassGroupDao; @@ -494,28 +487,6 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { } } - public TabDao getTabDao() { - if (tabDao != null) - return tabDao; - else - return tabDao = new TabDaoJena(this); - } - - public TabIndividualRelationDao getTabs2EntsDao() { - if (tabs2EntsDao != null) - return tabs2EntsDao; - else - return tabs2EntsDao = new TabIndividualRelationDaoJena(this); - } - - - public TabVClassRelationDao getTabs2TypesDao() { - if (tabs2TypesDao != null) - return tabs2TypesDao; - else - return tabs2TypesDao = new TabVClassRelationDaoJena(this); - } - public VClassGroupDao getVClassGroupDao() { if (vClassGroupDao != null) return vClassGroupDao; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/tabFactory/TabEntityFactoryAutoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/tabFactory/TabEntityFactoryAutoJena.java deleted file mode 100644 index 7d13b66ed..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/tabFactory/TabEntityFactoryAutoJena.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.tabFactory; - -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; - -import net.sf.jga.algorithms.Filter; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.hp.hpl.jena.ontology.OntClass; -import com.hp.hpl.jena.ontology.OntModel; -import com.hp.hpl.jena.rdf.model.Statement; -import com.hp.hpl.jena.shared.Lock; -import com.hp.hpl.jena.util.iterator.ClosableIterator; -import com.hp.hpl.jena.vocabulary.RDF; - -import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; -import edu.cornell.mannlib.vitro.webapp.dao.TabEntityFactory; -import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; -import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; -import edu.cornell.mannlib.vitro.webapp.dao.jena.IndividualJena; -import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena; - -public class TabEntityFactoryAutoJena extends TabEntityFactoryJena implements TabEntityFactory { - List _relatedEnts; - private static final Log log = LogFactory.getLog(TabEntityFactoryAutoJena.class.getName()); - - public TabEntityFactoryAutoJena(Tab tab, int auth_level, ApplicationBean appBean, WebappDaoFactoryJena wadf) { - super(tab, auth_level, appBean, wadf); - } - - @SuppressWarnings("unchecked") - public List getRelatedEntites(String alpha) { - if( _relatedEnts == null ) - _relatedEnts = getAllRelatedEnts(); - - if( alpha == null || "all".equals(alpha) ) - return _relatedEnts; - - List out = new LinkedList(); - Filter.filter(_relatedEnts, new FirstLetterFilter( alpha ), out); - return out; - } - - private List getAllRelatedEnts(){ - LinkedList ents = new LinkedList(); - getOntModel().enterCriticalSection(Lock.READ); - try{ - com.hp.hpl.jena.ontology.Individual tabInd = getTabIndividual(tab); - if( tabInd == null ) return Collections.EMPTY_LIST; - - if( TAB_AUTOLINKEDTOTAB == null ){ - log.error("could not find annotation property " + VitroVocabulary.TAB_AUTOLINKEDTOTAB); - return Collections.EMPTY_LIST; - } - - //get the classes that are linked to this tab - ClosableIterator classIt = getOntModel().listStatements(null, TAB_AUTOLINKEDTOTAB, tabInd); - - try{ - while(classIt.hasNext()){ - Statement linkedToTab = (Statement)classIt.next(); - OntClass linkedClass = getOntModel().getOntClass( linkedToTab.getSubject().getURI() ); - - ClosableIterator entIt = getOntModel().listStatements(null, RDF.type, linkedClass); - try{ - while(entIt.hasNext()){ - Statement entIsOfClass = (Statement)entIt.next(); - if( entIsOfClass.getSubject().canAs(com.hp.hpl.jena.ontology.Individual.class) ) { - com.hp.hpl.jena.ontology.Individual ind = (com.hp.hpl.jena.ontology.Individual) entIsOfClass.getSubject().as(com.hp.hpl.jena.ontology.Individual.class); - Individual ent = new IndividualJena(ind, (WebappDaoFactoryJena)webappDaoFactory); - ents.add(ent); - } - } - }finally{ - entIt.close(); - } - } - }finally{ - classIt.close(); - } - }finally{ - getOntModel().leaveCriticalSection(); - } - - removeDuplicates( ents ); - return ents; - } -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/tabFactory/TabEntityFactoryGalleryJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/tabFactory/TabEntityFactoryGalleryJena.java deleted file mode 100644 index 8e7f4e7ba..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/tabFactory/TabEntityFactoryGalleryJena.java +++ /dev/null @@ -1,104 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.dao.jena.tabFactory; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Random; - -import net.sf.jga.algorithms.Filter; -import net.sf.jga.fn.UnaryFunctor; - -import org.joda.time.DateTime; - -import com.hp.hpl.jena.ontology.OntModel; - -import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; -import edu.cornell.mannlib.vitro.webapp.dao.TabEntityFactory; -import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; -import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena; - -/** - * A TabEntityFactoryGallery does the same thing as any - * TabEntityFactory it just needs to return entities that have - * non-null thumbnails. They also need to return a random selection - * of entities when doing a non-alpha filtered request. - * - * @author bdc34 - * - */ -public class TabEntityFactoryGalleryJena extends TabEntityFactoryJena - implements TabEntityFactory { - - private TabEntityFactory _innerFactory = null; - public final UnaryFunctoronlyWithMainImage = new OnlyWithMainImage(); - - public TabEntityFactoryGalleryJena(TabEntityFactory innerEntFactory, Tab tab, int auth_level, ApplicationBean appBean, WebappDaoFactoryJena wadf) { - super(tab, auth_level, appBean, wadf); - this._innerFactory = innerEntFactory; - } - - public List getRelatedEntites(String alpha){ - if( alpha != null ) - return doAlphaFilteredGallery(alpha); - else - return doGallery(); - } - - @Override - public int getRelatedEntityCount() { - return _innerFactory.getRelatedEntityCount(); - } - - @Override - public List getLettersOfEnts() { - return _innerFactory.getLettersOfEnts(); - } - - private List doAlphaFilteredGallery(String alpha){ - List ents = _innerFactory.getRelatedEntites(alpha); - if( ents == null ) - return Collections.EMPTY_LIST; - return ents; - } - - /** - * Return a random selection of ents with non-null thumbnail images - * of the size specified by the tab. - * @return - */ - private List doGallery(){ - int numberOfrequestedEnts = tab.getGalleryCols() * tab.getGalleryRows() ; - List ents = _innerFactory.getRelatedEntites(null); - if( ents == null ) - return Collections.EMPTY_LIST; - - List filteredEnts = new LinkedList( ); - Filter.filter(ents,onlyWithMainImage,filteredEnts); - - if( filteredEnts.size() <= numberOfrequestedEnts) - return filteredEnts; - - Random r = new Random( (new DateTime()).getMillis() ); - List entsOut = new ArrayList( numberOfrequestedEnts ); - while( entsOut.size() < numberOfrequestedEnts && filteredEnts.size() > 0){ - int randIndex =Math.abs(r.nextInt()) % filteredEnts.size() ; - entsOut.add( filteredEnts.get(randIndex) ); - filteredEnts.remove(randIndex); - } - return entsOut; - } - - private class OnlyWithMainImage extends UnaryFunctor{ - @Override - public Boolean fn(Individual arg) { - return arg.getMainImageUri()!= null; - } - } -} - diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/tabFactory/TabEntityFactoryJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/tabFactory/TabEntityFactoryJena.java deleted file mode 100644 index 23911cb65..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/tabFactory/TabEntityFactoryJena.java +++ /dev/null @@ -1,156 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.dao.jena.tabFactory; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.ListIterator; - -import net.sf.jga.algorithms.Sort; -import net.sf.jga.algorithms.Transform; -import net.sf.jga.algorithms.Unique; -import net.sf.jga.fn.UnaryFunctor; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; -import edu.cornell.mannlib.vitro.webapp.dao.TabEntityFactory; -import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; -import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaBaseDao; -import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena; - -public abstract class TabEntityFactoryJena extends JenaBaseDao implements - TabEntityFactory { - - Tab tab = null; - ApplicationBean appBean; - WebappDaoFactory webappDaoFactory; - String current_str = ""; - int auth_level = 0; - - transient final UnaryFunctor firstLetterOfName = new FirstLetterOfEnt(); - private static final Log log = LogFactory.getLog(TabEntityFactoryJena.class.getName()); - - /** - * @param tab - * @param auth_level - - * int: if <0, don't check entity statusId; otherwise filter to - * entities whose statusId<=auth_level - * @param appBean - * is where we check to see if flag2 and flag3 are active. - */ -public TabEntityFactoryJena(Tab tab, int auth_level, - ApplicationBean appBean, WebappDaoFactoryJena wadf) { - super(wadf); - this.tab = tab; - - this.auth_level = auth_level; - - this.appBean = appBean; - - this.webappDaoFactory = wadf; - } - - public List getLettersOfEnts() { - return getLettersOfEnts( getRelatedEntites(null)); - } - - public abstract List getRelatedEntites(String alpha); - - public int getRelatedEntityCount() { - List ents = getRelatedEntites(null); - if( ents != null ) - return ents.size(); - else - return 0; - } - - protected String getTabUri(Tab tab){ - return DEFAULT_NAMESPACE+"tab"+tab.getTabId(); - } - - - protected com.hp.hpl.jena.ontology.Individual getTabIndividual(Tab tab){ - String taburi = getTabUri(tab); - com.hp.hpl.jena.ontology.Individual tabInd = getOntModel().getIndividual(taburi); - if( tabInd == null ){ - log.error("could not find tab: " + taburi); - return null; - } - return tabInd; - } - - @SuppressWarnings("unchecked") - public List getLettersOfEnts(List ents) { - Comparator comp = new Comparator(){ - public int compare(String o1, String o2) { - return o1.compareTo(o2); - }; - }; - - Iterablei = - Unique.unique( - Sort.sort( - Transform.transform( ents ,firstLetterOfName ), - comp - ) - ); - - ArrayList out = new ArrayList(26); - for( String str : i){ - out.add(str); - } - return out; - } - - @SuppressWarnings("serial") - class FirstLetterFilter extends UnaryFunctor{ - String firstLetter; - public FirstLetterFilter(String alpha){ - firstLetter = alpha; - } - @Override - public Boolean fn(Individual arg){ - if( arg.getName() == null ) - return Boolean.FALSE; - else - return new Boolean( firstLetter.equalsIgnoreCase( arg.getName().substring(0,1) ) ); - } - } - - @SuppressWarnings("serial") - private class FirstLetterOfEnt extends UnaryFunctor{ - @Override - public String fn(Individual arg) { - return arg.getName().substring(0,1).toUpperCase(); - } - } - - protected void removeDuplicates(List ents ){ - Collections.sort(ents, indComp); - ListIterator li = ents.listIterator(); - Individual prev = null; - while(li.hasNext() ){ - Individual current = li.next(); - if( prev != null && prev.getURI().equals(current.getURI()) ) - li.remove(); - else - prev = current; - } - } - - protected static Comparator indComp = - new Comparator(){ - public int compare (Individual a, Individual b){ - if( a == null && b == null ) return 0; - if( a == null ) return -1; - if( b == null ) return 1; - return a.getURI().compareTo(b.getURI()); - } - }; -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/tabFactory/TabEntityFactoryManualJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/tabFactory/TabEntityFactoryManualJena.java deleted file mode 100644 index 661699197..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/tabFactory/TabEntityFactoryManualJena.java +++ /dev/null @@ -1,92 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.dao.jena.tabFactory; - -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -import net.sf.jga.algorithms.Filter; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.hp.hpl.jena.rdf.model.Resource; -import com.hp.hpl.jena.rdf.model.Statement; -import com.hp.hpl.jena.shared.Lock; -import com.hp.hpl.jena.util.iterator.ClosableIterator; - -import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; -import edu.cornell.mannlib.vitro.webapp.dao.TabEntityFactory; -import edu.cornell.mannlib.vitro.webapp.dao.jena.IndividualJena; -import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena; - -public class TabEntityFactoryManualJena extends TabEntityFactoryJena implements TabEntityFactory { - List _allents = null; - - private static final Log log = LogFactory.getLog(TabEntityFactoryManualJena.class.getName()); - - public TabEntityFactoryManualJena(Tab tab, int auth_level, ApplicationBean appBean, WebappDaoFactoryJena wadf) { - super(tab, auth_level, appBean, wadf); - } - - public List getRelatedEntites(String alpha) { - com.hp.hpl.jena.ontology.Individual tabInd = getTabIndividual(tab); - if( tabInd == null ) return Collections.EMPTY_LIST; - - if( _allents == null ) - _allents = getAllRelatedEnts(); - - if( alpha == null || "all".equals(alpha) ) - return _allents; - - List out = new LinkedList(); - Filter.filter(_allents, new FirstLetterFilter( alpha ), out); - return out; - } - - private List getAllRelatedEnts(){ - getOntModel().enterCriticalSection(Lock.READ); - try { - com.hp.hpl.jena.ontology.Individual tabInd = getTabIndividual(tab); - if( tabInd == null ) return Collections.emptyList(); - - List ents = new LinkedList(); - if( TAB_INDIVIDUALRELATION == null ) - log.debug(" TAB_INDIVIDUALRELATION is " + TAB_INDIVIDUALRELATION ); - if( TAB_INDIVIDUALRELATION_INVOLVESTAB == null ) - log.debug(" TAB_INDIVIDUALRELATION_INVOLVESTAB is " + TAB_INDIVIDUALRELATION_INVOLVESTAB ); - if( TAB_INDIVIDUALRELATION_INVOLVESINDIVIDUAL == null ) - log.debug(" TAB_INDIVIDUALRELATION_INVOLVESINDIVIDUAL is " + TAB_INDIVIDUALRELATION_INVOLVESINDIVIDUAL ); - - ClosableIterator stmtIt = getOntModel().listStatements(null , TAB_INDIVIDUALRELATION_INVOLVESTAB, tabInd); - try{ - while(stmtIt.hasNext() ){ - Statement relationStmt = (Statement)stmtIt.next(); - Resource relation = relationStmt.getSubject(); - ClosableIterator manualLinkStmtIt = getOntModel().listStatements(relation, TAB_INDIVIDUALRELATION_INVOLVESINDIVIDUAL, (Resource)null); - try{ - while(manualLinkStmtIt.hasNext()){ - Statement stmt = (Statement)manualLinkStmtIt.next(); - if( stmt.getObject().canAs(com.hp.hpl.jena.ontology.Individual.class) ) { - com.hp.hpl.jena.ontology.Individual ind = (com.hp.hpl.jena.ontology.Individual) stmt.getObject().as(com.hp.hpl.jena.ontology.Individual.class); - Individual relatedInd = new IndividualJena(ind, (WebappDaoFactoryJena)webappDaoFactory); - ents.add(relatedInd); - } - } - }finally{ - manualLinkStmtIt.close(); - } - } - }finally{ - stmtIt.close(); - } - removeDuplicates(ents); - return ents; - } finally { - getOntModel().leaveCriticalSection(); - } - } -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/tabFactory/TabEntityFactoryMixedJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/tabFactory/TabEntityFactoryMixedJena.java deleted file mode 100644 index 04f20b17d..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/tabFactory/TabEntityFactoryMixedJena.java +++ /dev/null @@ -1,52 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.dao.jena.tabFactory; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; - -import com.hp.hpl.jena.ontology.OntModel; - -import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; -import edu.cornell.mannlib.vitro.webapp.dao.TabEntityFactory; -import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; -import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena; - -public class TabEntityFactoryMixedJena extends TabEntityFactoryJena implements - TabEntityFactory { - TabEntityFactory autoPart; - TabEntityFactory manualPart; - - public TabEntityFactoryMixedJena(Tab tab, int auth_level, ApplicationBean appBean, WebappDaoFactoryJena wadf) { - super(tab, auth_level, appBean, wadf); - autoPart = new TabEntityFactoryAutoJena(tab, auth_level, appBean, wadf); - manualPart = new TabEntityFactoryManualJena(tab, auth_level, appBean, wadf); - } - - @SuppressWarnings("unchecked") - public List getRelatedEntites(String alpha) { - List relEntsList = manualPart.getRelatedEntites(alpha); - relEntsList.addAll(autoPart.getRelatedEntites(alpha)); - - Collections.sort(relEntsList, comp); - removeDuplicates(relEntsList); - - return relEntsList; - } - - private static Comparator comp = new Comparator() { - public int compare(Object obj1, Object obj2){ - Individual first = (Individual) obj1; - Individual second = (Individual) obj2; - return (first.getName().compareTo(second.getName())); - } - }; - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/ontology/update/ABoxUpdater.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/ontology/update/ABoxUpdater.java index b38c52a16..b98ed418e 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/ontology/update/ABoxUpdater.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/ontology/update/ABoxUpdater.java @@ -145,8 +145,6 @@ public class ABoxUpdater { // the autolinking annotation should be rewritten using the // new class name. - Property autoLinkedToTab = ResourceFactory.createProperty(VitroVocabulary.TAB_AUTOLINKEDTOTAB); - StmtIterator iter = aboxModel.listStatements(oldClass, (Property) null, (RDFNode) null); int renameCount = 0; @@ -160,12 +158,6 @@ public class ABoxUpdater { // This happens in cases where a class hasn't really // been removed, but we just want to map any ABox // data using it to use a different class instead. - } - if (autoLinkedToTab.equals(oldStatement.getPredicate())) { - renameCount++; - Statement newStatement = ResourceFactory.createStatement(newClass, oldStatement.getPredicate(), oldStatement.getObject()); - additions.add(newStatement); - retractions.add(oldStatement); } else { removeCount++; retractions.add(oldStatement); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/ontology/update/TBoxUpdater.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/ontology/update/TBoxUpdater.java index 91b93a6ee..0034320db 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/ontology/update/TBoxUpdater.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/ontology/update/TBoxUpdater.java @@ -125,12 +125,6 @@ public class TBoxUpdater { // namespace continue; } - - if (VitroVocabulary.TAB_AUTOLINKEDTOTAB.equals(predicate.getURI())) { - continue; - // the tab autolinks are not like the other annotations - // and should never be updated automatically - } NodeIterator newObjects = newTboxAnnotationsModel.listObjectsOfProperty(subject, predicate); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetup.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetup.java index ca82a37c9..be173020d 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetup.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetup.java @@ -197,7 +197,7 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java log.debug("Loading initial site configuration"); essentialInterfaceData = InitialJenaModelUtils.loadInitialModel(sce.getServletContext(), defaultNamespace); if (essentialInterfaceData.size() == 0) { - essentialInterfaceData = InitialJenaModelUtils.basicPortalAndRootTab(defaultNamespace); + essentialInterfaceData = InitialJenaModelUtils.basicInterfaceData(defaultNamespace); essentialInterfaceData.add(InitialJenaModelUtils.basicClassgroup(wadf.getDefaultNamespace())); } //JenaModelUtils.makeClassGroupsFromRootClasses(wadf,memModel,essentialInterfaceData); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetupSDB.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetupSDB.java index 6c9d9a262..338c57e93 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetupSDB.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetupSDB.java @@ -299,11 +299,11 @@ public class JenaDataSourceSetupSDB extends JenaDataSourceSetupBase implements j ensureEssentialInterfaceData(unionOms.getApplicationMetadataModel(), sce, wadf); - log.info("Setting up namespace mapper"); + //log.info("Setting up namespace mapper"); - NamespaceMapper namespaceMapper = new NamespaceMapperJena(masterUnion, masterUnion, defaultNamespace); - ctx.setAttribute("NamespaceMapper", namespaceMapper); - unionOms.getFullModel().getBaseModel().register(namespaceMapper); + //NamespaceMapper namespaceMapper = new NamespaceMapperJena(masterUnion, masterUnion, defaultNamespace); + //ctx.setAttribute("NamespaceMapper", namespaceMapper); + //unionOms.getFullModel().getBaseModel().register(namespaceMapper); ctx.setAttribute("defaultNamespace", defaultNamespace); @@ -389,10 +389,11 @@ public class JenaDataSourceSetupSDB extends JenaDataSourceSetupBase implements j memModel.getResource(VitroVocabulary.PORTAL)); try { if (!portalIt.hasNext()) { - log.debug("Loading initial site configuration"); + log.info("Loading initial site configuration"); essentialInterfaceData = InitialJenaModelUtils.loadInitialModel(sce.getServletContext(), defaultNamespace); if (essentialInterfaceData.size() == 0) { - essentialInterfaceData = InitialJenaModelUtils.basicPortalAndRootTab(defaultNamespace); + log.info("Using basic initial site configuration."); + essentialInterfaceData = InitialJenaModelUtils.basicInterfaceData(defaultNamespace); essentialInterfaceData.add(InitialJenaModelUtils.basicClassgroup(wadf.getDefaultNamespace())); } //JenaModelUtils.makeClassGroupsFromRootClasses(wadf,memModel,essentialInterfaceData); @@ -507,7 +508,6 @@ public class JenaDataSourceSetupSDB extends JenaDataSourceSetupBase implements j String amdQuery = "DESCRIBE ?x WHERE { " + "{?x a <" + VitroVocabulary.PORTAL +"> } UNION " + - "{?x a <" + VitroVocabulary.TAB +"> } UNION " + "{?x a <" + VitroVocabulary.PROPERTYGROUP +"> } UNION " + "{?x a <" + VitroVocabulary.CLASSGROUP +"> } } "; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/jena/InitialJenaModelUtils.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/jena/InitialJenaModelUtils.java index 2e462ec7a..d8e207dd4 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/jena/InitialJenaModelUtils.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/jena/InitialJenaModelUtils.java @@ -68,47 +68,21 @@ public class InitialJenaModelUtils { ResourceUtils.renameResource(portalResource, defaultNamespace + "portal1"); } - //rename tabs - List tabIds = new ArrayList(); - Iterator tabResIt = initialModel.listSubjectsWithProperty(RDF.type, initialModel.getResource(VitroVocabulary.TAB)); - while (tabResIt.hasNext()) { - Resource tabRes = tabResIt.next(); - if (tabRes.isAnon()) { - tabIds.add(tabRes.getId()); - } - } - int tabIdInt = 0; - for (AnonId tabId : tabIds) { - tabIdInt++; - ResourceUtils.renameResource(initialModel.createResource(tabId), defaultNamespace + "tab" + tabIdInt); - } - return initialModel; } - public static Model basicPortalAndRootTab(String defaultNamespace) { + public static Model basicInterfaceData(String defaultNamespace) { OntModel essentialInterfaceData = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); Resource portalClass = essentialInterfaceData.getResource(VitroVocabulary.PORTAL); Property themeDirProperty = essentialInterfaceData.getProperty(VitroVocabulary.PORTAL_THEMEDIR); - Resource tabClass = essentialInterfaceData.getResource(VitroVocabulary.TAB); - Resource primaryTabClass = essentialInterfaceData.getResource(VitroVocabulary.TAB_PRIMARYTAB); - Property rootTabProperty = essentialInterfaceData.getProperty(VitroVocabulary.PORTAL_ROOTTAB); - Property tabInPortalProperty = essentialInterfaceData.getProperty(VitroVocabulary.TAB_PORTAL); - Individual portal1 = essentialInterfaceData.createIndividual(defaultNamespace+"portal1",portalClass); String defaultThemeStr = ApplicationBean.DEFAULT_THEME_DIR_FROM_CONTEXT; if (defaultThemeStr == null) { throw new RuntimeException("No default theme has been set; unable to create default portal."); } portal1.setPropertyValue(themeDirProperty,ResourceFactory.createPlainLiteral(defaultThemeStr)); - portal1.setLabel("New Vitro Portal", null); - Individual rootTab = essentialInterfaceData.createIndividual(defaultNamespace+"tab1",tabClass); - rootTab.setLabel("Home", null); - rootTab.addProperty(RDF.type, primaryTabClass); - rootTab.addProperty(tabInPortalProperty, portal1); - portal1.addProperty(rootTabProperty, rootTab); - + portal1.setLabel("New Vitro Portal", null); return essentialInterfaceData; } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/BreadCrumbsUtil.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/BreadCrumbsUtil.java deleted file mode 100755 index 65f2f4842..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/BreadCrumbsUtil.java +++ /dev/null @@ -1,112 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.web; - -import java.util.List; - -import javax.servlet.http.HttpServletRequest; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; -import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; - -/** - * Intended to generate the bread crumb html element. - * @author bdc34 - * - */ -public class BreadCrumbsUtil { - private static final Log log = LogFactory.getLog(BreadCrumbsUtil.class.getName()); - - /** separator used between bread crumbs */ - public static String separator = " > "; - - /** - * Populates a breadcrumb string for the current set of tabs, working - * backward up the chain to the root. - * In general this method finds the tab id that the request is on and then - * gets the tab hierarchy from TabDao. For each tab in the hierarchy - * a bread crumb is added. - * There are two deviations from this simple procedure: - * 1) if there is a "RootBreadCrumb" defined in the portal bean of the - * request then that will be the first crumb. - * 2) if the id of the first tab in the hierarchy equals the portal.rootTabId() - * then that crumb will have the label of portalBean.getAppName() - */ - public static String getBreadCrumbsDiv(HttpServletRequest request) { - VitroRequest vreq = new VitroRequest(request); - String ret = " - \ No newline at end of file + diff --git a/webapp/web/templates/tabs/tabAdmin.jsp b/webapp/web/templates/tabs/tabAdmin.jsp deleted file mode 100644 index 465792f1e..000000000 --- a/webapp/web/templates/tabs/tabAdmin.jsp +++ /dev/null @@ -1,44 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Tab" %> -<%@page import="edu.cornell.mannlib.vedit.beans.LoginStatusBean"%> - -<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> -<%@ page errorPage="/error.jsp"%> -<% /*********************************************** - Displays the little group of things at the bottom of the page - for administrators and editors. - - request.attributes: - an Tab object with the name "leadingTab" - - - request.parameters: - None, should only work with requestScope attributes for security reasons. - - Consider sticking < % = MiscWebUtils.getReqInfo(request) % > in the html output - for debugging info. - - bdc34 2006-01-22 created - **********************************************/ - - Tab leadingTab = (Tab) request.getAttribute("leadingTab"); - if (leadingTab == null) { - String e = "tabAdmin.jsp expects that request attribute 'leadingTab' be set to a TabBean object"; - throw new JspException(e); - } -%> - -<% if ( LoginStatusBean.getBean(request).isLoggedInAtLeast(LoginStatusBean.EDITOR)) { %> - <%/* just moving this into page scope for easy use */ %> -
- - - - - - - - edit tab: ${tab.title} -
-<% } %> diff --git a/webapp/web/templates/tabs/tabAtom.jsp b/webapp/web/templates/tabs/tabAtom.jsp deleted file mode 100644 index 1f29de009..000000000 --- a/webapp/web/templates/tabs/tabAtom.jsp +++ /dev/null @@ -1,134 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%@ page errorPage="/error.jsp"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.web.TabWebUtil" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Tab" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %> -<%@ page import="java.util.Collection" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Link" %> -<%@ page import="java.net.URLEncoder" %> -<%@ page import="org.joda.time.format.DateTimeFormatter" %> -<%@ page import="org.joda.time.format.ISODateTimeFormat" %> -<%@ page import="org.joda.time.DateTime" %> -<% -/****************************** -Takes tab and populates Atom feed with: - requested tab and its description - entities associated with this tab - immediate children of this tab and their descriptions -******************************/ -response.setContentType("application/atom+xml"); -Tab leadingTab = (Tab) request.getAttribute("leadingTab"); -if (leadingTab == null) { - String e = "tabprimary expects that request attribute 'leadingTab' be set to a TabBean object"; - throw new JspException(e); -} -Collection individuals = leadingTab.getRelatedEntities(); -Collection tabs = leadingTab.getChildTabs(); - -int portalId = 1; - -DateTime dt = new DateTime(); -DateTimeFormatter dtf = ISODateTimeFormat.basicDateTimeNoMillis(); -String time = dtf.print(dt.getMillis()); -time = time.substring(0,4)+"-"+time.substring(4,6)+"-"+time.substring(6,11)+":"+time.substring(11,13)+":"+time.substring(13,15)+"Z"; -%> -<%! -public String forURL(String frag) -{ - String result = null; - try - { - result = URLEncoder.encode(frag, "UTF-8"); - } catch (Exception ex) { - throw new RuntimeException("UTF-8 not supported", ex); - } - return result; -} - -public String escapeEntity(String frag) -{ - if(frag.contains("&")) frag = replaceAll(frag, "&", "&"); - if(frag.contains("'")) frag = replaceAll(frag, "'", "'"); - if(frag.contains("\"")) frag = replaceAll(frag, "\"", """); - if(frag.contains(">")) frag = replaceAll(frag, ">", ">"); - if(frag.contains("<")) frag = replaceAll(frag, "<", "<"); - return frag; -} - -public String replaceAll(String original, String match, String replace) -{ - int index1 = original.indexOf(match); - int index2 = original.indexOf(replace); - if(index1 == index2 && index1 != -1) - { - original = original.substring(0, index1+replace.length()+1)+replaceAll(original.substring(index1+replace.length()+1), match, replace); - return original; - } - if(index1 == -1) return original; - String before = original.substring(0, index1) + replace; - return before + replaceAll(original.substring(index1+1), match, replace); -} -%> - - -"> - <%= escapeEntity(leadingTab.getTitle()) %> - <%= leadingTab.getDescription() %> - " rel="self" type="application/atom+xml" /> - - <%= "http://"+request.getServerName()+":"+request.getLocalPort()+request.getContextPath()+escapeEntity("/index.jsp?home="+portalId+"&"+leadingTab.getTabDepthName()+"="+leadingTab.getTabId()) %> - <%= time %> - - Vivo - vivo@cornell.edu - - <% for(Individual i:individuals) { %> - - <%= escapeEntity(i.getName()) %> - <% if (i.getLinksList() == null) { %> - <% for(Link l: i.getLinksList()) { %> - - <% } %> - <% } else { %> - - <% } %> - <%= i.getURI() %> - <%= time %> - <% if (i.getBlurb() != null) { %> - <% if (i.getBlurb().matches(".*<.*>.*")) { %> -
<%= i.getBlurb() %>
- <% } %> - <% else { %> - <%= i.getBlurb() %> - <% } %> - <% } %> - <% if (i.getDescription() != null) { %> -
<%= i.getDescription() %>
- <% } %> -
- <% } %> - <% if (tabs != null) { %> - <% for(Tab t:tabs) { %> - - <%= escapeEntity(t.getTitle()) %> - - <%= "http://"+request.getServerName()+":"+request.getLocalPort()+request.getContextPath()+escapeEntity("/index.jsp?home="+portalId+"&"+t.getTabDepthName()+"="+t.getTabId()) %> - <%= time %> - <% if (t.getDescription() != null) { %> - <% if (t.getDescription().matches(".*<.*>.*")) { %> -
<%= t.getDescription() %>
- <% } %> - <% else { %> - <%= t.getDescription() %> - <% } %> - <% } %> - <% if (t.getBody() != null) { %> -
<%= t.getBody() %>
- <% } %> -
- <% } %> - <% } %> -
diff --git a/webapp/web/templates/tabs/tabBasic.jsp b/webapp/web/templates/tabs/tabBasic.jsp deleted file mode 100755 index 176b663ec..000000000 --- a/webapp/web/templates/tabs/tabBasic.jsp +++ /dev/null @@ -1,138 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%@ page import="org.apache.commons.logging.Log" %> -<%@ page import="org.apache.commons.logging.LogFactory" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.web.TabWebUtil" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Tab" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %> -<%@ page errorPage="/error.jsp"%> -<% /*********************************************** - Display a single tab or subtab in the most basic fashion. - - Note: most of the depth based control is in tabSub.jsp - tabSubAsList.jsp and tabEntities.jsp. The only depth based - control of what gets displayed that is in this code is - the tab.body, which is only displayed on depth 1. - - request.attributes: - a Tab object with the name "tab3223" where 3223 is - the id of the tab to display. This can be added to the attribute - list using TabWebUtil.stashTabsInRequest which gets called - in tabprimary.jsp. - - request.parameters: - "tabDepth" String that is the depth of the tab in the display - leadingTab = 1, child of leadingTab = 2, etc. - if tabDepth is not set it defaults to 1 - "tabId" id of the tab to display, defaults to leadingTab. - - "noDesc" if true then don't display the tab.description, default is false. - "noEntities" if true then don't display the associated entities for this tab. - "noContent" if true then don't display the primary content tabs. - "noSubtabs" if true then don't display the subtabs associated with this tab. - "subtabsAsList" if true then display just children (not grand children,etc) subtabs as a list. - - Consider sticking < % = MiscWebUtils.getReqInfo(request) % > in the html - output for debugging info. - - bdc34 2006-01-03 created - **********************************************/ - String INACTIVE = ""; - String DEFAULT_LABEL = null; - - /*************************************************** - nac26 2008-05-08 following brian's lead from menu.jsp to get the portalId so it can be added to the tab links */ - final Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.web.tabBasic.jsp"); - - int portalId = 1; - - /**************************************************/ - - String tabId = request.getParameter("tabId"); - if (tabId == null) { - String e = "tabBasic expects that request parameter 'tabId' be set"; - throw new JspException(e); - } - - Tab tab = TabWebUtil.findStashedTab(tabId, request); - if (tab == null) { - String e = "tabBasic expects that request attribute 'leadingTab' will have the tab with tabId as a sub tab"; - throw new JspException(e); - } - - String obj = request.getParameter("tabDepth"); - int depth = 1; //depth 1 represents primary tab level, 2 is secondary, etc. - if (obj == null) { - String e = "tabBasic expects that request parameter 'tabDepth' be set"; - throw new JspException(e); - } - depth = Integer.parseInt((String) obj); - - boolean entities = true; - if ("true".equalsIgnoreCase(request.getParameter("noEntities"))) - entities = false; - boolean content = true; - if ("true".equalsIgnoreCase(request.getParameter("noContent"))) - content = false; - boolean subtabs = true; - if ("true".equalsIgnoreCase(request.getParameter("noSubtabs"))) - subtabs = false; - boolean subtabsAsList = false; - if ("true".equalsIgnoreCase(request.getParameter("subtabsAsList"))) { - subtabsAsList = true; - subtabs = false; - } - - boolean noDesc = false; - if ("true".equalsIgnoreCase(request.getParameter("noDesc"))) { - noDesc = true; - } - - String tabEntsController = Controllers.TAB_ENTITIES; - - String titleLink = TabWebUtil.tab2TabAnchorElement(tab, request, depth, INACTIVE, DEFAULT_LABEL, portalId); - if (depth == 1)//don't make a link for root dispaly tab - titleLink = tab.getTitle(); - - Integer headingDepth = depth + 1; - String headingOpen = ""; - String headingClose = ""; - - String tabDesc = ""; - if (!noDesc && tab.getDescription() != null && !tab.getDescription().equals(" ")) - tabDesc = "
" + tab.getDescription() + "
"; - String tabBody = ""; - - /* tab.body is only displayed for the depth 1 display tab */ - if (depth <= 2 && tab.getBody() != null && !tab.getBody().equals(" ")) - tabBody = "
" + tab.getBody() + "
"; -%> -
-<%=headingOpen%><%=titleLink%><%=headingClose%> -<%=tabDesc%> -<%=tabBody%> -<% if( entities ){ %> - - - - -<% } %> -<% if( subtabs ) { %> - - - - -<% }%> -<% if( subtabsAsList ) { %> - - - - -<% }%> -<% if(content) { %> - - - - -<% } %> -
\ No newline at end of file diff --git a/webapp/web/templates/tabs/tabContent.jsp b/webapp/web/templates/tabs/tabContent.jsp deleted file mode 100755 index a60b78c9c..000000000 --- a/webapp/web/templates/tabs/tabContent.jsp +++ /dev/null @@ -1,95 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Tab" %> -<%@ page import="java.util.Collection,java.util.Iterator" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.web.TabWebUtil" %> -<%@ page errorPage="/error.jsp"%> -<% - int CutOffDepth = 3; - /*********************************************** - Tab Content is to display the sub tabs of type primaryTabContent - - Primary Content Tabs will have: - tab heading, - tab description - request.attributes - "leadingTab" the tab that is at the top of the display hierarchy - - "tabDepth" String that is the depth of the tab in the display - leadingTab = 1, child of leadingTab = 2, etc. - Here tabDepth does not default, it must be set - - bdc34 2006-01-12 created - **********************************************/ - - Tab leadingTab =(Tab) request.getAttribute("leadingTab"); - if(leadingTab== null ) { - String e="tabContent expects that request attribute 'leadingTab' be set"; - throw new JspException(e); - } - - String tabId = request.getParameter("tabId"); - if( tabId == null ){ - String e="tabContent expects that request parameter 'tabId' be set"; - throw new JspException(e); - } - - Tab tab = null; - tab = TabWebUtil.findStashedTab(tabId,request); - if( tab == null ){ - String e="tabContent expects that request attribute 'leadingTab' will have the tab with tabId as a sub tab"; - throw new JspException(e); - } - - String obj= request.getParameter("tabDepth"); - int depth = 1; //depth 1 represents primary tab level, 2 is secondary, etc. - if( obj == null ){ - String e="tabContent expects that request parameter 'tabDepth' be set"; - throw new JspException(e); - } - depth = Integer.parseInt((String)obj); - int childDepth = depth + 1; - - Collection children = tab.filterChildrenForContentTabs(); - if( depth < CutOffDepth && children!= null ){ - Iterator childIter=children.iterator(); - boolean hasChildren = childIter.hasNext(); - int columnSize = children.size(); - if( hasChildren ){ %> - -
- - <% } - while( childIter.hasNext() ) { - Tab contentTab = (Tab)childIter.next(); - TabWebUtil.stashTabsInRequest(contentTab, request); %> - - <% if (columnSize==2) {%> - - <% } - if( hasChildren ){ %> -
- <% } %> - - <% else if (columnSize==3) {%> - - <% } %> - - <% else if (columnSize==4) {%> - - <% } %> - - <% else {%> - - <% } %> - - - - - - - -
-
- <%}%> -<% } %> diff --git a/webapp/web/templates/tabs/tabSub.jsp b/webapp/web/templates/tabs/tabSub.jsp deleted file mode 100755 index 6b3bea6c3..000000000 --- a/webapp/web/templates/tabs/tabSub.jsp +++ /dev/null @@ -1,128 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%@ page import="java.util.Collection" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Tab" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.web.TabWebUtil" %> -<%@ page import="java.util.Iterator" %> -<%@ page errorPage="/error.jsp"%> -<% - int CutOffDepth = 3; //tab depth at which subtabs stop being shown - int HorzSubTabCutOff = 8; //subtab count at which we switch to tabSubAsList.jsp - int EntsInDepth2TabsCutOff = 4; //subtab count at which entities stop being shown in depth 2 tabs. - int TabDescCutoffDepth = 3;//depth at which descriptions of subtabs stop being shown - - /*********************************************** - Display a set of subtabs for a tab - - request.attributes - "leadingTab" the tab that is at the top of the display hierarchy - - request.parameters - "tabId" id of the tab to do subtabs for - - "noEntities" can be set to 'true' or 'false' and will control if - subtabs have entities. defaults to false/having entites; - - "tabDepth" String that is the depth of the tab in the display - leadingTab = 1, child of leadingTab = 2, etc. - Here tabDepth does not default, it must be set - - bdc34 2006-01-12 created - **********************************************/ - Tab leadingTab = (Tab) request.getAttribute("leadingTab"); - if (leadingTab == null) { - String e = "tabSub expects that request attribute 'leadingTab' be set"; - throw new JspException(e); - } - - String tabId = request.getParameter("tabId"); - if (tabId == null) { - String e = "tabSub expects that request parameter 'tabId' be set"; - throw new JspException(e); - } - - Tab tab = null; - tab = TabWebUtil.findStashedTab(tabId, request); - if (tab == null) { - String e = "tabSub expects that request attribute 'leadingTab' will have the tab with tabId as a sub tab"; - throw new JspException(e); - } - - String obj = request.getParameter("tabDepth"); - int depth = 1; //depth 1 represents primary tab level, 2 is secondary, etc. - if (obj == null) { - String e = "tabSub expects that request parameter 'tabDepth' be set"; - throw new JspException(e); - } - depth = Integer.parseInt((String) obj); - int childDepth = depth + 1; - - Collection children = tab.filterChildrenForSubtabs(); - if (depth < CutOffDepth && children != null) { - if (children.size() >= HorzSubTabCutOff) { /* too many children, do tabSubAsList instead */ %> - - - - - <% } else { - - //here we figure out if these subtabs should have entities - //if we were passed a parameter, then maybe no entities - obj = request.getParameter("noEntities"); - String noEntities = "true".equalsIgnoreCase(obj) ? "true" : "false"; - //if we have more subtabs then the cutoff, no entities for the subtabs - noEntities = (children.size() >= EntsInDepth2TabsCutOff ? "true" : noEntities); - //if we are the first set of subtabs on a primary tab it seems there are no entities? sort of odd - noEntities = ((tab.PRIMARY_TAB == tab.getTabtypeId() && childDepth == 2) ? "true" : noEntities); - - String noDesc = (childDepth >= TabDescCutoffDepth) ? "true" : "false"; - - Iterator childIter = children.iterator(); - boolean hasChildren = childIter.hasNext(); - int columnSize = children.size(); - if (hasChildren) { %> - -
- - <% } - while( childIter.hasNext() ) { - Tab subtab = (Tab)childIter.next(); - TabWebUtil.stashTabsInRequest(subtab, request); %> - - <% if (columnSize==1) {%> - - <% } - if( hasChildren ){ %> -
- <% } %> - - <% else if (columnSize==2) {%> - - <% } %> - - <% else if (columnSize==3) {%> - - <% } %> - - <% else if (columnSize==4) {%> - - <% } %> - - <% else {%> - - <% } %> - - - - - - - - - - -
-
- <%} - } - } %> diff --git a/webapp/web/templates/tabs/tabSubAsList.jsp b/webapp/web/templates/tabs/tabSubAsList.jsp deleted file mode 100644 index ac9750b4f..000000000 --- a/webapp/web/templates/tabs/tabSubAsList.jsp +++ /dev/null @@ -1,87 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%@ page import="java.lang.Integer" %> -<%@ page import="java.util.Collection" %> -<%@ page import="java.util.Iterator" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.web.TabWebUtil" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Tab" %> -<%@ page errorPage="/error.jsp"%> -<% - int CutOffDepth = 3; //tab depth at which subtabs stop being shown - int TabDescCutoffDepth = 3;//depth at which descriptions of subtabs stop being shown - /*********************************************** - Display a set of subtabs for a Tab as a
    - Based on tabSub. - This does not attempt to display any subtabs, entities, etc. - - request.attributes - "leadingTab" the tab that is at the top of the display hierarchy - - request.parameters - "tabId" id of the tab to do subtabs for - - "tabDepth" String that is the depth of the tab in the display - leadingTab = 1, child of leadingTab = 2, etc. - Here tabDepth does not default, it must be set - - bdc34 2006-01-18 created - **********************************************/ - Tab leadingTab = (Tab) request.getAttribute("leadingTab"); - if (leadingTab == null) { - String e = "tabSub expects that request attribute 'leadingTab' be set"; - throw new JspException(e); - } - - String tabId = request.getParameter("tabId"); - if (tabId == null) { - String e = "tabSub expects that request parameter 'tabId' be set"; - throw new JspException(e); - } - - Tab tab = null; - tab = TabWebUtil.findStashedTab(tabId, request); - if (tab == null) { - String e = "tabSub expects that request attribute 'leadingTab' will have the tab with tabId as a sub tab"; - throw new JspException(e); - } - - String obj = request.getParameter("tabDepth"); - int depth = 1; //depth 1 represents primary tab level, 2 is secondary, etc. - if (obj == null) { - String e = "tabSub expects that request parameter 'tabDepth' be set"; - throw new JspException(e); - } - depth = Integer.parseInt((String) obj); - int childDepth = depth + 1; - - String noDesc = (childDepth >= TabDescCutoffDepth) ? "true" : "false"; - //noDesc = "true"; - - Collection children = tab.filterChildrenForSubtabs(); - if (depth < CutOffDepth && children != null) { - Iterator childIter = children.iterator(); - boolean hasChildren = childIter.hasNext(); - if (hasChildren) { %> -
    -
      - <% } - while( childIter.hasNext() ) { - Tab subtab = (Tab)childIter.next(); - TabWebUtil.stashTabsInRequest(subtab,request); %> -
    • - - - - - - - - - -
    • - <% } - if( hasChildren ){ %> -
    -
    - <%}%> -<% } %> diff --git a/webapp/web/templates/tabs/tabprimary.jsp b/webapp/web/templates/tabs/tabprimary.jsp deleted file mode 100755 index 951f1e1cc..000000000 --- a/webapp/web/templates/tabs/tabprimary.jsp +++ /dev/null @@ -1,38 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%@ page errorPage="/error.jsp"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.web.TabWebUtil" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Tab" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %> - -<% /*********************************************** - Display a primary tab. - - A display of a primary tab will include: - primary tab heading, - the primary tab description, - the primary tab body, - the secondary tabs , - the primary content tabs. - - expected request.attributes: - 'leadingTab' Tab to be desplayed as root of display hierarchy - - bdc34 2006-01-03 created - **********************************************/ - Tab leadingTab = (Tab) request.getAttribute("leadingTab"); - if (leadingTab == null) { - String e = "tabprimary expects that request attribute 'leadingTab' be set to a TabBean object"; - throw new JspException(e); - } - TabWebUtil.stashTabsInRequest(leadingTab, request); %> -
    -
    - - - - - -
    -
    \ No newline at end of file