NIHVIVO-2403 Remove tabs from code

This commit is contained in:
brianjlowe 2011-05-10 20:15:31 +00:00
parent 132cbdce2c
commit fbead2b020
72 changed files with 337 additions and 7065 deletions

View file

@ -52,8 +52,6 @@ xmlns:vitro="&vitro;"
<owl:AnnotationProperty rdf:about="&vitro;individualSortFieldAnnot"/> <owl:AnnotationProperty rdf:about="&vitro;individualSortFieldAnnot"/>
<owl:AnnotationProperty rdf:about="&vitro;individualSortDirectionAnnot"/> <owl:AnnotationProperty rdf:about="&vitro;individualSortDirectionAnnot"/>
<!-- Tab-related constructs -->
<!-- externalID-related constructs --> <!-- externalID-related constructs -->
<owl:AnnotationProperty rdf:about="&vitro;isExternalId"/> <owl:AnnotationProperty rdf:about="&vitro;isExternalId"/>
@ -147,76 +145,11 @@ xmlns:vitro="&vitro;"
<owl:DatatypeProperty rdf:about="&vitro;flag3SearchFiltering"/> <owl:DatatypeProperty rdf:about="&vitro;flag3SearchFiltering"/>
<owl:DatatypeProperty rdf:about="&vitro;urlPrefix"/> <owl:DatatypeProperty rdf:about="&vitro;urlPrefix"/>
<!-- Tab-related constructs -->
<owl:Class rdf:about="&vitro;Tab"/>
<owl:Class rdf:about="&vitro;SubcollectionCategory">
<rdfs:subClassOf rdf:resource="&vitro;Tab"/>
</owl:Class>
<owl:Class rdf:about="&vitro;Subcollection">
<rdfs:subClassOf rdf:resource="&vitro;Tab"/>
</owl:Class>
<owl:Class rdf:about="&vitro;Collection">
<rdfs:subClassOf rdf:resource="&vitro;Tab"/>
</owl:Class>
<owl:Class rdf:about="&vitro;SecondaryTab">
<rdfs:subClassOf rdf:resource="&vitro;Tab"/>
</owl:Class>
<owl:Class rdf:about="&vitro;PrimaryTabContent">
<rdfs:subClassOf rdf:resource="&vitro;Tab"/>
</owl:Class>
<owl:Class rdf:about="&vitro;PrimaryTab">
<rdfs:subClassOf rdf:resource="&vitro;Tab"/>
</owl:Class>
<owl:Class rdf:about="&vitro;AutoLinkableTab">
<rdfs:subClassOf rdf:resource="&vitro;Tab"/>
</owl:Class>
<owl:Class rdf:about="&vitro;ManuallyLinkableTab">
<rdfs:subClassOf rdf:resource="&vitro;Tab"/>
</owl:Class>
<owl:Class rdf:about="&vitro;MixedTab">
<rdfs:subClassOf rdf:resource="&vitro;AutoLinkableTab"/>
<rdfs:subClassOf rdf:resource="&vitro;ManuallyLinkableTab"/>
</owl:Class>
<owl:DatatypeProperty rdf:about="&vitro;tabCreatorUserId"/>
<owl:DatatypeProperty rdf:about="&vitro;statusId"/>
<owl:DatatypeProperty rdf:about="&vitro;tabBody"/>
<owl:DatatypeProperty rdf:about="&vitro;dayLimit"/>
<owl:DatatypeProperty rdf:about="&vitro;galleryRows"/>
<owl:DatatypeProperty rdf:about="&vitro;galleryCols"/>
<owl:DatatypeProperty rdf:about="&vitro;moreTag"/>
<owl:DatatypeProperty rdf:about="&vitro;imageWidth"/>
<owl:DatatypeProperty rdf:about="&vitro;individualSortDirection"/>
<owl:DatatypeProperty rdf:about="&vitro;individualSortField"/>
<owl:ObjectProperty rdf:about="&vitro;inPortal"/>
<owl:DatatypeProperty rdf:about="&vitro;individualSortField"/>
<owl:DatatypeProperty rdf:about="&vitro;individualSortDirection"/>
<owl:DatatypeProperty rdf:about="&vitro;rssUrl"/>
<owl:DatatypeProperty rdf:about="&vitro;flag2Set"/>
<owl:DatatypeProperty rdf:about="&vitro;flag3Set"/>
<owl:DatatypeProperty rdf:about="&vitro;flag2Mode"/>
<owl:DatatypeProperty rdf:about="&vitro;flag3Mode"/>
<owl:ObjectProperty rdf:about="&vitro;subTabOf"/>
<owl:AnnotationProperty rdf:about="&vitro;autoLinkedToTab"/>
<owl:Class rdf:about="&vitro;TabIndividualRelation"/>
<owl:ObjectProperty rdf:about="&vitro;involvesIndividual"/>
<owl:ObjectProperty rdf:about="&vitro;involvesTab"/>
<!-- Application-related constructs --> <!-- Application-related constructs -->
<owl:Class rdf:about="&vitro;Application"/> <owl:Class rdf:about="&vitro;Application"/>
<owl:DatatypeProperty rdf:about="&vitro;flag1Name"/>
<owl:DatatypeProperty rdf:about="&vitro;flag2Name"/>
<owl:DatatypeProperty rdf:about="&vitro;flag3Name"/>
<owl:DatatypeProperty rdf:about="&vitro;minSharedPortalId"/>
<owl:DatatypeProperty rdf:about="&vitro;maxSharedPortalId"/>
<owl:DatatypeProperty rdf:about="&vitro;rootLogotypeImage"/> <owl:DatatypeProperty rdf:about="&vitro;rootLogotypeImage"/>
<owl:DatatypeProperty rdf:about="&vitro;keywordHeading"/> <owl:DatatypeProperty rdf:about="&vitro;keywordHeading"/>
<owl:DatatypeProperty rdf:about="&vitro;onlyCurrent"/>
<owl:DatatypeProperty rdf:about="&vitro;maxPortalId"/>
<owl:DatatypeProperty rdf:about="&vitro;flag2Values"/>
<owl:DatatypeProperty rdf:about="&vitro;flag1Values"/>
<owl:DatatypeProperty rdf:about="&vitro;flag3Values"/>
<!-- User-related constructs --> <!-- User-related constructs -->

View file

@ -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<Tab> { // 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 <Individual> getRelatedEntityList(String alpha){
if (grabEntityFactory()==null && relatedEntityList == null)
return new LinkedList<Individual>(); // 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 <Individual>getRelatedEntities(){ return getRelatedEntityList(null); }
private Collection childTabList=null;
public void setChildTabs(Collection <Tab> val) {childTabList=val;}
public Collection <Tab>getChildTabs() {return childTabList;}
private Collection<Tab> 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<Tab> 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 <Tab>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 = "<p>Tab:<ul>";
output += "<li>tab id: [" + tabId + "]</li>";
output += "<li>tabtype id: [" + tabtypeId + "]</li>";
output += "<li>user id: [" + userId + "]</li>";
output += "<li>day limit: [" + dayLimit + "]</li>";
output += "<li>gallery rows: [" + galleryRows + "]</li>";
output += "<li>gallery columns: [" + galleryCols + "]</li>";
output += "<li>image width [" + imageWidth + "]</li>";
output += "<li>entity sort field: [" + entitySortField + "]</li>";
output += "<li>entity sort direction [" + entitySortDirection + "]</li>";
output += "<li>flag2Set: [" + flag2Set + "]</li>";
output += "<li>flag2Numeric: [" + flag2Numeric + "]</li>";
output += "<li>flag2Mode: [" + flag2Mode + "]</li>";
output += "<li>flag3Set: [" + flag3Set + "]</li>";
output += "<li>flag3Numeric: [" + flag3Numeric + "]</li>";
output += "<li>flag3Mode: [" + flag3Mode + "]</li>";
output += "<li>title: [" + title + "]</li>";
output += "<li>moreTag: [" + moreTag + "]</li>";
output += "<li>description: [" + description + "]</li>";
output += "<li>body: [" + body + "]</li>";
output += "<li>rssURL: [" + rssURL + "]</li>";
output += "<li>entity link method: [" + entityLinkMethod + "]</li>";
output += "<li>autolink type count: [" + autolinkTypeCount + "]</li>";
output += "<li>alpha filtered entity count [" + alphaFilteredEntityCount + "]</li>";
output += "<li>alpha UNfiltered entity count [" + alphaUnfilteredEntityCount + "]</li>";
if (relatedEntityList!=null && relatedEntityList.size()>0) {
output += "<li>related entities [" + relatedEntityList.toString() + "]</li>";
}
if (relatedEntityList!=null && relatedEntityList.size()>0) {
output += "<li>related entities [" + relatedEntityList.toString() + "]</li>";
}
output += "</ul></p>";
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());
}
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; 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;
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.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;

View file

@ -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(
"<html><head>"+
"<meta http-equiv='refresh' "+
"content='0;URL=http://research.cals.cornell.edu/index.jsp?home=60' />"+
"<title>CALS Research</title>"+
"</head>"+
"<body bgcolor='black'>"+
"</body>"+
"</html>");
*/
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;
}
}

View file

@ -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<String> manuallyLinkedUris = Collections.emptyList();
List<String> 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<String> autoLinkedUris, List<String> 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<Individual> results = new ArrayList<Individual>(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<String> autoLinkedUris,
List<String> 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<String> vclassUris, List<String> 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<PageRecord> makePagesList( int count, int pageSize, int selectedPage){
List<PageRecord> records = new ArrayList<PageRecord>( 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;
}
}
}

View file

@ -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<String> results = new ArrayList<String>();
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<Integer, String> tabTypes = new HashMap<Integer, String>();
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<Checkbox> parentList = new LinkedList<Checkbox>();
Iterator<Tab> parentIt = tDao.getParentTabs(t).iterator();
while (parentIt.hasNext()) {
Tab parent = parentIt.next();
Checkbox cb = new Checkbox();
//cb.setBody(parent.getTitle());
cb.setBody("<a href=\"tabEdit?id="+parent.getTabId()+"\">"+parent.getTitle()+"</a>");
cb.setValue(Integer.toString(parent.getTabId()));
cb.setChecked(false);
parentList.add(cb);
}
foo.getCheckboxLists().put("parentTabs",parentList);
// child tabs
List<Checkbox> childList = new LinkedList<Checkbox>();
Iterator<Tab> 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("<a href=\"tabEdit?id="+child.getTabId()+"\">"+child.getTitle()+"</a>");
cb.setChecked(false);
childList.add(cb);
}
foo.getCheckboxLists().put("childTabs",childList);
HashMap OptionMap = new HashMap();
List<VClassGroup> 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<VClass> 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<VClass> types = new LinkedList<VClass>();
List<String> typeURIs = tDao.getTabAutoLinkedVClassURIs(tabId);
Iterator<String> 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<TabIndividualRelation> tirs = tirDao.getTabIndividualRelationsByTabURI(((WebappDaoFactory)request.getSession().getServletContext().getAttribute("webappDaoFactory")).getDefaultNamespace()+"tab"+tabId);
List checkboxList = new ArrayList();
Iterator<TabIndividualRelation> 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", "<link rel=\"stylesheet\" type=\"text/css\" href=\""+vreq.getAppBean().getThemeDir()+"css/edit.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);
}
}

View file

@ -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<childIdStr.length; childIndex++) {
try {
int childId = Integer.decode(childIdStr[childIndex]);
Tab child = tDao.getTab(childId);
tDao.removeParentTab(child, parent);
} catch (NumberFormatException nfe) {}
}
} catch (NumberFormatException nfe) {}
} else {
try {
int childId = Integer.decode(childIdStr[0]);
Tab child = tDao.getTab(childId);
for (int parentIndex=0; parentIndex<parentIdStr.length; parentIndex++) {
try {
int parentId = Integer.decode(parentIdStr[parentIndex]);
Tab parent = tDao.getTab(parentId);
tDao.removeParentTab(child, parent);
} catch (NumberFormatException nfe) {}
}
} catch (NumberFormatException nfe) {}
}
} else if (action.equals("_insert")) {
try {
int childId = Integer.decode(childIdStr[0]);
int parentId = Integer.decode(parentIdStr[0]);
Tab child = tDao.getTab(childId);
Tab parent = tDao.getTab(parentId);
tDao.addParentTab(child, parent);
} catch (NumberFormatException nfe) {}
}
}
//if no page forwarder was set, just go back to referring page:
//the referer stuff all will be changed so as not to rely on the HTTP header
EditProcessObject epo = super.createEpo(request);
String referer = epo.getReferer();
if (referer == null) {
try {
response.sendRedirect(defaultLandingPage);
} catch (IOException e) {
e.printStackTrace();
}
} else {
try {
response.sendRedirect(referer);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

View file

@ -1,99 +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.TabIndividualRelation;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.TabIndividualRelationDao;
public class TabIndividualRelationOperationController extends
BaseEditController {
private static final Log log = LogFactory.getLog(TabIndividualRelationOperationController.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;
}
TabIndividualRelationDao dao = request.getFullWebappDaoFactory().getTabs2EntsDao();
try {
if (request.getParameter("operation").equals("remove")) {
String[] tirURIstrs = request.getParameterValues("TirURI");
if ((tirURIstrs != null) && (tirURIstrs.length > 0)) {
for (int i=0; i<tirURIstrs.length; i++) {
TabIndividualRelation tir = dao.getTabIndividualRelationByURI(tirURIstrs[i]);
dao.deleteTabIndividualRelation(tir);
}
}
}
} catch (Exception e) {
//e.printStackTrace();
}
//if no page forwarder was set, just go back to referring page:
//the referer stuff all will be changed so as not to rely on the HTTP header
String referer = request.getHeader("REFERER");
if (referer == null) {
try {
response.sendRedirect(defaultLandingPage);
} catch (IOException e) {
e.printStackTrace();
}
} else {
try {
response.sendRedirect(referer);
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) {
doGet(request, response);
}
}

View file

@ -1,158 +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 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.forwarder.PageForwarder;
import edu.cornell.mannlib.vedit.forwarder.impl.UrlForwarder;
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 TabRetryController extends BaseEditController {
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"};
private static final Log log = LogFactory.getLog(TabRetryController.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);
epo.setBeanClass(Tab.class);
epo.setIdFieldName("TabId");
String action = "insert";
TabDao tDao = request.getFullWebappDaoFactory().getTabDao();
epo.setDataAccessObject(tDao);
Tab tabForEditing = null;
if (!epo.getUseRecycledBean()){
if (request.getParameter("id") != null) {
int id = Integer.parseInt(request.getParameter("id"));
if (id > 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<tabtypeIds.length; i++) {
Option tabtypeOpt = new Option(Integer.toString(tabtypeIds[i]), tabtypeNames[i], tabForEditing.getTabtypeId()==tabtypeIds[i]);
tabtypeList.add(tabtypeOpt);
}
optionMap.put("TabtypeId", tabtypeList);
List entityLinkMethodList = new LinkedList();
entityLinkMethodList.add(new Option("mixed", "mixed manual and auto", tabForEditing.getEntityLinkMethod().equals("mixed")));
entityLinkMethodList.add(new Option("manual", "manual", tabForEditing.getEntityLinkMethod().equals("manual")));
entityLinkMethodList.add(new Option("auto", "by tab-type relationships", tabForEditing.getEntityLinkMethod().equals("auto")));
optionMap.put("EntityLinkMethod",entityLinkMethodList);
// TODO? statusId
// portalId
foo.setOptionLists(optionMap);
epo.setFormObject(foo);
String html = FormUtils.htmlFormFromBean(tabForEditing,action,foo,epo.getBadValueMap());
RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
request.setAttribute("formHtml",html);
request.setAttribute("bodyJsp","/templates/edit/formBasic.jsp");
request.setAttribute("formJsp","/templates/edit/specific/tab_retry.jsp");
request.setAttribute("scripts","/templates/edit/formBasic.js");
request.setAttribute("title","Tab Editing Form");
request.setAttribute("_action",action);
request.setAttribute("unqualifiedClassName","Tab");
setRequestAttributes(request,epo);
try {
rd.forward(request, response);
} catch (Exception e) {
log.error("TabRetryController could not forward to view.");
log.error(e.getMessage());
log.error(e.getStackTrace());
}
}
public void doGet (HttpServletRequest request, HttpServletResponse response) {
doPost(request, response);
}
class TabInsertPageForwarder implements PageForwarder {
public void doForward(HttpServletRequest request, HttpServletResponse response, EditProcessObject epo){
String newTabUrl = "tabEdit?id=";
Tab tab = (Tab) epo.getNewBean();
newTabUrl += tab.getTabId();
try {
response.sendRedirect(newTabUrl);
} catch (IOException ioe) {
log.error("TabInsertPageForwarder could not send redirect.");
}
}
}
}

View file

@ -1,161 +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.Collections;
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.ManagePortals;
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.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;
public class Tabs2EntsRetryController extends BaseEditController {
private static final Log log = LogFactory.getLog(Tabs2EntsRetryController.class.getName());
public void doPost (HttpServletRequest req, HttpServletResponse response) {
if (!isAuthorizedToDisplayPage(req, response, new Actions(new ManagePortals()))) {
return;
}
VitroRequest request = new VitroRequest(req);
//create an EditProcessObject for this and put it in the session
EditProcessObject epo = super.createEpo(request);
String action = "insert";
TabIndividualRelationDao t2eDao = request.getFullWebappDaoFactory().getTabs2EntsDao();
epo.setDataAccessObject(t2eDao);
TabDao tDao = request.getFullWebappDaoFactory().getTabDao();
IndividualDao eDao = request.getFullWebappDaoFactory().getIndividualDao();
TabIndividualRelation objectForEditing = null;
if (request.getParameter("uri") != null) {
try {
objectForEditing = t2eDao.getTabIndividualRelationByURI(request.getParameter("uri"));
action = "update";
} catch (NullPointerException e) {
log.error("Need to implement 'record not found' error message.");
}
} else {
objectForEditing = new TabIndividualRelation();
String entityIdStr = request.getParameter("entityUri");
if (entityIdStr != null) {
try {
objectForEditing.setEntURI(entityIdStr);
} 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(t2eDao.getClass().getDeclaredMethod("getTabs2TypesById",args));
} catch (NoSuchMethodException e) {
log.error("Tabs2EntsRetryController could not find the getTabs2TypesById method in the facade");
}
HashMap optionMap = new HashMap();
List<Tab> 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<Individual> 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);
}
}

View file

@ -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);
}
}

View file

@ -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<typeURIstrs.length; i++) {
TabVClassRelation t2t = new TabVClassRelation();
t2t.setTabId(Integer.decode(tabIdStr));
t2t.setVClassURI(typeURIstrs[i]);
dao.deleteTabVClassRelation(t2t);
}
}
}
} else if (request.getParameter("operation").equals("add")) {
TabVClassRelation t2t = new TabVClassRelation();
t2t.setTabId(Integer.decode(request.getParameter("TabId")));
t2t.setVClassURI(request.getParameter("TypeURI"));
dao.insertTabVClassRelation(t2t);
}
} catch (Exception e) {
//e.printStackTrace();
}
}
//if no page forwarder was set, just go back to referring page:
//the referer stuff all will be changed so as not to rely on the HTTP header
String referer = request.getHeader("REFERER");
if (referer == null) {
try {
response.sendRedirect(defaultLandingPage);
} catch (IOException e) {
e.printStackTrace();
}
} else {
try {
response.sendRedirect(referer);
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) {
doGet(request, response);
}
}

View file

@ -1,148 +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.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.collections.map.ListOrderedMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vedit.beans.EditProcessObject;
import edu.cornell.mannlib.vedit.beans.FormObject;
import edu.cornell.mannlib.vedit.controller.BaseEditController;
import edu.cornell.mannlib.vedit.util.FormUtils;
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.Tab;
import edu.cornell.mannlib.vitro.webapp.beans.TabVClassRelation;
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.TabDao;
import edu.cornell.mannlib.vitro.webapp.dao.TabVClassRelationDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
public class Tabs2TypesRetryController extends BaseEditController {
private static final Log log = LogFactory.getLog(Tabs2TypesRetryController.class.getName());
public void doPost (HttpServletRequest req, HttpServletResponse response) {
if (!isAuthorizedToDisplayPage(req, response, new Actions(new ManagePortals()))) {
return;
}
VitroRequest request = new VitroRequest(req);
//create an EditProcessObject for this and put it in the session
EditProcessObject epo = super.createEpo(request);
String action = "insert";
TabVClassRelationDao t2tDao = request.getFullWebappDaoFactory().getTabs2TypesDao();
epo.setDataAccessObject(t2tDao);
TabDao tDao = request.getFullWebappDaoFactory().getTabDao();
VClassGroupDao cgDao = request.getFullWebappDaoFactory().getVClassGroupDao();
TabVClassRelation objectForEditing = null;
if (request.getParameter("id") != null) {
int id = Integer.parseInt(request.getParameter("id"));
if (id > 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<Tab> 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);
}
}

View file

@ -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<Integer, String> types = new HashMap<Integer, String>();
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<Tab> tabs = dao.getTabsForPortal(1);
Collections.sort(tabs, new TabComparator());
ArrayList<String> results = new ArrayList<String>();
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("<a href=\"./tabEdit?id="+tab.getTabId()+"\">"+tab.getTitle()+"</a>");
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<Tab> {
@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;
}
}
}

View file

@ -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.RedirectResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; 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.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.Tags;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.User; 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.MainMenu;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.menu.TabMenu;
import freemarker.ext.beans.BeansWrapper; import freemarker.ext.beans.BeansWrapper;
import freemarker.template.Configuration; import freemarker.template.Configuration;
import freemarker.template.DefaultObjectWrapper; import freemarker.template.DefaultObjectWrapper;
@ -354,7 +352,6 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
map.putAll(getDirectives()); map.putAll(getDirectives());
map.putAll(getMethods()); map.putAll(getMethods());
map.put("tabMenu", getTabMenu(vreq));
map.put("menu", getDisplayModelMenu(vreq)); map.put("menu", getDisplayModelMenu(vreq));
map.put("user", new User(vreq)); map.put("user", new User(vreq));
@ -363,7 +360,6 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
map.put("copyright", getCopyrightInfo(appBean)); map.put("copyright", getCopyrightInfo(appBean));
map.put("siteTagline", appBean.getShortHand()); 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. // This value is used only in stylesheets.ftl and already contains the context path.
map.put("stylesheetPath", UrlBuilder.getUrl(themeDir + "/css")); map.put("stylesheetPath", UrlBuilder.getUrl(themeDir + "/css"));
@ -394,10 +390,6 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
return (name.length() == 0 || name.equals("index.jsp")) ? "home" : name; 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){ protected MainMenu getDisplayModelMenu(VitroRequest vreq){
String url = vreq.getRequestURI().substring(vreq.getContextPath().length()); String url = vreq.getRequestURI().substring(vreq.getContextPath().length());
return vreq.getWebappDaoFactory().getMenuDao().getMainMenu(url); return vreq.getWebappDaoFactory().getMenuDao().getMainMenu(url);

View file

@ -8,7 +8,6 @@ import java.util.Map;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; 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.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; 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.controller.freemarker.responsevalues.TemplateResponseValues;
@ -43,22 +42,9 @@ public class HomePageController extends FreemarkerHttpServlet {
body.putAll(pageData); 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); 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 @Override
protected String getTitle(String siteName, VitroRequest vreq) { protected String getTitle(String siteName, VitroRequest vreq) {
return siteName; return siteName;

View file

@ -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.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; 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.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; 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 ENTITY_LIST_CONTROLLER_MAX_RESULTS = 30000;
public static final int INDIVIDUALS_PER_PAGE = 30; 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"; private static final String TEMPLATE_DEFAULT = "individualList.ftl";
@ -230,7 +229,7 @@ public class IndividualListController extends FreemarkerHttpServlet {
if( size > INDIVIDUALS_PER_PAGE ){ if( size > INDIVIDUALS_PER_PAGE ){
rvMap.put("showPages", Boolean.TRUE); rvMap.put("showPages", Boolean.TRUE);
List<PageRecord> pageRecords = TabEntitiesController.makePagesList(size, INDIVIDUALS_PER_PAGE, page); List<PageRecord> pageRecords = makePagesList(size, INDIVIDUALS_PER_PAGE, page);
rvMap.put("pages", pageRecords); rvMap.put("pages", pageRecords);
}else{ }else{
rvMap.put("showPages", Boolean.FALSE); rvMap.put("showPages", Boolean.FALSE);
@ -271,4 +270,68 @@ public class IndividualListController extends FreemarkerHttpServlet {
} }
} }
public static List<PageRecord> makePagesList( int count, int pageSize, int selectedPage){
List<PageRecord> records = new ArrayList<PageRecord>( 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;
}
}
} }

View file

@ -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.auth.requestedAction.usepages.UseAdvancedDataToolsPages;
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; 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.edit.listing.UsersListingController;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
@ -120,10 +119,6 @@ public class SiteAdminController extends FreemarkerHttpServlet {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
Map<String, String> urls = new HashMap<String, String>(); Map<String, String> urls = new HashMap<String, String>();
if (PolicyHelper.isAuthorizedForActions(vreq, AllTabsForPortalListingController.REQUIRED_ACTIONS)) {
urls.put("tabs", urlBuilder.getPortalUrl("/listTabs"));
}
// TODO remove this when the UserAccounts are fully implemented. -- jblake // TODO remove this when the UserAccounts are fully implemented. -- jblake
if (PolicyHelper.isAuthorizedForActions(vreq, UsersListingController.REQUIRED_ACTIONS)) { if (PolicyHelper.isAuthorizedForActions(vreq, UsersListingController.REQUIRED_ACTIONS)) {
urls.put("users", urlBuilder.getPortalUrl("/listUsers")); urls.put("users", urlBuilder.getPortalUrl("/listUsers"));

View file

@ -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<Tab> getParentTabs(Tab tab);
List<Tab> getParentTabs(String tabURI);
List<Tab> getChildTabs(Tab tab);
List<Tab> 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 <String> getTabAutoLinkedVClassURIs(int tab_id);
List <String> 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<Tab> getAllAutolinkableTabs(int portalId);
List<Tab> getAllManuallyLinkableTabs(int portalId);
}

View file

@ -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 <Individual> 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 <String> getLettersOfEnts();
}

View file

@ -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<TabIndividualRelation> getTabIndividualRelationsByIndividualURI(String individualURI);
List<TabIndividualRelation> 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);
}

View file

@ -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);
}

View file

@ -147,7 +147,6 @@ public class VitroVocabulary {
// ================== Vitro Portal vocabulary =========================== // ================== Vitro Portal vocabulary ===========================
public static final String PORTAL = vitroURI+"Portal"; 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_THEMEDIR = vitroURI+"themeDir";
public static final String PORTAL_BANNERIMAGE = vitroURI+"bannerImage"; public static final String PORTAL_BANNERIMAGE = vitroURI+"bannerImage";
public static final String PORTAL_CONTACTMAIL = vitroURI+"contactMail"; public static final String PORTAL_CONTACTMAIL = vitroURI+"contactMail";
@ -168,44 +167,6 @@ public class VitroVocabulary {
// reusing displayRank property above // reusing displayRank property above
public static final String PORTAL_URLPREFIX = vitroURI + "urlPrefix"; 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 ================================= // =============== Vitro User vocabulary =================================
// TODO - these go away when the UserAccount stuff is fully implemented - jblake // TODO - these go away when the UserAccount stuff is fully implemented - jblake

View file

@ -112,10 +112,6 @@ public interface WebappDaoFactory {
public ApplicationDao getApplicationDao(); public ApplicationDao getApplicationDao();
public TabDao getTabDao();
public TabIndividualRelationDao getTabs2EntsDao();
public TabVClassRelationDao getTabs2TypesDao();
public KeywordIndividualRelationDao getKeys2EntsDao(); public KeywordIndividualRelationDao getKeys2EntsDao();
public KeywordDao getKeywordDao(); public KeywordDao getKeywordDao();

View file

@ -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<Tab> getParentTabs(Tab tab) {
return setupFilteringTabs(innerDao.getParentTabs(tab));
}
public List<Tab> getParentTabs(String tabURI) {
return setupFilteringTabs(innerDao.getParentTabs(tabURI));
}
public List<Tab> getChildTabs(Tab tab) {
return setupFilteringTabs(innerDao.getChildTabs(tab));
}
public List<Tab> getChildTabs(String tabURI) {
return setupFilteringTabs(innerDao.getChildTabs(tabURI));
}
public List<Tab> getAllAutolinkableTabs(int portalId) {
return setupFilteringTabs(filter(innerDao.getAllAutolinkableTabs(portalId),filters.getTabFilter()));
}
public List<Tab> 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<Integer>());
}
private List<Tab> setupFilteringTabs( Collection<Tab> tabs ){
if( tabs == null ) return null;
LinkedList<Tab> tabsOut = new LinkedList<Tab>();
Set<Integer> visitedTabIds = new HashSet<Integer>();
for( Tab tab : tabs){
tabsOut.add( setupFilteringTabCarefully( tab, visitedTabIds) );
}
return tabsOut;
}
private List<Tab> setupFilteringTabs(Collection<Tab> tabs, Set<Integer> visitedTabIds){
if( tabs == null ) return null;
LinkedList<Tab> tabsOut = new LinkedList<Tab>();
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<Integer> 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<Tab> children = setupFilteringTabs( in.getChildTabs(), visitedTabIds);
in.setChildTabs( children );
return in;
}
}

View file

@ -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.PageDao;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao; 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.UserAccountsDao;
import edu.cornell.mannlib.vitro.webapp.dao.UserDao; import edu.cornell.mannlib.vitro.webapp.dao.UserDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
@ -72,7 +69,6 @@ public class WebappDaoFactoryFiltering implements WebappDaoFactory {
transient private ObjectPropertyStatementDao filteringObjectPropertyStatementDao=null; transient private ObjectPropertyStatementDao filteringObjectPropertyStatementDao=null;
transient private VClassDao filteringVClassDao=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 UserDao filteringUserDao=null; // TODO This goes away when the UserAccounts stuff is fully implemented - jblake.
transient private UserAccountsDao filteringUserAccountsDao=null; transient private UserAccountsDao filteringUserAccountsDao=null;
transient private VClassGroupDao filteringVClassGroupDao=null; transient private VClassGroupDao filteringVClassGroupDao=null;
@ -132,13 +128,6 @@ public class WebappDaoFactoryFiltering implements WebappDaoFactory {
return filteringIndividualDao; 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. // TODO This goes away when the UserAccounts stuff is fully implemented - jblake.
public UserDao getUserDao() { public UserDao getUserDao() {
if( filteringUserDao == null) if( filteringUserDao == null)
@ -190,14 +179,6 @@ public class WebappDaoFactoryFiltering implements WebappDaoFactory {
return innerWebappDaoFactory.getUserURI(); return innerWebappDaoFactory.getUserURI();
} }
public TabIndividualRelationDao getTabs2EntsDao() {
return innerWebappDaoFactory.getTabs2EntsDao();
}
public TabVClassRelationDao getTabs2TypesDao() {
return innerWebappDaoFactory.getTabs2TypesDao();
}
public FlagDao getFlagDao() { public FlagDao getFlagDao() {
return innerWebappDaoFactory.getFlagDao(); return innerWebappDaoFactory.getFlagDao();
} }

View file

@ -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<Individual,String> firstLetterOfName = new FirstLetterOfEnt();
public static UnaryFunctor<Individual,Boolean> getFilterForTab( final Tab tab, final boolean isFlag1Filtering ){
DateTime now = new DateTime();
UnaryFunctor<Individual,Boolean> 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<Individual,Boolean> getTimeFilter(final Tab tab, final DateTime now){
UnaryFunctor<Individual,Boolean> out = null;
if( tab.getDayLimit() == 0){
out = getSunsetWindowFilter( now.toDate() ).getIndividualFilter();
} else if( tab.getDayLimit() > 0 ) {
out = new UnaryFunctor<Individual,Boolean>(){
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<Individual,Boolean>(){
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<Individual,Boolean> getAlphaFilter(final String letter){
return new UnaryFunctor<Individual,Boolean>(){
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<Individual>, List<Individual>>
// 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<Individual>,Collection<String>>
getLetersOfEntsTransform(){
return new UnaryFunctor<Collection<Individual>,Collection<String>>(){
public Collection<String> fn(Collection<Individual> individuals) {
Iterable<String>i =
Sort.sort(
Unique.unique(
Transform.transform( individuals,
VitroFilterUtils.FirstLetterOfIndividuals() )
)
);
ArrayList<String> out = new ArrayList<String>(26);
for( String str : i){
out.add(str);
}
return out;
}
};
}
@SuppressWarnings("unchecked")
public static List getLettersOfEnts(List<Individual> ents) {
Comparator<String> comp = new Comparator<String>(){
public int compare(String o1, String o2) {
return o1.compareTo(o2);
};
};
Iterable<String>i =
Unique.unique(
Sort.sort(
Transform.transform( ents ,firstLetterOfName ),
comp
)
);
ArrayList<String> out = new ArrayList<String>(26);
for( String str : i){
out.add(str);
}
return out;
}
@SuppressWarnings("serial")
class FirstLetterFilter extends UnaryFunctor<Individual,Boolean>{
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<Individual,String>{
@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<Individual,Boolean> fn =
new UnaryFunctor<Individual, Boolean>(){
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<ObjectPropertyStatement,Boolean> objPropfn =
new UnaryFunctor<ObjectPropertyStatement, Boolean>(){
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;
}
}

View file

@ -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.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement; import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup; 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.User;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
@ -37,14 +36,12 @@ public interface VitroFilters {
public UnaryFunctor<VClass, Boolean> getClassFilter(); public UnaryFunctor<VClass, Boolean> getClassFilter();
public UnaryFunctor<Tab, Boolean> getTabFilter();
public UnaryFunctor<VClassGroup, Boolean> getVClassGroupFilter(); public UnaryFunctor<VClassGroup, Boolean> getVClassGroupFilter();
// TODO This goes away when the UserAccounts stuff is fully implemented -- jb // TODO This goes away when the UserAccounts stuff is fully implemented -- jb
public UnaryFunctor<User, Boolean> getUserFilter(); public UnaryFunctor<User, Boolean> getUserFilter();
public UnaryFunctor<PropertyGroup, Boolean> getPropertyGroupFilter(); public UnaryFunctor<PropertyGroup, Boolean> getPropertyGroupFilter();
} }

View file

@ -18,7 +18,6 @@ public abstract class VitroFiltersBase implements VitroFilters {
AdaptorFunctors.and(this.getDataPropertyStatementFilter(),other.getDataPropertyStatementFilter()), AdaptorFunctors.and(this.getDataPropertyStatementFilter(),other.getDataPropertyStatementFilter()),
AdaptorFunctors.and(this.getObjectPropertyStatementFilter(),other.getObjectPropertyStatementFilter()), AdaptorFunctors.and(this.getObjectPropertyStatementFilter(),other.getObjectPropertyStatementFilter()),
AdaptorFunctors.and(this.getClassFilter(),other.getClassFilter()), AdaptorFunctors.and(this.getClassFilter(),other.getClassFilter()),
AdaptorFunctors.and(this.getTabFilter(),other.getTabFilter()),
AdaptorFunctors.and(this.getVClassGroupFilter(),other.getVClassGroupFilter()), AdaptorFunctors.and(this.getVClassGroupFilter(),other.getVClassGroupFilter()),
AdaptorFunctors.and(this.getUserFilter(), other.getUserFilter()), AdaptorFunctors.and(this.getUserFilter(), other.getUserFilter()),
AdaptorFunctors.and(this.getPropertyGroupFilter(), other.getPropertyGroupFilter()) AdaptorFunctors.and(this.getPropertyGroupFilter(), other.getPropertyGroupFilter())

View file

@ -2,9 +2,17 @@
package edu.cornell.mannlib.vitro.webapp.dao.filtering.filters; 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.UnaryFunctor;
import net.sf.jga.fn.adaptor.AdaptorFunctors; 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. * A object to hold all the filters commonly used by the vitro webapp.
@ -32,9 +40,6 @@ public class VitroFiltersImpl extends VitroFiltersBase {
UnaryFunctor<VClass,Boolean> classFilter; UnaryFunctor<VClass,Boolean> classFilter;
/* *************** filters only used by Webapp ******************* */ /* *************** filters only used by Webapp ******************* */
/** filter for Tab objects */
UnaryFunctor<Tab,Boolean> tabFilter;
/** filter for VClassGroup objects */ /** filter for VClassGroup objects */
UnaryFunctor<VClassGroup,Boolean> vClassGroupFilter; UnaryFunctor<VClassGroup,Boolean> vClassGroupFilter;
@ -58,7 +63,6 @@ public class VitroFiltersImpl extends VitroFiltersBase {
dataPropertyStatementFilter = FILTER_OUT_NOTHING; dataPropertyStatementFilter = FILTER_OUT_NOTHING;
objectPropertyStatementFilter= FILTER_OUT_NOTHING; objectPropertyStatementFilter= FILTER_OUT_NOTHING;
classFilter= FILTER_OUT_NOTHING; classFilter= FILTER_OUT_NOTHING;
tabFilter= FILTER_OUT_NOTHING;
vClassGroupFilter = FILTER_OUT_NOTHING; vClassGroupFilter = FILTER_OUT_NOTHING;
userFilter= FILTER_OUT_NOTHING; userFilter= FILTER_OUT_NOTHING;
propertyGroupFilter = FILTER_OUT_NOTHING; propertyGroupFilter = FILTER_OUT_NOTHING;
@ -71,7 +75,6 @@ public class VitroFiltersImpl extends VitroFiltersBase {
UnaryFunctor<DataPropertyStatement, Boolean> dataPropertyStatementFilter, UnaryFunctor<DataPropertyStatement, Boolean> dataPropertyStatementFilter,
UnaryFunctor<ObjectPropertyStatement, Boolean> objectPropertyStatementFilter, UnaryFunctor<ObjectPropertyStatement, Boolean> objectPropertyStatementFilter,
UnaryFunctor<VClass, Boolean> classFilter, UnaryFunctor<VClass, Boolean> classFilter,
UnaryFunctor<Tab, Boolean> tabFilter,
UnaryFunctor<VClassGroup, Boolean> classGroupFilter, UnaryFunctor<VClassGroup, Boolean> classGroupFilter,
UnaryFunctor<User, Boolean> userFilter, UnaryFunctor<User, Boolean> userFilter,
UnaryFunctor<PropertyGroup,Boolean>propertyGroupFilter) { UnaryFunctor<PropertyGroup,Boolean>propertyGroupFilter) {
@ -82,7 +85,6 @@ public class VitroFiltersImpl extends VitroFiltersBase {
this.dataPropertyStatementFilter = dataPropertyStatementFilter; this.dataPropertyStatementFilter = dataPropertyStatementFilter;
this.objectPropertyStatementFilter = objectPropertyStatementFilter; this.objectPropertyStatementFilter = objectPropertyStatementFilter;
this.classFilter = classFilter; this.classFilter = classFilter;
this.tabFilter = tabFilter;
vClassGroupFilter = classGroupFilter; vClassGroupFilter = classGroupFilter;
this.userFilter = userFilter; this.userFilter = userFilter;
this.propertyGroupFilter = propertyGroupFilter; this.propertyGroupFilter = propertyGroupFilter;
@ -165,18 +167,6 @@ public class VitroFiltersImpl extends VitroFiltersBase {
return this; return this;
} }
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.webapp.dao.filtering.VitroFilters#getTabFilter()
*/
public UnaryFunctor<Tab, Boolean> getTabFilter() {
return tabFilter;
}
public VitroFilters setTabFilter(UnaryFunctor<Tab, Boolean> tabFilter) {
this.tabFilter = tabFilter;
return this;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.webapp.dao.filtering.VitroFilters#getVClassGroupFilter() * @see edu.cornell.mannlib.vitro.webapp.dao.filtering.VitroFilters#getVClassGroupFilter()
*/ */

View file

@ -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<Individual,Boolean> _entityFilter;
List<Individual> _innerEnts;
List<Individual> _filteredEnts;
UnaryFunctor<List<Individual>,List<Individual>> _sorting;
public TabEntityFactoryFiltering(TabEntityFactory factory,
UnaryFunctor<Individual, Boolean> filter,
UnaryFunctor<List<Individual>,List<Individual>> sorting) {
super();
_innerTabFactory = factory;
_entityFilter = filter;
_sorting = sorting;
}
@SuppressWarnings("unchecked")
public List getLettersOfEnts() {
ArrayList out = new ArrayList();
List<Individual> ents = getInnerEnts();
filter(ents,_entityFilter);
return FiltersForTabs.getLettersOfEnts( ents);
}
/** Get entities from innerTabFactory filtered by entityFilter. */
@SuppressWarnings("unchecked")
public List getRelatedEntites(String alpha) {
List<Individual> ents = _innerTabFactory.getRelatedEntites( alpha );
if( ents == null ) return Collections.EMPTY_LIST;
List<Individual> outEnts = new LinkedList<Individual>();
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<Individual> 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());
}
}

View file

@ -875,8 +875,6 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao {
String type = typeRes.getURI(); String type = typeRes.getURI();
// brute forcing this until we implement a better strategy // brute forcing this until we implement a better strategy
if (VitroVocabulary.PORTAL.equals(type) || if (VitroVocabulary.PORTAL.equals(type) ||
VitroVocabulary.TAB.equals(type) ||
VitroVocabulary.TAB_INDIVIDUALRELATION.equals(type) ||
VitroVocabulary.LINK.equals(type) || VitroVocabulary.LINK.equals(type) ||
VitroVocabulary.KEYWORD.equals(type) || VitroVocabulary.KEYWORD.equals(type) ||
VitroVocabulary.KEYWORD_INDIVIDUALRELATION.equals(type) || VitroVocabulary.KEYWORD_INDIVIDUALRELATION.equals(type) ||

View file

@ -114,7 +114,8 @@ public class IndividualDaoSDB extends IndividualDaoJena {
"SELECT DISTINCT ?ind ?label ?moniker " + "SELECT DISTINCT ?ind ?label ?moniker " +
"WHERE " + "WHERE " +
"{ \n" + "{ \n" +
"{ \n" + "{ ?ind a <" + theClass.getURI() + "> } \n" +
"UNION { \n" +
" ?ind a <" + theClass.getURI() + "> . \n" + " ?ind a <" + theClass.getURI() + "> . \n" +
" ?ind <" + RDFS.label.getURI() + "> ?label \n" + " ?ind <" + RDFS.label.getURI() + "> ?label \n" +
"} \n" + "} \n" +

View file

@ -119,7 +119,6 @@ public class JenaBaseDaoCon {
// protected DatatypeProperty APPLICATION_MAXPORTALID = null; // protected DatatypeProperty APPLICATION_MAXPORTALID = null;
protected OntClass PORTAL = _constModel.createClass(VitroVocabulary.PORTAL); 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 APPLICATION_THEMEDIR = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_THEMEDIR);
protected DatatypeProperty PORTAL_BANNERIMAGE = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_BANNERIMAGE); protected DatatypeProperty PORTAL_BANNERIMAGE = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_BANNERIMAGE);
//protected DatatypeProperty PORTAL_FLAG2VALUES = null; //protected DatatypeProperty PORTAL_FLAG2VALUES = null;
@ -142,40 +141,6 @@ public class JenaBaseDaoCon {
protected DatatypeProperty PORTAL_IMAGETHUMBWIDTH = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_IMAGETHUMBWIDTH); protected DatatypeProperty PORTAL_IMAGETHUMBWIDTH = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_IMAGETHUMBWIDTH);
protected DatatypeProperty PORTAL_URLPREFIX = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_URLPREFIX); 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 AnnotationProperty ONTOLOGY_PREFIX_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.ONTOLOGY_PREFIX_ANNOT);
protected OntClass FS_FILE = _constModel.createClass(VitroVocabulary.FS_FILE_CLASS); protected OntClass FS_FILE = _constModel.createClass(VitroVocabulary.FS_FILE_CLASS);

View file

@ -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<Tab> getParentTabs(Tab tab) {
return getParentTabs(DEFAULT_NAMESPACE+"tab"+tab.getTabId());
}
public List<Tab> getParentTabs(String tabURI) {
List<Tab> parentList = new ArrayList<Tab>();
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<Tab> getChildTabs(Tab tab) {
return getChildTabs(DEFAULT_NAMESPACE+"tab"+tab.getTabId());
}
public List<Tab> getChildTabs(String tabURI) {
List<Tab> childList = new ArrayList<Tab>();
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<Tab> getAllAutolinkableTabs(int portalId) {
List<Tab> tabs = new ArrayList<Tab>();
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<Tab> getAllManuallyLinkableTabs(int portalId) {
List<Tab> tabs = new LinkedList<Tab>();
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<String> getTabAutoLinkedVClassURIs(int tabId) {
List<String> typeURIs = new LinkedList<String>();
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<String> getTabManuallyLinkedEntityURIs(int tab_id) {
List<String> entityURIs = new LinkedList<String>();
TabIndividualRelationDaoJena tabToIndDao = new TabIndividualRelationDaoJena( getWebappDaoFactory() );
List<TabIndividualRelation> 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<Tab> getPrimaryTabs(int portalId){
getOntModel().enterCriticalSection(Lock.READ);
try {
List<Tab> primaryTabs = new LinkedList<Tab>();
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<Tab> filtered = new LinkedList<Tab>();
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);
}
}

View file

@ -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<TabIndividualRelation> 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<TabIndividualRelation> 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;
}
}

View file

@ -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();
}
}
}

View file

@ -36,7 +36,7 @@ import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
public class VClassGroupDaoJena extends JenaBaseDao implements VClassGroupDao { 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) { public VClassGroupDaoJena(WebappDaoFactoryJena wadf) {
super(wadf); super(wadf);

View file

@ -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.PageDao;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao; 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.UserAccountsDao;
import edu.cornell.mannlib.vitro.webapp.dao.UserDao; import edu.cornell.mannlib.vitro.webapp.dao.UserDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
@ -74,10 +71,6 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
protected LinksDao linksDao; protected LinksDao linksDao;
protected LinktypeDao linktypeDao; protected LinktypeDao linktypeDao;
protected ApplicationDaoJena applicationDao; 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 UserDao userDao; // TODO This goes away when the UserAccounts stuff is fully implemented -- jb
protected UserAccountsDao userAccountsDao; protected UserAccountsDao userAccountsDao;
protected VClassGroupDao vClassGroupDao; 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() { public VClassGroupDao getVClassGroupDao() {
if (vClassGroupDao != null) if (vClassGroupDao != null)
return vClassGroupDao; return vClassGroupDao;

View file

@ -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<Individual> _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<Individual> out = new LinkedList<Individual>();
Filter.filter(_relatedEnts, new FirstLetterFilter( alpha ), out);
return out;
}
private List getAllRelatedEnts(){
LinkedList<Individual> ents = new LinkedList<Individual>();
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;
}
}

View file

@ -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 UnaryFunctor<Individual,Boolean>onlyWithMainImage = 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 <Individual> 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 <Individual> 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<Individual,Boolean>{
@Override
public Boolean fn(Individual arg) {
return arg.getMainImageUri()!= null;
}
}
}

View file

@ -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<Individual,String> 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<Individual> 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<Individual> ents) {
Comparator<String> comp = new Comparator<String>(){
public int compare(String o1, String o2) {
return o1.compareTo(o2);
};
};
Iterable<String>i =
Unique.unique(
Sort.sort(
Transform.transform( ents ,firstLetterOfName ),
comp
)
);
ArrayList<String> out = new ArrayList<String>(26);
for( String str : i){
out.add(str);
}
return out;
}
@SuppressWarnings("serial")
class FirstLetterFilter extends UnaryFunctor<Individual,Boolean>{
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<Individual,String>{
@Override
public String fn(Individual arg) {
return arg.getName().substring(0,1).toUpperCase();
}
}
protected void removeDuplicates(List<Individual> ents ){
Collections.sort(ents, indComp);
ListIterator<Individual> 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<Individual> indComp =
new Comparator<Individual>(){
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());
}
};
}

View file

@ -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<Individual> _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<Individual> out = new LinkedList<Individual>();
Filter.filter(_allents, new FirstLetterFilter( alpha ), out);
return out;
}
private List<Individual> getAllRelatedEnts(){
getOntModel().enterCriticalSection(Lock.READ);
try {
com.hp.hpl.jena.ontology.Individual tabInd = getTabIndividual(tab);
if( tabInd == null ) return Collections.emptyList();
List<Individual> ents = new LinkedList<Individual>();
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();
}
}
}

View file

@ -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()));
}
};
}

View file

@ -145,8 +145,6 @@ public class ABoxUpdater {
// the autolinking annotation should be rewritten using the // the autolinking annotation should be rewritten using the
// new class name. // new class name.
Property autoLinkedToTab = ResourceFactory.createProperty(VitroVocabulary.TAB_AUTOLINKEDTOTAB);
StmtIterator iter = aboxModel.listStatements(oldClass, (Property) null, (RDFNode) null); StmtIterator iter = aboxModel.listStatements(oldClass, (Property) null, (RDFNode) null);
int renameCount = 0; int renameCount = 0;
@ -160,12 +158,6 @@ public class ABoxUpdater {
// This happens in cases where a class hasn't really // This happens in cases where a class hasn't really
// been removed, but we just want to map any ABox // been removed, but we just want to map any ABox
// data using it to use a different class instead. // 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 { } else {
removeCount++; removeCount++;
retractions.add(oldStatement); retractions.add(oldStatement);

View file

@ -126,12 +126,6 @@ public class TBoxUpdater {
continue; 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); NodeIterator newObjects = newTboxAnnotationsModel.listObjectsOfProperty(subject, predicate);
if ((newObjects == null) || (!newObjects.hasNext()) ) { if ((newObjects == null) || (!newObjects.hasNext()) ) {

View file

@ -197,7 +197,7 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java
log.debug("Loading initial site configuration"); log.debug("Loading initial site configuration");
essentialInterfaceData = InitialJenaModelUtils.loadInitialModel(sce.getServletContext(), defaultNamespace); essentialInterfaceData = InitialJenaModelUtils.loadInitialModel(sce.getServletContext(), defaultNamespace);
if (essentialInterfaceData.size() == 0) { if (essentialInterfaceData.size() == 0) {
essentialInterfaceData = InitialJenaModelUtils.basicPortalAndRootTab(defaultNamespace); essentialInterfaceData = InitialJenaModelUtils.basicInterfaceData(defaultNamespace);
essentialInterfaceData.add(InitialJenaModelUtils.basicClassgroup(wadf.getDefaultNamespace())); essentialInterfaceData.add(InitialJenaModelUtils.basicClassgroup(wadf.getDefaultNamespace()));
} }
//JenaModelUtils.makeClassGroupsFromRootClasses(wadf,memModel,essentialInterfaceData); //JenaModelUtils.makeClassGroupsFromRootClasses(wadf,memModel,essentialInterfaceData);

View file

@ -299,11 +299,11 @@ public class JenaDataSourceSetupSDB extends JenaDataSourceSetupBase implements j
ensureEssentialInterfaceData(unionOms.getApplicationMetadataModel(), sce, wadf); ensureEssentialInterfaceData(unionOms.getApplicationMetadataModel(), sce, wadf);
log.info("Setting up namespace mapper"); //log.info("Setting up namespace mapper");
NamespaceMapper namespaceMapper = new NamespaceMapperJena(masterUnion, masterUnion, defaultNamespace); //NamespaceMapper namespaceMapper = new NamespaceMapperJena(masterUnion, masterUnion, defaultNamespace);
ctx.setAttribute("NamespaceMapper", namespaceMapper); //ctx.setAttribute("NamespaceMapper", namespaceMapper);
unionOms.getFullModel().getBaseModel().register(namespaceMapper); //unionOms.getFullModel().getBaseModel().register(namespaceMapper);
ctx.setAttribute("defaultNamespace", defaultNamespace); ctx.setAttribute("defaultNamespace", defaultNamespace);
@ -389,10 +389,11 @@ public class JenaDataSourceSetupSDB extends JenaDataSourceSetupBase implements j
memModel.getResource(VitroVocabulary.PORTAL)); memModel.getResource(VitroVocabulary.PORTAL));
try { try {
if (!portalIt.hasNext()) { if (!portalIt.hasNext()) {
log.debug("Loading initial site configuration"); log.info("Loading initial site configuration");
essentialInterfaceData = InitialJenaModelUtils.loadInitialModel(sce.getServletContext(), defaultNamespace); essentialInterfaceData = InitialJenaModelUtils.loadInitialModel(sce.getServletContext(), defaultNamespace);
if (essentialInterfaceData.size() == 0) { 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())); essentialInterfaceData.add(InitialJenaModelUtils.basicClassgroup(wadf.getDefaultNamespace()));
} }
//JenaModelUtils.makeClassGroupsFromRootClasses(wadf,memModel,essentialInterfaceData); //JenaModelUtils.makeClassGroupsFromRootClasses(wadf,memModel,essentialInterfaceData);
@ -507,7 +508,6 @@ public class JenaDataSourceSetupSDB extends JenaDataSourceSetupBase implements j
String amdQuery = "DESCRIBE ?x WHERE { " + String amdQuery = "DESCRIBE ?x WHERE { " +
"{?x a <" + VitroVocabulary.PORTAL +"> } UNION " + "{?x a <" + VitroVocabulary.PORTAL +"> } UNION " +
"{?x a <" + VitroVocabulary.TAB +"> } UNION " +
"{?x a <" + VitroVocabulary.PROPERTYGROUP +"> } UNION " + "{?x a <" + VitroVocabulary.PROPERTYGROUP +"> } UNION " +
"{?x a <" + VitroVocabulary.CLASSGROUP +"> } } "; "{?x a <" + VitroVocabulary.CLASSGROUP +"> } } ";

View file

@ -68,34 +68,14 @@ public class InitialJenaModelUtils {
ResourceUtils.renameResource(portalResource, defaultNamespace + "portal1"); ResourceUtils.renameResource(portalResource, defaultNamespace + "portal1");
} }
//rename tabs
List<AnonId> tabIds = new ArrayList<AnonId>();
Iterator<Resource> 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; return initialModel;
} }
public static Model basicPortalAndRootTab(String defaultNamespace) { public static Model basicInterfaceData(String defaultNamespace) {
OntModel essentialInterfaceData = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); OntModel essentialInterfaceData = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
Resource portalClass = essentialInterfaceData.getResource(VitroVocabulary.PORTAL); Resource portalClass = essentialInterfaceData.getResource(VitroVocabulary.PORTAL);
Property themeDirProperty = essentialInterfaceData.getProperty(VitroVocabulary.PORTAL_THEMEDIR); 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); Individual portal1 = essentialInterfaceData.createIndividual(defaultNamespace+"portal1",portalClass);
String defaultThemeStr = ApplicationBean.DEFAULT_THEME_DIR_FROM_CONTEXT; String defaultThemeStr = ApplicationBean.DEFAULT_THEME_DIR_FROM_CONTEXT;
if (defaultThemeStr == null) { if (defaultThemeStr == null) {
@ -103,12 +83,6 @@ public class InitialJenaModelUtils {
} }
portal1.setPropertyValue(themeDirProperty,ResourceFactory.createPlainLiteral(defaultThemeStr)); portal1.setPropertyValue(themeDirProperty,ResourceFactory.createPlainLiteral(defaultThemeStr));
portal1.setLabel("New Vitro Portal", null); 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);
return essentialInterfaceData; return essentialInterfaceData;
} }

View file

@ -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 = " &gt; ";
/**
* 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 = "<div class='breadCrumbs'> ";
try {
String label = null, spacer = null;
int tabId = TabWebUtil.getTabIdFromRequest(request); // has to be able to find a portal to get a tab id if none in request
int rootId = TabWebUtil.getRootTabId(request); // also has to be able to find a portal to get a root tab is if none in request
int depth = 0;
// this is a third, final shot at getting a populated portal if none was in the request
ApplicationBean application = vreq.getAppBean();
//get the "RootBreadCrumb" if there is one
ret += getRootBreadCrumb(vreq, separator, application);
List chain = vreq.getWebappDaoFactory().getTabDao().getTabHierarchy(tabId,rootId);
for(int i=0; i<chain.size(); i++){
Integer id = (Integer)chain.get(i);
if( rootId == id.intValue() ){
depth = TabWebUtil.PRIMARY;
spacer = "";
} else {
depth = i-1;
label = null;
spacer = separator;
}
ret += spacer + makeBreadCrumbElement(vreq,id.intValue(),depth,label);
}
} catch (Throwable t) {
t.printStackTrace();
}
return ret + " </div>";
}
/**
* gets the root bread crumb from portal bean
* @param req
* @return
*/
public static String getRootBreadCrumb(VitroRequest vreq,String spacer,ApplicationBean application){
String crumb = "";
if (application==null){
log.error("getRootBreadCrumb() was passed a null portal");
} else if (application.getRootBreadCrumbURL() != null &&
application.getRootBreadCrumbAnchor() != null) {
spacer = (spacer == null)? "": spacer;
crumb="<a href='"+application.getRootBreadCrumbURL()
+ "' > " + application.getRootBreadCrumbAnchor() + "</a>"
+ spacer;
}
return crumb;
}
// if (portalBean.getRootBreadCrumbURL() != null && !portalBean.getRootBreadCrumbURL().equals("") && !portalBean.getRootBreadCrumbURL().equals("&nbsp;")) { %>
// <a href="<%=portalBean.getRootBreadCrumbURL()%>"><%=portalBean.getRootBreadCrumbAnchor()%></a>
// <%
// } else { %>
// <a href="index.jsp?home=<%=portalBean.getPortalId()%>"><%=portalBean.getAppName()%></a>
/**
* *******************************************************
* @param req
* @param tabId
* @param depth
* @param label, should be null but if not, then use as label
* @return
*/
private static String makeBreadCrumbElement(VitroRequest vreq, int tabId, int depth, String label){
if( depth < 0 )
depth = 0;
String href = "index.jsp?"+TabWebUtil.tabDepthNames[depth]+"="+tabId;
label = (label == null) ? vreq.getWebappDaoFactory().getTabDao().getNameForTabId(tabId) : label;
return "<a href='"+href+"'>"+label+"</a>";
}
}

View file

@ -1,165 +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.HashSet;
import java.util.Iterator;
import java.util.List;
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;
/**
* Intended to generate the hierarchal tab menu.
*
*/
public class TabMenu {
private static final Log log = LogFactory.getLog(TabMenu.class.getName());
//we got lists, we got tables, take your pick.
static String itemOpen ="<li>", itemClose="</li>\n";
static String itemOpenActive ="<li class=\"activePrimaryTab\">";
static String secondaryItemOpen ="<td>", secondaryItemClose="</td>\n";
static String secondaryItemOpenActive ="<td class=\"activeSecondaryTab\">";
static String primaryOpen="<ul id=\"primary\">\n", primaryClose="</ul>\n";
// static String secondaryOpen="<ul id=\"secondary\">\n", secondaryClose="</ul>\n";
// static String itemOpen ="<td>", itemClose="</td>\n";
// static String primaryOpen="<table id='primary'><tr>\n", primaryClose="</tr></table>";
static String secondaryOpen="<table id=\"secondary\"><tr>\n", secondaryClose="</tr></table>";
static String primaryActiveClass = "activePrimaryTab";
static String secondaryActiveClass ="activeSecondaryTab";
static final int DEFAULT_PORTAL_ID = 1;
static final int DEFAULT_ROOT_TAB_ID = 1;
/**
* The is the method you should call to get an html element for the
* tab menu of a page. There must be a better way to do this, call
* out to a jsp? some kind of template? For now the goal is to consolidate
* the point of creation of the menu so that all code uses the same
* method and we can improve it later.
*
* @param req - needs to have the Attribute "portalBean"
* @return
*/
public static String getPrimaryTabMenu(VitroRequest vreq){
String ret = primaryOpen;
String label = null;
try {
int portalId = DEFAULT_PORTAL_ID;
List primaryTabs = vreq.getWebappDaoFactory().getTabDao().getPrimaryTabs(portalId);
if (primaryTabs != null) {
Iterator itPrime = primaryTabs.iterator();
while( itPrime.hasNext() ){
Tab tab = (Tab) itPrime.next();
boolean active = isTabActive(vreq, tab.getTabId());
boolean isRootTab = false;
//are we at the root tab for the portal?
isRootTab = (tab.getTabId() == DEFAULT_ROOT_TAB_ID);
label = isRootTab?"Home":null;
ret += "\t";
if (active) {
ret += itemOpenActive;
ret += TabWebUtil.tab2TabAnchorElement(tab, vreq,
TabWebUtil.PRIMARY, primaryActiveClass, label, portalId)
+ "\t" + itemClose;
}
else {
ret += itemOpen;
ret += TabWebUtil.tab2TabAnchorElement(tab, vreq,
TabWebUtil.PRIMARY, null, label, portalId)
+ "\t" + itemClose;
}
}
}
} catch (Throwable t) {
t.printStackTrace();
}
return ret + primaryClose;
}
/**
* Gets secondary tabs for tab menu.
* @param req
* @return
*/
public static String getSecondaryTabMenu(VitroRequest vreq){
try {
List pathToRoot = getTabsAboveCurrent(vreq);
int primaryTabId = -1;
if( pathToRoot != null && pathToRoot.size() > 0 ){
primaryTabId = ((Integer)pathToRoot.get(0)).intValue();
} else {
primaryTabId = DEFAULT_ROOT_TAB_ID;
}
return getSecondaryTabMenu(vreq,primaryTabId);
} catch (Throwable t) {
t.printStackTrace();
return "";
}
}
private static String getSecondaryTabMenu(VitroRequest vreq, int primaryTabId){
try {
int portalId = DEFAULT_PORTAL_ID;
String ret="";
List secondaryTabs = vreq.getWebappDaoFactory().getTabDao().getSecondaryTabs( primaryTabId );
if (secondaryTabs != null && secondaryTabs.size()>0){
ret += secondaryOpen;
Iterator it = secondaryTabs.iterator();
while( it.hasNext() ){
Tab tab = (Tab) it.next();
boolean active = isTabActive(vreq, tab.getTabId());
ret += "\t";
if (active) {
ret += secondaryItemOpen;
ret += TabWebUtil.tab2TabAnchorElement(tab,vreq,TabWebUtil.SECONDARY,secondaryActiveClass,null,portalId)+secondaryItemClose;
}
else {
ret += secondaryItemOpen;
ret += TabWebUtil.tab2TabAnchorElement(tab,vreq,TabWebUtil.SECONDARY,null,null,portalId)+secondaryItemClose;
}
}
ret += secondaryClose;
}
return ret;
} catch (Throwable t) {
t.printStackTrace();
return "";
}
}
/**
* A tab is active is it is the current tab, or it is a broader tab.
* Currently this uses getTabsAboveCurrent() which queries the db
* for the tab hierarchy above the current tab. This assumes that
* all tabs have only one broaded tab.
*
* @param req
* @param tabInQuestion
*/
public static boolean isTabActive(VitroRequest vreq, int tabInQuestion){
int current = TabWebUtil.getTabIdFromRequest(vreq);
if( current == tabInQuestion ) return true;
List above = getTabsAboveCurrent(vreq);
if( above != null && above.size() > 0 ){
HashSet set = new HashSet( above );
return set.contains(new Integer( tabInQuestion ));
} else
return false;
}
private static List getTabsAboveCurrent( VitroRequest vreq){
List above = (List)vreq.getAttribute("tabsAboveCurrent");
if( above == null ){
int currentTab = TabWebUtil.getTabIdFromRequest(vreq);
above = vreq.getWebappDaoFactory().getTabDao().getTabHierarchy(currentTab, -1);
vreq.setAttribute("tabsAboveCurrent", above);
}
return above;
}
}

View file

@ -1,241 +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.Collection;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import org.apache.commons.lang.StringEscapeUtils;
import edu.cornell.mannlib.vitro.webapp.beans.Tab;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
/**
* This is a collecton of method that deal tabs and
* how they are used on jsp's and in servlets.
* NOTE 0 is an invalid tab id, there should never be a tab 0;
* -1 is also an invalid tab id.
*
* @author bdc34
*/
public class TabWebUtil {
final static int ROOT_TAB_ID = 1;
static String [] tabDepthNames =
{"primary","secondary","collection","subcollection","more"};
static int PRIMARY =0;
static int SECONDARY=1;
static int COLLECTION=2;
static int SUBCOLLECTION=3;
static int MORE=4;
//some values from index.jsp
final static boolean FILTER_BY_PORTAL = true;
final static int TAB_FILTER_FLAG2 = 2; // see beans.Tab
final static int TAB_FILTER_FLAG3 = 3; // see beans.Tab
final static int TAB_FILTER_FLAG_BOTH = 5; // see beans.Tab
final static int DEFAULT_ROOT_TAB_ID = 1;
private static int getPrimaryTabIdFromRequest(HttpServletRequest request){
return getNdepthTabId(request,tabDepthNames[PRIMARY],0);
}
private static int getSecondaryTabIdFromRequest(HttpServletRequest request){
return getNdepthTabId(request,tabDepthNames[SECONDARY],0);
}
private static int getCollectionTabIdFromRequest(HttpServletRequest request){
return getNdepthTabId(request,tabDepthNames[COLLECTION],0);
}
private static int getSubcollectionTabIdFromRequest(HttpServletRequest request){
return getNdepthTabId(request,tabDepthNames[SUBCOLLECTION],0);
}
private static int getMoreTabIdFromRequest(HttpServletRequest request){
return getNdepthTabId(request,tabDepthNames[MORE],0);
}
public static void tabPrep(HttpServletRequest request){
//this will do all the legwork for getting ready to work with tabs
//and stick the values into the request
getTabIdFromRequest(request);
}
/**
*
* @param req
* @author jc55
* @return
*/
public static int getTabIdFromRequest(HttpServletRequest request){
// JCR 20050827 will convert so only one incoming tab id is necessary but may need
// to support this on a legacy basis and until that is working correctly
// BUT probably can't do this since tabs can have multiple parents and can't
// necessarily determine the user's path to the tab from the tab alone
Object obj = request.getAttribute("currentTabId") ;
Integer value = (Integer)obj;
if( value != null )
return value.intValue();
int depth = 0;
int leadingTabId=0; //0 is an invalid tab id, there should never be a tab 0;
int incomingMoreId = getMoreTabIdFromRequest(request);
if (incomingMoreId>0) {
leadingTabId=incomingMoreId;
depth = MORE;
} else {
int incomingSubCollectionId = getSubcollectionTabIdFromRequest(request);
if (incomingSubCollectionId>0) {
leadingTabId=incomingSubCollectionId;
depth = SUBCOLLECTION;
} else {
int incomingCollectionId = getCollectionTabIdFromRequest(request);
if (incomingCollectionId>0) {
leadingTabId=incomingCollectionId;
depth = COLLECTION;
} else {
int incomingSecondaryTabId = getSecondaryTabIdFromRequest(request);
if (incomingSecondaryTabId>0) {
leadingTabId=incomingSecondaryTabId;
depth = SECONDARY;
} else {
int incomingPrimaryTabId = getPrimaryTabIdFromRequest(request);
if (incomingPrimaryTabId>0) {
leadingTabId=incomingPrimaryTabId;
depth = PRIMARY;
} else {
leadingTabId= getRootTabId(request);
depth = PRIMARY;
}
}
}
}
}
request.setAttribute("currentTabDepth", new Integer(depth));
request.setAttribute("currentTabId",new Integer(leadingTabId));
return leadingTabId;
}
public static int getRootTabId(HttpServletRequest request){
VitroRequest vreq = new VitroRequest(request);
return DEFAULT_ROOT_TAB_ID;
}
public final static String STASHED_KEY="stashTabsInRequestCalled";
/**
* puts pointers to Tab objects in request with names like
* tab233 where the 233 is from TabBean.getTabId.
* LeadingTab will be stashed also.
*/
public static void stashTabsInRequest(Tab leadingTab, HttpServletRequest request)
throws JspException{
if(leadingTab == null){
String e="attempt to call TabWebUtil.stashTabsInRequest() with null leadingTab";
throw new JspException(e);
}
if(request == null){
String e="attempt to call TabWebUtil.stashTabsInRequest() with null req";
throw new JspException(e);
}
request.setAttribute( STASHED_KEY ,new Boolean(true));
stashTabInReq(leadingTab,request); //stash leading tab
Collection children = leadingTab.getChildTabs();
if( children == null ) return;
Iterator it = leadingTab.getChildTabs().iterator();
while( it.hasNext() ){
Tab tab = (Tab)it.next();
stashTabInReq(tab,request);
}
}
private static void stashTabInReq(Tab tab, HttpServletRequest request){
request.setAttribute("tab"+String.valueOf(tab.getTabId()),tab);
}
/**
* Get a TabBean that was placed in the Request by stashTabsInRequestCalled().
* @param tabId
* @param req
* @return
* @throws JspException
*/
public static Tab findStashedTab( String tabId, HttpServletRequest request)
throws JspException{
if( request == null )
throw new JspException("findStashedTab: request was null");
if( request.getAttribute(STASHED_KEY) == null )
throw new JspException("findStashedTab: called before stashTabsInRequest.");
if( tabId == null)
throw new JspException("findStashedTab: tabId was null");
Object obj = request.getAttribute("tab"+tabId);
if( obj == null )
throw new JspException("findStashedTab: tab"+tabId+" not found in vitro request");
if(!( obj instanceof Tab ))
throw new JspException("findStashedTab: tab"+tabId+" was not a TabBean class"+
obj.getClass().getName());
return (Tab)obj;
}
/**
* Makes an anchor/link HTML element for the tab menu tag for the given tab.
*
* @param tab object to make a element for
* @param req
* @param depth the depth of the tab - see TabWebUtil.tabDepthNames
* @param active - if true set CSS class as active
* @param label - if not null, label overrides the tab.name
* @param portalId - ID of the current portal in session
* @return a HTML tag for the tab menu.
*/
public static String tab2TabAnchorElement(Tab tab, HttpServletRequest req,
int depth, String clazz, String label, int portalId){
// int incomingPrimaryTabId = TabWebUtil.getPrimaryTabIdFromRequest(vreq);
String tooltipStr = tab.getDescription();
String cls=""; //this is the class='activeTab' for css use
String title = "";
String context = req.getContextPath();
if (clazz != null)
cls="class=\""+clazz+"\"";
if (tooltipStr!=null && !tooltipStr.equals("") && !tooltipStr.equals("&nbsp;")) {
title = " title=\""+tooltipStr+"\"";
}
String anchor = label != null ? label : tab.getTitle();
String tabIdParam = tabDepthNames[depth] + "=" + tab.getTabId();
String href="'" + context + "/index.jsp?home=" + portalId + "&amp;" + tabIdParam + "'";
return "<a "+cls+title+" href="+href+">"+StringEscapeUtils.escapeXml(anchor)+"</a>";
}
/**
* Used for parsing primary,secondary,etc parameters.
* @param req
* @param parameterName
* @param defaultId
* @return
*/
private static int getNdepthTabId(HttpServletRequest request, String parameterName, int defaultId ){
VitroRequest vreq=null;
if (request instanceof VitroRequest) {
vreq = (VitroRequest)request;
} else {
vreq = new VitroRequest(request);
}
// in the future when a tab has a URI, not just an id, we will want the URI
// to be passed through a VitroRequest because of character set issues
String idStr = vreq.getParameter(parameterName);
int theId = defaultId;
if ( idStr != null && !idStr.equals("") )
try{
theId = Integer.parseInt( idStr );
}catch(Throwable th) {}
return theId;
}
}

View file

@ -1,72 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.menu;
import java.util.Iterator;
import java.util.List;
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.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
import edu.cornell.mannlib.vitro.webapp.web.TabWebUtil;
/** A main menu constructed from persisted tab data
*
* @author rjy7
*
*/
public class TabMenu extends MainMenu {
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(TabMenu.class.getName());
private static String TAB_PARAM = "primary";
private static String PATH = "/index.jsp";
private static int ROOT_TAB_ID = 1;
public TabMenu(VitroRequest vreq, int portalId) {
super(vreq);
//Tabs stored in database
List<Tab> primaryTabs = vreq.getWebappDaoFactory().getTabDao().getPrimaryTabs(portalId);
int tabId = TabWebUtil.getTabIdFromRequest(vreq);
int rootId = TabWebUtil.getRootTabId(vreq);
List tabLevels = vreq.getWebappDaoFactory().getTabDao().getTabHierarchy(tabId,rootId);
vreq.setAttribute("tabLevels", tabLevels);
Iterator<Tab> primaryTabIterator = primaryTabs.iterator();
//Iterator tabLevelIterator = tabLevels.iterator();
Tab tab;
while (primaryTabIterator.hasNext()) {
tab = (Tab) primaryTabIterator.next();
addItem(tab);
// RY Also need to loop through nested tab levels, but not doing that now.
}
// Hard-coded tabs. It's not a good idea to have these here, since any menu item that doesn't
// come from the db should be accessible to the template to change the text. But we need them here
// (rather than adding directly from the template) to apply the "active" mechanism.
addItem("Index", "/browse");
}
private void addItem(Tab tab) {
boolean isActive = isActiveItem(tab);
String text = tab.getTitle();
String path = UrlBuilder.getPath(PATH, new ParamMap(TAB_PARAM, "" + tab.getTabId()));
addItem(text, path, isActive);
}
private boolean isActiveItem(Tab tab) {
String requestedTabId = vreq.getParameter(TAB_PARAM);
int tabId = tab.getTabId();
if (requestedTabId == null) {
return tabId == ROOT_TAB_ID && "true".equals(vreq.getAttribute("homePageRequested"));
} else {
return Integer.parseInt(requestedTabId) == tabId;
}
}
}

View file

@ -13,121 +13,119 @@ import org.junit.Assert;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl; import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
import edu.cornell.mannlib.vitro.webapp.beans.Tab;
public class FiltersTest { public class FiltersTest {
Boolean ACCEPTED = Boolean.TRUE; Boolean ACCEPTED = Boolean.TRUE;
Boolean REJECTED = Boolean.FALSE; Boolean REJECTED = Boolean.FALSE;
@Before // @Before
public void setUp() throws Exception { // public void setUp() throws Exception {
} // }
@Test @Test
public void testTimeFiltersForFutureEvents(){ public void testTimeFiltersForFutureEvents(){
Tab tab = new Tab(); // Tab tab = new Tab();
tab.setDayLimit( 10 ); // tab.setDayLimit( 10 );
UnaryFunctor<Individual,Boolean> filter = // UnaryFunctor<Individual,Boolean> filter =
FiltersForTabs.getTimeFilter(tab, new DateTime()); // FiltersForTabs.getTimeFilter(tab, new DateTime());
//
Individual ind = new IndividualImpl(); // Individual ind = new IndividualImpl();
DateTime timekey; // DateTime timekey;
//
// Allow a slight fudge factor for the time it takes the tests to run. // // Allow a slight fudge factor for the time it takes the tests to run.
DateTime now = new DateTime().plusSeconds(1); // DateTime now = new DateTime().plusSeconds(1);
//
for(int i=1; i < 100 ; i++){ // for(int i=1; i < 100 ; i++){
timekey = now.minusDays(i); // timekey = now.minusDays(i);
ind.setTimekey( timekey.toDate() ); // ind.setTimekey( timekey.toDate() );
Assert.assertTrue("minus " + i + " days should Reject", // Assert.assertTrue("minus " + i + " days should Reject",
filter.fn( ind ) == REJECTED); // filter.fn( ind ) == REJECTED);
// }
//
// for(int i=0; i< 10 ; i++){
// timekey = now.plusDays(i);
// ind.setTimekey( timekey.toDate() );
// Assert.assertTrue("plus " + i + " days should Accept",
// filter.fn( ind ) == ACCEPTED);
// }
//
// timekey = now.plusDays( 10 );
// ind.setTimekey( timekey.toDate() );
// Assert.assertTrue("plus 10 days should Reject",
// filter.fn( ind ) == REJECTED);
//
// for(int i=10; i < 1000 ; i++){
// timekey = now.plusDays(i);
// ind.setTimekey( timekey.toDate() );
// Assert.assertTrue("plus " + i + " days should Reject",
// filter.fn( ind ) == REJECTED);
// }
} }
for(int i=0; i< 10 ; i++){ // @Test
timekey = now.plusDays(i); // public void testTimeFiltersForPastReleases(){
ind.setTimekey( timekey.toDate() ); // Tab tab = new Tab();
Assert.assertTrue("plus " + i + " days should Accept", // tab.setDayLimit( -10 );
filter.fn( ind ) == ACCEPTED); // UnaryFunctor<Individual,Boolean> filter =
} // FiltersForTabs.getTimeFilter(tab, new DateTime());
//
timekey = now.plusDays( 10 ); // Individual ind = new IndividualImpl();
ind.setTimekey( timekey.toDate() ); // DateTime sunrise;
Assert.assertTrue("plus 10 days should Reject", //
filter.fn( ind ) == REJECTED); // // Allow a slight fudge factor for the time it takes the tests to run.
// DateTime now = new DateTime().plusSeconds(1);
for(int i=10; i < 1000 ; i++){ //
timekey = now.plusDays(i); // for(int i=1; i < 1000 ; i++){
ind.setTimekey( timekey.toDate() ); // sunrise = now.plusDays(i);
Assert.assertTrue("plus " + i + " days should Reject", // ind.setSunrise( sunrise.toDate() );
filter.fn( ind ) == REJECTED); // Assert.assertTrue("plus " + i + " days should Reject",
} // filter.fn( ind ) == REJECTED);
} // }
//
@Test // ind.setSunrise( now.minusMinutes(20).toDate() );
public void testTimeFiltersForPastReleases(){ // Assert.assertTrue("minus 20 minutes should Accept",
Tab tab = new Tab(); // filter.fn( ind ) == ACCEPTED);
tab.setDayLimit( -10 ); //
UnaryFunctor<Individual,Boolean> filter = // for(int i=1; i <= 10 ; i++){
FiltersForTabs.getTimeFilter(tab, new DateTime()); // sunrise = now.minusDays(i);
// ind.setSunrise( sunrise.toDate() );
Individual ind = new IndividualImpl(); // Assert.assertTrue("minus " + i + " days should Accept",
DateTime sunrise; // filter.fn( ind ) == ACCEPTED);
// }
// Allow a slight fudge factor for the time it takes the tests to run. //
DateTime now = new DateTime().plusSeconds(1); // for(int i=11; i < 100 ; i++){
// sunrise = now.minusDays(i);
for(int i=1; i < 1000 ; i++){ // ind.setSunrise( sunrise.toDate() );
sunrise = now.plusDays(i); // Assert.assertTrue("minus " + i + " days should Reject",
ind.setSunrise( sunrise.toDate() ); // filter.fn( ind ) == REJECTED);
Assert.assertTrue("plus " + i + " days should Reject", // }
filter.fn( ind ) == REJECTED); // }
} //
// @Test
ind.setSunrise( now.minusMinutes(20).toDate() ); // public void testMarkowitzCase(){
Assert.assertTrue("minus 20 minutes should Accept", // DateTime now = new DateTime().withTime(0, 0, 0, 0);
filter.fn( ind ) == ACCEPTED); // Date sunrise = now.minusDays(1).toDate();
// Date timeKey = now.plusDays(2).toDate();
for(int i=1; i <= 10 ; i++){ //
sunrise = now.minusDays(i); // Tab tab = new Tab();
ind.setSunrise( sunrise.toDate() ); // tab.setDayLimit( -10 );
Assert.assertTrue("minus " + i + " days should Accept", // UnaryFunctor<Individual,Boolean> filter =
filter.fn( ind ) == ACCEPTED); // FiltersForTabs.getTimeFilter(tab, new DateTime());
} //
// Individual ind = new IndividualImpl();
for(int i=11; i < 100 ; i++){ // ind.setSunrise( sunrise );
sunrise = now.minusDays(i); // ind.setTimekey( timeKey );
ind.setSunrise( sunrise.toDate() ); //
Assert.assertTrue("minus " + i + " days should Reject", // Assert.assertTrue("Should accept with day limit -10",
filter.fn( ind ) == REJECTED); // filter.fn( ind ) == ACCEPTED);
} //
} // tab.setDayLimit( 10 );
// filter = FiltersForTabs.getTimeFilter(tab, new DateTime());
@Test //
public void testMarkowitzCase(){ // Assert.assertTrue("Should accept with day limit +10",
DateTime now = new DateTime().withTime(0, 0, 0, 0); // filter.fn( ind ) == ACCEPTED );
Date sunrise = now.minusDays(1).toDate(); // }
Date timeKey = now.plusDays(2).toDate();
Tab tab = new Tab();
tab.setDayLimit( -10 );
UnaryFunctor<Individual,Boolean> filter =
FiltersForTabs.getTimeFilter(tab, new DateTime());
Individual ind = new IndividualImpl();
ind.setSunrise( sunrise );
ind.setTimekey( timeKey );
Assert.assertTrue("Should accept with day limit -10",
filter.fn( ind ) == ACCEPTED);
tab.setDayLimit( 10 );
filter = FiltersForTabs.getTimeFilter(tab, new DateTime());
Assert.assertTrue("Should accept with day limit +10",
filter.fn( ind ) == ACCEPTED );
}
} }

View file

@ -28,150 +28,150 @@ public class VitroFiltersFactoryTest {
public void setUp() throws Exception { public void setUp() throws Exception {
} }
@Test // @Test
public void testSunsetWindowFilterOnListOfEnts() { // public void testSunsetWindowFilterOnListOfEnts() {
DateTime easyDate = new org.joda.time.DateTime(2005,1,1,0,0,0,0); //2005-01-01 // DateTime easyDate = new org.joda.time.DateTime(2005,1,1,0,0,0,0); //2005-01-01
Date givenDate = easyDate.toDate(); // Date givenDate = easyDate.toDate();
//
// VitroFilters vf = FiltersForTabs.getSunsetWindowFilter(givenDate);
// Assert.assertNotNull(vf);
// checkFilterForNull(vf);
//
// List<Individual> ents = new LinkedList();
// for( int i = 0; i< 10; i++){
// Individual ent = new IndividualImpl();
// ent.setSunrise( null );
// ent.setSunset( null );
// ents.add(ent);
// }
//
// BaseFiltering bf = new BaseFiltering();
// List filtered = bf.filter(ents,vf.getIndividualFilter());
// Assert.assertNotNull(filtered);
// Assert.assertTrue("expcted to filter no entities, filtered out " + (10-filtered.size()),
// filtered.size() == 10);
//
// Individual ent = new IndividualImpl();
// ent.setSunrise( easyDate.minusDays(3).toDate() );
// ent.setSunset( easyDate.plusDays(3).toDate() );
// ents.add(ent);
//
// filtered = bf.filter(ents,vf.getIndividualFilter());
// Assert.assertNotNull(filtered);
// Assert.assertTrue("expcted to filter no entities, filtered out " + (11-filtered.size()),
// filtered.size() == 11);
//
// ent = new IndividualImpl();
// ent.setSunrise( easyDate.minusDays(100).toDate() );
// ent.setSunset( easyDate.minusDays(110).toDate() );
// ents.add(ent);
//
// filtered = bf.filter(ents,vf.getIndividualFilter());
// Assert.assertNotNull(filtered);
// Assert.assertTrue("expcted to filter one entity, filtered out " + (12-filtered.size()),
// filtered.size() == 11);
//
// long count = Summarize.count(ents,vf.getIndividualFilter());
// Assert.assertTrue("expected 12, got " + ents.size(), ents.size() == 12);
// Assert.assertTrue("expected count of 11, got " + count , count == 11);
//
// long a = 20000;
// int b = (int)a;
// Assert.assertTrue( b == 20000);
// }
VitroFilters vf = FiltersForTabs.getSunsetWindowFilter(givenDate); // @Test
Assert.assertNotNull(vf); // public void testGetSunsetWindowFilter() {
checkFilterForNull(vf); // DateTime easyDate = new org.joda.time.DateTime(2005,1,1,0,0,0,0); //2005-01-01
// Date givenDate = easyDate.toDate();
List<Individual> ents = new LinkedList(); //
for( int i = 0; i< 10; i++){ // VitroFilters vf = FiltersForTabs.getSunsetWindowFilter(givenDate);
Individual ent = new IndividualImpl(); // Assert.assertNotNull(vf);
ent.setSunrise( null ); // checkFilterForNull(vf);
ent.setSunset( null ); //
ents.add(ent); // Individual ent = new IndividualImpl();
} // ent.setSunrise( easyDate.minusDays(3).toDate() );
// ent.setSunset( easyDate.plusDays(3).toDate() );
BaseFiltering bf = new BaseFiltering(); // Assert.assertTrue(vf.getIndividualFilter().fn( ent ) );
List filtered = bf.filter(ents,vf.getIndividualFilter()); //
Assert.assertNotNull(filtered); // ent.setSunrise( easyDate.toDate() );
Assert.assertTrue("expcted to filter no entities, filtered out " + (10-filtered.size()), // Assert.assertTrue("items should be not filtered on first sunrise day", vf.getIndividualFilter().fn(ent));
filtered.size() == 10); //
// ent.setSunrise( easyDate.minusDays(3).toDate() );
Individual ent = new IndividualImpl(); // ent.setSunset( easyDate.minusDays( 2 ).toDate() );
ent.setSunrise( easyDate.minusDays(3).toDate() ); // Assert.assertFalse("should be sunset and filtered out", vf.getIndividualFilter().fn( ent ));
ent.setSunset( easyDate.plusDays(3).toDate() ); //
ents.add(ent); // ent.setSunrise( easyDate.plusDays(3).toDate() );
// ent.setSunset( easyDate.plusDays( 10 ).toDate() );
filtered = bf.filter(ents,vf.getIndividualFilter()); // Assert.assertFalse("should not yet be sunrised and filtered out", vf.getIndividualFilter().fn( ent ));
Assert.assertNotNull(filtered); //
Assert.assertTrue("expcted to filter no entities, filtered out " + (11-filtered.size()), // ent.setSunrise( null );
filtered.size() == 11); // ent.setSunset( null );
// Assert.assertTrue("nulls should not throw exceptions and and not be filtered out", vf.getIndividualFilter().fn( ent ));
ent = new IndividualImpl(); //
ent.setSunrise( easyDate.minusDays(100).toDate() ); // //should work with webapp too
ent.setSunset( easyDate.minusDays(110).toDate() ); // Individual entwa = new IndividualImpl();
ents.add(ent); // entwa.setSunrise( easyDate.minusDays(3).toDate() );
// entwa.setSunset( easyDate.plusDays(3).toDate() );
filtered = bf.filter(ents,vf.getIndividualFilter()); // Assert.assertTrue(vf.getIndividualFilter().fn( entwa ) );
Assert.assertNotNull(filtered); //
Assert.assertTrue("expcted to filter one entity, filtered out " + (12-filtered.size()), // entwa.setSunrise( easyDate.toDate() );
filtered.size() == 11); // Assert.assertTrue("items should be not filtered on first sunrise day", vf.getIndividualFilter().fn(entwa));
//
long count = Summarize.count(ents,vf.getIndividualFilter()); // entwa.setSunrise( easyDate.minusDays(3).toDate() );
Assert.assertTrue("expected 12, got " + ents.size(), ents.size() == 12); // entwa.setSunset( easyDate.minusDays( 2 ).toDate() );
Assert.assertTrue("expected count of 11, got " + count , count == 11); // Assert.assertFalse("should be sunset and filtered out", vf.getIndividualFilter().fn( entwa ));
//
long a = 20000; // entwa.setSunrise( easyDate.plusDays(3).toDate() );
int b = (int)a; // entwa.setSunset( easyDate.plusDays( 10 ).toDate() );
Assert.assertTrue( b == 20000); // Assert.assertFalse("should not yet be sunrised and filtered out", vf.getIndividualFilter().fn( entwa ));
} //
// entwa.setSunrise( null );
@Test // entwa.setSunset( null );
public void testGetSunsetWindowFilter() { // Assert.assertTrue("null should not throw exceptions and should not be filtered out", vf.getIndividualFilter().fn( entwa ));
DateTime easyDate = new org.joda.time.DateTime(2005,1,1,0,0,0,0); //2005-01-01 //
Date givenDate = easyDate.toDate(); // //ObjectPropertyStatements
// ObjectPropertyStatement ops = new ObjectPropertyStatementImpl();
VitroFilters vf = FiltersForTabs.getSunsetWindowFilter(givenDate); // ops.setObject(entwa);
Assert.assertNotNull(vf); //
checkFilterForNull(vf); // entwa.setSunrise( easyDate.minusDays(3).toDate() );
// entwa.setSunset( easyDate.plusDays(3).toDate() );
Individual ent = new IndividualImpl(); // Assert.assertTrue(vf.getIndividualFilter().fn( entwa ) );
ent.setSunrise( easyDate.minusDays(3).toDate() ); //
ent.setSunset( easyDate.plusDays(3).toDate() ); // entwa.setSunrise( easyDate.toDate() );
Assert.assertTrue(vf.getIndividualFilter().fn( ent ) ); // Assert.assertTrue("items should be not filtered on first sunrise day", vf.getObjectPropertyStatementFilter().fn(ops));
//
ent.setSunrise( easyDate.toDate() ); // entwa.setSunrise( easyDate.minusDays(3).toDate() );
Assert.assertTrue("items should be not filtered on first sunrise day", vf.getIndividualFilter().fn(ent)); // entwa.setSunset( easyDate.minusDays( 2 ).toDate() );
// Assert.assertFalse("should be sunset and filtered out", vf.getObjectPropertyStatementFilter().fn(ops));
ent.setSunrise( easyDate.minusDays(3).toDate() ); //
ent.setSunset( easyDate.minusDays( 2 ).toDate() ); // entwa.setSunrise( easyDate.plusDays(3).toDate() );
Assert.assertFalse("should be sunset and filtered out", vf.getIndividualFilter().fn( ent )); // entwa.setSunset( easyDate.plusDays( 10 ).toDate() );
// Assert.assertFalse("should not yet be sunrised and filtered out", vf.getObjectPropertyStatementFilter().fn(ops));
ent.setSunrise( easyDate.plusDays(3).toDate() ); //
ent.setSunset( easyDate.plusDays( 10 ).toDate() ); // entwa.setSunrise( null );
Assert.assertFalse("should not yet be sunrised and filtered out", vf.getIndividualFilter().fn( ent )); // entwa.setSunset( null );
// Assert.assertTrue("null should not throw exceptions and should not be filtered out", vf.getObjectPropertyStatementFilter().fn(ops));
ent.setSunrise( null ); //
ent.setSunset( null ); // ops.setSunrise( null );
Assert.assertTrue("nulls should not throw exceptions and and not be filtered out", vf.getIndividualFilter().fn( ent )); // ops.setSunset( null );
// Assert.assertTrue("null should not throw exceptions and should not be filtered out", vf.getObjectPropertyStatementFilter().fn( ops ) );
//should work with webapp too //
Individual entwa = new IndividualImpl(); // //DataPropertyStatements
entwa.setSunrise( easyDate.minusDays(3).toDate() ); // DataPropertyStatement dps = new DataPropertyStatementImpl();
entwa.setSunset( easyDate.plusDays(3).toDate() ); // dps.setSunrise( easyDate.minusDays(3).toDate() );
Assert.assertTrue(vf.getIndividualFilter().fn( entwa ) ); // dps.setSunset( easyDate.plusDays( 3).toDate() );
// Assert.assertTrue( vf.getDataPropertyStatementFilter().fn( dps ) );
entwa.setSunrise( easyDate.toDate() ); //
Assert.assertTrue("items should be not filtered on first sunrise day", vf.getIndividualFilter().fn(entwa)); // dps.setSunrise( easyDate.toDate() );
// dps.setSunset( easyDate.plusDays( 3).toDate() );
entwa.setSunrise( easyDate.minusDays(3).toDate() ); // Assert.assertTrue( vf.getDataPropertyStatementFilter().fn( dps ) );
entwa.setSunset( easyDate.minusDays( 2 ).toDate() ); //
Assert.assertFalse("should be sunset and filtered out", vf.getIndividualFilter().fn( entwa )); // dps.setSunrise( null );
// dps.setSunset( null );
entwa.setSunrise( easyDate.plusDays(3).toDate() ); // Assert.assertTrue("should be not throw exceptions and should not be filtered out", vf.getDataPropertyStatementFilter().fn( dps ) );
entwa.setSunset( easyDate.plusDays( 10 ).toDate() ); //
Assert.assertFalse("should not yet be sunrised and filtered out", vf.getIndividualFilter().fn( entwa )); // }
entwa.setSunrise( null );
entwa.setSunset( null );
Assert.assertTrue("null should not throw exceptions and should not be filtered out", vf.getIndividualFilter().fn( entwa ));
//ObjectPropertyStatements
ObjectPropertyStatement ops = new ObjectPropertyStatementImpl();
ops.setObject(entwa);
entwa.setSunrise( easyDate.minusDays(3).toDate() );
entwa.setSunset( easyDate.plusDays(3).toDate() );
Assert.assertTrue(vf.getIndividualFilter().fn( entwa ) );
entwa.setSunrise( easyDate.toDate() );
Assert.assertTrue("items should be not filtered on first sunrise day", vf.getObjectPropertyStatementFilter().fn(ops));
entwa.setSunrise( easyDate.minusDays(3).toDate() );
entwa.setSunset( easyDate.minusDays( 2 ).toDate() );
Assert.assertFalse("should be sunset and filtered out", vf.getObjectPropertyStatementFilter().fn(ops));
entwa.setSunrise( easyDate.plusDays(3).toDate() );
entwa.setSunset( easyDate.plusDays( 10 ).toDate() );
Assert.assertFalse("should not yet be sunrised and filtered out", vf.getObjectPropertyStatementFilter().fn(ops));
entwa.setSunrise( null );
entwa.setSunset( null );
Assert.assertTrue("null should not throw exceptions and should not be filtered out", vf.getObjectPropertyStatementFilter().fn(ops));
ops.setSunrise( null );
ops.setSunset( null );
Assert.assertTrue("null should not throw exceptions and should not be filtered out", vf.getObjectPropertyStatementFilter().fn( ops ) );
//DataPropertyStatements
DataPropertyStatement dps = new DataPropertyStatementImpl();
dps.setSunrise( easyDate.minusDays(3).toDate() );
dps.setSunset( easyDate.plusDays( 3).toDate() );
Assert.assertTrue( vf.getDataPropertyStatementFilter().fn( dps ) );
dps.setSunrise( easyDate.toDate() );
dps.setSunset( easyDate.plusDays( 3).toDate() );
Assert.assertTrue( vf.getDataPropertyStatementFilter().fn( dps ) );
dps.setSunrise( null );
dps.setSunset( null );
Assert.assertTrue("should be not throw exceptions and should not be filtered out", vf.getDataPropertyStatementFilter().fn( dps ) );
}
@Test @Test
public void testGetTestFilter() { public void testGetTestFilter() {
@ -200,7 +200,7 @@ public class VitroFiltersFactoryTest {
Assert.assertNotNull("getObjectPropertyFilter was null", vf.getObjectPropertyFilter()); Assert.assertNotNull("getObjectPropertyFilter was null", vf.getObjectPropertyFilter());
Assert.assertNotNull("getObjectPropertyStatementFilter was null", vf.getObjectPropertyStatementFilter()); Assert.assertNotNull("getObjectPropertyStatementFilter was null", vf.getObjectPropertyStatementFilter());
Assert.assertNotNull("getIndividualFilter was null", vf.getIndividualFilter()); Assert.assertNotNull("getIndividualFilter was null", vf.getIndividualFilter());
Assert.assertNotNull("getTabFilter was null", vf.getTabFilter()); //Assert.assertNotNull("getTabFilter was null", vf.getTabFilter());
Assert.assertNotNull("getUserFilter was null", vf.getUserFilter()); Assert.assertNotNull("getUserFilter was null", vf.getUserFilter());
Assert.assertNotNull("getVClassGroupFilter was null", vf.getVClassGroupFilter()); Assert.assertNotNull("getVClassGroupFilter was null", vf.getVClassGroupFilter());
} }

View file

@ -6,24 +6,17 @@ import junit.framework.Assert;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty; import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl; import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
import edu.cornell.mannlib.vitro.webapp.beans.Link;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty; import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Ontology; import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
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.User;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.InsertException; import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
import edu.cornell.mannlib.vitro.webapp.dao.TabDao;
import edu.cornell.mannlib.vitro.webapp.dao.UserDao; import edu.cornell.mannlib.vitro.webapp.dao.UserDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
/** /**

View file

@ -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.PageDao;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao; 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.UserAccountsDao;
import edu.cornell.mannlib.vitro.webapp.dao.UserDao; import edu.cornell.mannlib.vitro.webapp.dao.UserDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
@ -193,24 +190,6 @@ public class WebappDaoFactoryStub implements WebappDaoFactory {
"WebappDaoFactory.getApplicationDao() not implemented."); "WebappDaoFactory.getApplicationDao() not implemented.");
} }
@Override
public TabDao getTabDao() {
throw new RuntimeException(
"WebappDaoFactory.getTabDao() not implemented.");
}
@Override
public TabIndividualRelationDao getTabs2EntsDao() {
throw new RuntimeException(
"WebappDaoFactory.getTabs2EntsDao() not implemented.");
}
@Override
public TabVClassRelationDao getTabs2TypesDao() {
throw new RuntimeException(
"WebappDaoFactory.getTabs2TypesDao() not implemented.");
}
@Override @Override
public KeywordIndividualRelationDao getKeys2EntsDao() { public KeywordIndividualRelationDao getKeys2EntsDao() {
throw new RuntimeException( throw new RuntimeException(

View file

@ -1,110 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%@ taglib prefix="form" uri="http://vitro.mannlib.cornell.edu/edit/tags" %>
<tr class="editformcell">
<td valign="bottom" colspan="2">
<b>Tab Title*</b> <i>(a short phrase to appear on headings, menus or pick lists)</i><br/>
<input type="text" name="Title" value="<form:value name="Title"/>" style="width:60%;" maxlength="80" />
<font size="2" color="red"><form:error name="Title"/></font>
</td>
<td valign="bottom" colspan="1">
<b>Tab Shorthand</b> <i>(an alternate phrase for display as <strong>More ...</strong> in the application)</i><br/>
<input type="text" name="ShortHand" value="<form:value name="MoreTag"/>" style="width:80%;" maxlength="80" />
<font size="2" color="red"><form:error name="MoreTag"/></font>
</td>
</tr>
<tr class="editformcell">
<td valign="bottom" colspan="3">
<b>Tab Description</b> <i>A single short sentence to summarize the contents for users</i><br/>
<strong>Note that this now becomes the tool tip when the mouse rolls over a primary or secondary tab name</strong><br/>
<input type="text" name="Description" value="<form:value name="Description"/>" style="width:90%;" maxlength="255" />
<font size="2" color="red"><form:error name="Description"/></font>
</td>
</tr>
<tr class="editformcell">
<td valign="bottom" colspan="3">
<b>Tab Body</b> <i>enter any longer text or comment here</i><br/>
<textarea name="Body" rows="10" wrap="soft"><form:value name="Rows"/><form:value name="Body"/></textarea>
<font size="2" color="red"><form:error name="Body"/></font>
</td>
</tr>
<tr class="editformcell">
<td valign="top" colspan="1">
<% /*
<b>Originator</b><br>
<input type="text" disabled="disabled" name="UserId" value="<form:value name="UserId"/>"/>
<font size="2" color="red"><form:error name="UserId"/></font>
*/ %>
</td>
<td valign="bottom" colspan="1">
<b>Tab Type</b><br>
<select name="TabtypeId" >
<form:option name="TabtypeId"/>
</select>
<font size="2" color="red"><form:error name="TabtypeId"/></font>
</td>
<td valign="bottom" colspan="1">
<b>Individual link method</b><br /><i>(if method is "by tab-type relationships", select types after editing this tab itself)</i><br />
<select name="EntityLinkMethod" >
<form:option name="EntityLinkMethod"/>
</select>
<font size="2" color="red"><form:error name="EntityLinkMethod"/></font>
</td> </tr>
<tr class="editformcell"><td colspan="3"><hr /></td></tr>
<% /*
<tr class="editformcell">
<td valign="bottom" colspan="3">
<b>URL of RSS feed</b> (must include the full http://... path)<br/>
<input type="text" name="RssURL" value="<form:value name="RssURL"/>" style="width:60%;" maxlength="255" />
<font size="2" color="red"><form:error name="RssURL"/></font>
</td>
</tr>
*/ %>
<tr class="editformcell">
<td valign="bottom" colspan="1">
<b>Order for display within parent tab</b><br />
<input type="text" name="DisplayRank" value="<form:value name="DisplayRank"/>" size="5" maxlength="11" />
<font size="2" color="red"><form:error name="DisplayRank"/></font>
</td>
<td valign="bottom" colspan="2">
<b>Optional time limit for entities</b> <i>in days; use negative values for the past; not active for manual linking or image galleries</i><br/>
<i>positive values will key off entity <b>timekey</b> field; negative values off entity <b>sunrise</b> field</i><br/>
<input type="text" name="DayLimit" value="<form:value name="DayLimit"/>" size="5" maxlength="11" />
<font size="2" color="red"><form:error name="DayLimit"/></font>
</td>
</tr>
<tr class="editformcell">
<td valign="bottom" colspan="1">
<b>Sort field for related entities</b><br /><i><strong>name</strong>,rand(),timekey,sunset,sunrise</i><br/>
<input type="text" name="EntitySortField" value="<form:value name="EntitySortField"/>" size="10" maxlength="50" />
<font size="2" color="red"><form:error name="EntitySortField"/></font>
</td>
<td valign="bottom" colspan="2">
<b>Sort direction for related entities</b><br /><i>blank for ascending,"desc" for descending</i><br/>
<input type="text" name="EntitySortDirection" value="<form:value name="EntitySortDirection"/>" size="4" maxlength="4" />
<font size="2" color="red"><form:error name="EntitySortDirection"/></font>
</td>
</tr>
<tr class="editformcell"><td colspan="3"><hr /></td></tr>
<tr class="editformcell"><td colspan="3">The following fields apply only when images are involved</td></tr>
<tr class="editformcell">
<td valign="bottom" colspan="1">
<b>Columns of images to display</b><br/>
<i>9 columns of images at 94 pixels wide fits a 1024x768 display window</i><br/>
<input type="text" name="GalleryCols" value="<form:value name="GalleryCols"/>" size="5" maxlength="11" />
<font size="2" color="red"><form:error name="GalleryCols"/></font>
</td>
<td valign="bottom" colspan="1">
<b>Rows of images to display</b><br/>
<i>if only a single row is specified, the A|B|C...|Z choices don't appear with image galleries</i><br/>
<input type="text" name="GalleryRows" value="<form:value name="GalleryRows"/>" size="5" maxlength="11" />
<font size="2" color="red"><form:error name="GalleryRows"/></font>
</td>
<td valign="bottom" colspan="1">
<b>Width for image display</i><br/>
<input type="text" name="ImageWidth" value="<form:value name="ImageWidth"/>" size="5" maxlength="11" />
<font size="2" color="red"><form:error name="ImageWidth"/></font>
</td>
</tr>

View file

@ -1,28 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%@ taglib prefix="form" uri="http://vitro.mannlib.cornell.edu/edit/tags" %>
<tr class="editformcell">
<td valign="top">
<b>Tab</b><br/>
<select name="TabId" >
<form:option name="TabId"/>
</select>
<font size="2" color="red"><form:error name="TabId"/></font>
</td>
</tr>
<tr class="editformcell">
<td valign="top">
<b>Individual</b><br/>
<select name="EntURI" >
<form:option name="EntId"/>
</select>
<font size="2" color="red"><form:error name="EntId"/></font>
</td>
</tr>
<tr class="editformcell">
<td valign="bottom" colspan="1">
<b>Order for display</b> in selected tab; blank will default to zero<br/>
<input type="text" name="DisplayRank" value="<form:value name="DisplayRank"/>" size="5" maxlength="11" />
<font size="2" color="red"><form:error name="DisplayRank"/></font>
</td>
</tr>

View file

@ -1,79 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%@ taglib prefix="form" uri="http://vitro.mannlib.cornell.edu/edit/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="vitro" uri="/WEB-INF/tlds/VitroUtils.tld" %>
<%@page import="edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.ManageTabs" %>
<% request.setAttribute("requestedActions", new ManageTabs()); %>
<vitro:confirmAuthorization />
<div class="editingForm">
<form id="editForm" name="editForm" action="doTabHierarchyOperation" method="post">
<input type="hidden" name="_epoKey" value="${epoKey}" />
<div align="center">
<table cellpadding="4" cellspacing="2" border="0">
<tr><th colspan="3">
<div class="entryFormHead">
<h2>${title}</h2>
<c:choose>
<c:when test='${_action == "insert"}'>
<h3>Creating New Record</h3>
</c:when>
<c:otherwise>
<h3>Editing Existing Record</h3>
</c:otherwise>
</c:choose>
<span class="entryFormHeadInstructions">(<sup>*</sup> Required Fields)</span>
</div><!--entryFormHead-->
</th></tr>
<tr class="editformcell">
<td valign="top">
<b>Broader tab<sup>*</sup></b><br/>
<select name="ParentId">
<c:forEach var="option" items="${epo.formObject.optionLists['ParentId']}">
<option value="${option.value}">${option.body}</option>
</c:forEach>
</select>
<span class="warning"><form:error name="ParentId"/></span>
</td>
</tr>
<tr class="editformcell">
<td valign="top">
<b>Narrower Tab<sup>*</sup></b><br/>
<select name="ChildId" >
<c:forEach var="option" items="${epo.formObject.optionLists['ChildId']}">
<option value="${option.value}">${option.body}</option>
</c:forEach>
</select>
<span class="warning"><form:error name="ChildId"/></span>
</td>
</tr>
<tr class="editformcell">
<td colspan="3" align="center">
<c:choose>
<c:when test='${_action == "insert"}'>
<input id="primaryAction" type="submit" class="form-button" name="_insert" value="Create New Record"/>
</c:when>
<c:otherwise>
<input id="primaryAction" type="submit" class="form-button" name="_update" value="Submit Changes"/>
<input type="submit" class="form-button" name="_insert" value="Save as New Record"/>
<input type="submit" class="form-button" name="_delete" onclick="return confirmDelete();" value="Delete"/>
</c:otherwise>
</c:choose>
<input type="reset" class="form-button" value="Reset"/>
<input type="submit" class="form-button" name="_cancel" value="Cancel"/>
</td>
</tr>
</table>
</div><!--alignCenter-->
</form>
</div><!--editingform-->

View file

@ -1,21 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%@ taglib prefix="form" uri="http://vitro.mannlib.cornell.edu/edit/tags" %>
<tr class="editformcell">
<td valign="top">
<b>Tab</b><br/>
<select name="TabId" >
<form:option name="TabId"/>
</select>
<font size="2" color="red"><form:error name="TabId"/></font>
</td>
</tr>
<tr class="editformcell">
<td valign="top">
<b>Vclass</b><br/>
<select name="VClassURI" >
<form:option name="VClassId"/>
</select>
<font size="2" color="red"><form:error name="VClassId"/></font>
</td>
</tr>

View file

@ -1,193 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="form" uri="http://vitro.mannlib.cornell.edu/edit/tags" %>
<%@taglib prefix="vitro" uri="/WEB-INF/tlds/VitroUtils.tld" %>
<%@page import="edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.ManageTabs" %>
<% request.setAttribute("requestedActions", new ManageTabs()); %>
<vitro:confirmAuthorization />
<div class="editingForm">
<jsp:include page="/templates/edit/fetch/vertical.jsp"/>
<%
/**
*
* @version 1.00
* @author Jon Corson-Rikert
*
* UPDATES:
* BJL 2007-XX-XX : significant modifications for semweb-align (removed SQL tags, etc.)
* JCR 2006-03-05 : modified references to ETypes and change property file used to display auto-affiliated vclasses (a.k.a. types)
* JCR 2005-11-06 : modified field specifications for tab editing so tabs_retry will get numeric rather than String versions of flag2Set and flag3Set
*/
%>
<c:set var="PRIMARY_TAB_TABTYPE" value="28"/>
<c:set var="SUBCOLLECTION_CATEGORY_TABTYPE" value="18"/>
<p/>
<div align="center">
<table class="form-background" border="0" cellpadding="2" cellspacing="2">
<tr valign="bottom" align="center">
<td>
<form action="./" method="get">
<input type="submit" class="form-button" value="Display This Tab (Public)"/>
<input type="hidden" name="primary" value="${tab.tabId}" />
</form>
<form action="listTabs" method="get">
<input type="submit" class="form-button" value="See All Tabs"/>
</form>
</td>
<td valign="bottom" align="center">
<form action="editForm" method="get">
<input name="id" type = "hidden" value="<%=request.getAttribute("tabId")%>" />
<input type="submit" class="form-button" value="Edit Tab Details"/>
<input type="hidden" name="controller" value="Tab"/>
</form>
</td>
<td valign="bottom">
<form action="editForm" method="get">
<input type="submit" class="form-button" value="Add New Tab"/>
<input type="hidden" name="controller" value="Tab"/>
</form>
</td>
</tr>
<tr><td colspan="3"><hr/></td></tr>
<!-- ____________________________ parent tabs ______________________________________ -->
<c:choose>
<c:when test="${tab.tabtypeId < PRIMARY_TAB_TABTYPE}">
<tr valign="bottom">
<td colspan="2" valign="bottom">
<c:if test="${!empty epo.formObject.checkboxLists['parentTabs']}">
<form action="doTabHierarchyOperation" method="get">
<ul>
<c:forEach var="cb" items="${epo.formObject.checkboxLists['parentTabs']}">
<li style="list-style-type:none"><input name="ParentId" type="checkbox" value="${cb.value}"/>${cb.body}</li>
</c:forEach>
</ul>
<input type="submit" class="form-button" value="Remove checked parent tabs"/>
<input type="hidden" name="ChildId" value="${tab.tabId}"/>
<input type="hidden" name="primaryAction" value="_remove"/>
<input type="hidden" name="_epoKey" value="${tabHierarchyEpoKey}"/>
</form>
</c:if>
</td>
<td>
<form action="editForm" method="get">
<input type="hidden" name="ChildId" value="${tab.tabId}">
<input type="hidden" name="controller" value="Tabs2Tabs"/>
<input type="submit" class="form-button" value="Add existing tab as parent tab"/>
</form>
</td>
</tr>
</c:when>
<c:otherwise>
<tr><td colspan="3" align="center">This is the highest level tab, so no links to higher tabs are possible.</td></tr>
</c:otherwise>
</c:choose>
<tr><td colspan="3"><hr/></td></tr>
<!-- _____________________________________ child tabs ___________________________________________ -->
<c:choose>
<c:when test="${tab.tabtypeId>SUBCOLLECTION_CATEGORY_TABTYPE}">
<tr valign="bottom">
<td colspan="2" valign="bottom">
<c:if test="${!empty epo.formObject.checkboxLists['childTabs']}">
<form action="doTabHierarchyOperation" method="get">
<ul>
<c:forEach var="cb" items="${epo.formObject.checkboxLists['childTabs']}">
<li style="list-style-type:none"><input name="ChildId" type="checkbox" value="${cb.value}"/>${cb.body}</li>
</c:forEach>
</ul>
<input type="hidden" name="ParentId" value="${tab.tabId}"/>
<input type="submit" class="form-button" value="Remove checked child tabs"/>
<input type="hidden" name="primaryAction" value="_remove"/>
<input type="hidden" name="_epoKey" value="${tabHierarchyEpoKey}"/>
</form>
</c:if>
</td>
<td>
<form action="editForm" method="get">
<input type="hidden" name="ParentId" value="${tab.tabId}">
<input type="hidden" name="controller" value="Tabs2Tabs">
<input type="submit" class="form-button" value="Add existing tab as child tab"/>
</form>
</td>
</tr>
</c:when>
<c:otherwise>
<tr><td colspan="3" align="center">This is the lowest level tab, so no links to lower tabs are possible.</td></tr>
</c:otherwise>
</c:choose>
<tr><td colspan="3"><hr/></td></tr>
<!-- ________________________________________________ vClasses __________________________________________________ -->
<c:choose>
<c:when test="${tab.entityLinkMethod eq 'auto' || tab.entityLinkMethod eq 'mixed'}">
<tr valign="bottom" align="center">
<td colspan="2" valign="bottom" align="left">
<c:if test="${!empty affilTypes}">
<form action="tabs2TypesOp" method="get">
<ul style="list-style-type:none;">
<c:forEach var="type" items="${affilTypes}">
<li style="list-style-type:none;"><input type="checkbox" name="TypeURI" value="${type.URI}">${type.name}</input></li>
</c:forEach>
</ul>
<input type="hidden" name="TabId" value="${tab.tabId}"/>
<input type="hidden" name="operation" value="remove"/>
<input type="hidden" name="_epoKey" value="${epoKey}"/>
<input type="submit" class="form-button" value="Remove Checked Class Autolinks"/>
</form>
</c:if>
</td>
<td>
<form action="editForm" method="get">
<input type="hidden" name="TabId" value="${tab.tabId}"/>
<input type="hidden" name="controller" value="Tabs2Types"/>
<input type="submit" class="form-button" value="Add Class Autolink"/>
</form>
</td>
</tr>
<tr><td colspan="3"><hr/></td></tr>
</c:when>
<c:otherwise><tr><td colspan="3" align="center">This tab is set for manual links to individuals only. Auto-affiliation with a type is not possible.</td></tr><tr><td colspan="3"><hr/></td></tr></c:otherwise>
</c:choose>
<!-- _______________________________________ entities ___________________________________________________ -->
<c:choose>
<c:when test="${tab.entityLinkMethod eq 'manual' || tab.entityLinkMethod eq 'mixed'}">
<tr valign="bottom" align="center">
<td colspan="2" valign="bottom" align="left">
<c:if test="${!empty epo.formObject.checkboxLists['affilEnts']}">
<form action="tabIndividualRelationOp" method="get">
<ul style="list-style-type:none;">
<c:forEach var="cb" items="${epo.formObject.checkboxLists['affilEnts']}">
<li style="list-style-type:none;"><input type="checkbox" name="TirURI" value="${cb.value}" class="form-item"/>${cb.body}</li>
</c:forEach>
</ul>
<input type="hidden" name="TabId" value="${tab.tabId}"/>
<input type="hidden" name="operation" value="remove"/>
<input type="hidden" name="_epoKey" value="${epoKey}"/>
<input type="submit" class="form-button" value="Remove Checked Individuals"/>
</form>
</c:if>
</td>
<td>
<form action="editForm" method="get">
<select name="VClassUri" class="form-item">
<form:option name="VClassURI"/>
</select><br/>
<p>Select class of individual</p>
<input type="hidden" name="TabId" value="${tab.tabId}"/>
<input type="hidden" name="controller" value="Tabs2Ents"/>
<input type="submit" class="form-button" value="Add an individual to this tab"/>
</form>
</td>
</tr>
</c:when>
<c:otherwise><tr><td colspan="3" align="center">This tab is set for tab-type relationships only; direct links to individuals are not possible</td></tr></c:otherwise>
</c:choose>
</table>
</div>
</div>

View file

@ -17,10 +17,6 @@
<li><a href="${siteConfig.urls.menuN3Editor}">Menu management</a></li> <li><a href="${siteConfig.urls.menuN3Editor}">Menu management</a></li>
</#if> </#if>
<#if siteConfig.urls.tabs??>
<li><a href="${siteConfig.urls.tabs}">Tab management</a></li>
</#if>
<#if siteConfig.urls.users??> <#if siteConfig.urls.users??>
<li><a href="${siteConfig.urls.users}">User accounts</a></li> <li><a href="${siteConfig.urls.users}">User accounts</a></li>
</#if> </#if>

View file

@ -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)) { %>
<c:set var='tab' value='${requestScope.leadingTab}'/><%/* just moving this into page scope for easy use */ %>
<div class='admin bottom'>
<c:url var="editHref" value="tabEdit">
<c:param name="controller" value="Tab"/>
<c:param name="id" value="${tab.tabId}"/>
</c:url>
<c:set var="editHref">
<c:out value="${editHref}" escapeXml="true"/>
</c:set>
<a href="${editHref}">edit tab: <em>${tab.title}</em></a>
</div>
<% } %>

View file

@ -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<Individual> individuals = leadingTab.getRelatedEntities();
Collection<Tab> 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, "&", "&amp;");
if(frag.contains("'")) frag = replaceAll(frag, "'", "&apos;");
if(frag.contains("\"")) frag = replaceAll(frag, "\"", "&quot;");
if(frag.contains(">")) frag = replaceAll(frag, ">", "&gt;");
if(frag.contains("<")) frag = replaceAll(frag, "<", "&lt;");
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);
}
%>
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en" xml:base="http://<%= request.getServerName()+":"+request.getLocalPort() %>">
<title><%= escapeEntity(leadingTab.getTitle()) %></title>
<subtitle><%= leadingTab.getDescription() %></subtitle>
<link href="<%= "http://"+request.getServerName()+":"+request.getLocalPort()+request.getContextPath()+escapeEntity("/index.jsp?home="+portalId+"&"+leadingTab.getTabDepthName()+"="+leadingTab.getTabId()+"&view=atom") %>" rel="self" type="application/atom+xml" />
<link href="<%= "http://"+request.getServerName()+":"+request.getLocalPort()+request.getContextPath()+escapeEntity("/index.jsp?home="+portalId+"&"+leadingTab.getTabDepthName()+"="+leadingTab.getTabId()) %>" rel="alternate" type="text/html" />
<id><%= "http://"+request.getServerName()+":"+request.getLocalPort()+request.getContextPath()+escapeEntity("/index.jsp?home="+portalId+"&"+leadingTab.getTabDepthName()+"="+leadingTab.getTabId()) %></id>
<updated><%= time %></updated>
<author>
<name>Vivo</name>
<email>vivo@cornell.edu</email>
</author>
<% for(Individual i:individuals) { %>
<entry>
<title><%= escapeEntity(i.getName()) %></title>
<% if (i.getLinksList() == null) { %>
<% for(Link l: i.getLinksList()) { %>
<link href="<%= l.getUrl() %>" rel="alternate" type="text/html" />
<% } %>
<% } else { %>
<link href="<%= escapeEntity(request.getContextPath().substring(1)+"/entity?home="+portalId+"&uri="+forURL(i.getURI())) %>" rel="alternate" type="text/html" />
<% } %>
<id><%= i.getURI() %></id>
<updated><%= time %></updated>
<% if (i.getBlurb() != null) { %>
<% if (i.getBlurb().matches(".*<.*>.*")) { %>
<summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><%= i.getBlurb() %></div></summary>
<% } %>
<% else { %>
<summary type="text"><%= i.getBlurb() %></summary>
<% } %>
<% } %>
<% if (i.getDescription() != null) { %>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><%= i.getDescription() %></div></content>
<% } %>
</entry>
<% } %>
<% if (tabs != null) { %>
<% for(Tab t:tabs) { %>
<entry>
<title><%= escapeEntity(t.getTitle()) %></title>
<link href="<%= escapeEntity(request.getContextPath().substring(1)+"/index.jsp?home="+portalId+"&"+t.getTabDepthName()+"="+t.getTabId()) %>" rel="alternate" type="text/html" />
<id><%= "http://"+request.getServerName()+":"+request.getLocalPort()+request.getContextPath()+escapeEntity("/index.jsp?home="+portalId+"&"+t.getTabDepthName()+"="+t.getTabId()) %></id>
<updated><%= time %></updated>
<% if (t.getDescription() != null) { %>
<% if (t.getDescription().matches(".*<.*>.*")) { %>
<summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><%= t.getDescription() %></div></summary>
<% } %>
<% else { %>
<summary type="text"><%= t.getDescription() %></summary>
<% } %>
<% } %>
<% if (t.getBody() != null) { %>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><%= t.getBody() %></div></content>
<% } %>
</entry>
<% } %>
<% } %>
</feed>

View file

@ -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 = "<h" + headingDepth + ">";
String headingClose = "</h" + headingDepth + ">";
String tabDesc = "";
if (!noDesc && tab.getDescription() != null && !tab.getDescription().equals("&nbsp;"))
tabDesc = "<div class='tabDesc' >" + tab.getDescription() + "</div>";
String tabBody = "";
/* tab.body is only displayed for the depth 1 display tab */
if (depth <= 2 && tab.getBody() != null && !tab.getBody().equals("&nbsp;"))
tabBody = "<div class='tabBody'>" + tab.getBody() + "</div><!-- END div class='tabBody' -->";
%>
<div class="tab depth<%=depth%>" id="tab<%=tabId%>">
<%=headingOpen%><%=titleLink%><%=headingClose%>
<%=tabDesc%>
<%=tabBody%>
<% if( entities ){ %>
<jsp:include page="<%=tabEntsController%>" flush="true">
<jsp:param name="tabId" value="<%=tab.getTabId()%>"/>
<jsp:param name="tabDepth" value="<%=depth%>"/>
</jsp:include>
<% } %>
<% if( subtabs ) { %>
<jsp:include page="tabSub.jsp" flush="true">
<jsp:param name="tabId" value="<%=tab.getTabId()%>"/>
<jsp:param name="tabDepth" value="<%=depth%>"/>
</jsp:include>
<% }%>
<% if( subtabsAsList ) { %>
<jsp:include page="tabSubAsList.jsp" flush="true">
<jsp:param name="tabId" value="<%=tab.getTabId()%>"/>
<jsp:param name="tabDepth" value="<%=depth%>"/>
</jsp:include>
<% }%>
<% if(content) { %>
<jsp:include page="tabContent.jsp" flush="true">
<jsp:param name="tabId" value="<%=tab.getTabId()%>"/>
<jsp:param name="tabDepth" value="1" />
</jsp:include>
<% } %>
</div><!-- tab depth<%=depth%> -->

View file

@ -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 ){ %>
<div id='tabContent'><!-- tabContent.jsp -->
<table><tr>
<% }
while( childIter.hasNext() ) {
Tab contentTab = (Tab)childIter.next();
TabWebUtil.stashTabsInRequest(contentTab, request); %>
<% if (columnSize==2) {%>
<td class="span-12">
<% } %>
<% else if (columnSize==3) {%>
<td class="span-8">
<% } %>
<% else if (columnSize==4) {%>
<td class="span-6">
<% } %>
<% else {%>
<td>
<% } %>
<jsp:include page='tabBasic.jsp'>
<jsp:param name='tabDepth' value='<%=childDepth%>' />
<jsp:param name='tabId' value='<%=contentTab.getTabId()%>' />
<jsp:param name='noContent' value='true'/>
<jsp:param name='noSubtabs' value='true'/>
</jsp:include>
</td>
<% }
if( hasChildren ){ %>
</tr></table>
</div><!-- end tabContent div-->
<%}%>
<% } %>

View file

@ -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 */ %>
<jsp:include page='tabSubAsList.jsp' >
<jsp:param name='tabDepth' value='<%=depth%>' />
<jsp:param name='tabId' value='<%=tabId%>' />
</jsp:include>
<% } 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) { %>
<div class='subtabs'><!-- tabSub.jsp -->
<table><tr>
<% }
while( childIter.hasNext() ) {
Tab subtab = (Tab)childIter.next();
TabWebUtil.stashTabsInRequest(subtab, request); %>
<% if (columnSize==1) {%>
<td class="span-24">
<% } %>
<% else if (columnSize==2) {%>
<td class="span-12">
<% } %>
<% else if (columnSize==3) {%>
<td class="span-8">
<% } %>
<% else if (columnSize==4) {%>
<td class="span-6">
<% } %>
<% else {%>
<td>
<% } %>
<jsp:include page='tabBasic.jsp'>
<jsp:param name='tabDepth' value='<%=childDepth%>' />
<jsp:param name='tabId' value='<%=subtab.getTabId()%>' />
<jsp:param name='noDesc' value='<%=noDesc%>'/>
<jsp:param name='noEntities' value='<%=noEntities%>'/>
<jsp:param name='noContent' value='true'/>
<jsp:param name='noSubtabs' value='true'/>
<jsp:param name='subtabsAsList' value='true'/>
</jsp:include>
</td>
<% }
if( hasChildren ){ %>
</tr></table>
</div><!-- end subtabs div-->
<%}
}
} %>

View file

@ -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 <UL></UL>
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) { %>
<div class='subtabs'><!-- tabSub.jsp -->
<ul class='tabSubAsList'>
<% }
while( childIter.hasNext() ) {
Tab subtab = (Tab)childIter.next();
TabWebUtil.stashTabsInRequest(subtab,request); %>
<li>
<jsp:include page='tabBasic.jsp'>
<jsp:param name='tabDepth' value='<%=childDepth%>' />
<jsp:param name='tabId' value='<%=subtab.getTabId()%>' />
<jsp:param name='noDesc' value='<%=noDesc%>'/>
<jsp:param name='yesBody' value='false'/>
<jsp:param name='noEntities' value='true'/>
<jsp:param name='noContent' value='true'/>
<jsp:param name='noSubtabs' value='true'/>
</jsp:include>
</li>
<% }
if( hasChildren ){ %>
</ul>
</div><!-- end subtabs div-->
<%}%>
<% } %>

View file

@ -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); %>
<div id="content">
<div id='contents'>
<jsp:include page='/templates/tabs/tabBasic.jsp' flush='true'>
<jsp:param name='tabId' value='<%= leadingTab.getTabId() %>' />
<jsp:param name='tabDepth' value='1' />
</jsp:include>
<jsp:include page='/templates/tabs/tabAdmin.jsp' flush='true' />
</div> <!-- contents -->
</div><!-- content -->