|
From: Rashmi B. <ra...@us...> - 2005-04-19 00:39:45
|
Update of /cvsroot/pocolap/pocolap/src/com/pocolap/tags In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10837 Modified Files: ReptGrid.java Log Message: PDF related changes Index: ReptGrid.java =================================================================== RCS file: /cvsroot/pocolap/pocolap/src/com/pocolap/tags/ReptGrid.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ReptGrid.java 14 Apr 2005 22:32:38 -0000 1.17 --- ReptGrid.java 19 Apr 2005 00:39:35 -0000 1.18 *************** *** 4,24 **** Copyright (c) 2003 Todd Runstein ! Permission is hereby granted, free of charge, to any person obtaining a copy ! of this software and associated documentation files (the "Software"), to deal ! in the Software without restriction, including without limitation the rights to use, ! copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the ! Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: ! The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. ! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ! EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES ! OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ! NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ! HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ! WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ! FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ --- 4,24 ---- Copyright (c) 2003 Todd Runstein ! Permission is hereby granted, free of charge, to any person obtaining a copy ! of this software and associated documentation files (the "Software"), to deal ! in the Software without restriction, including without limitation the rights to use, ! copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the ! Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: ! The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. ! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ! EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES ! OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ! NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ! HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ! WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ! FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ *************** *** 42,48 **** import com.pocolap.xtab.layout.SpreadSheet; import com.pocolap.selectors.Selector; ! import com.pocolap.servlets.pocOLAPConstants ; ! import org.apache.log4j.Logger ; import com.pocolap.schema.CrossTabDef ; --- 42,48 ---- import com.pocolap.xtab.layout.SpreadSheet; import com.pocolap.selectors.Selector; ! import com.pocolap.servlets.pocOLAPConstants ; ! import org.apache.log4j.Logger ; import com.pocolap.schema.CrossTabDef ; *************** *** 51,60 **** * ReptGrid is a heavy tag, consisting of select lists and a spreadsheet-like table. * This one should be broken out into more reusable components. ! * * @author todd * */ public class ReptGrid extends TagSupport { ! static Logger logger = Logger.getLogger(ReptGrid.class); /** --- 51,60 ---- * ReptGrid is a heavy tag, consisting of select lists and a spreadsheet-like table. * This one should be broken out into more reusable components. ! * * @author todd * */ public class ReptGrid extends TagSupport { ! static Logger logger = Logger.getLogger(ReptGrid.class); /** *************** *** 66,73 **** ! /** * doEndTag writes selection and report content ! * ! * @return int determines how remainder of page is processed * @throws JspExection if processing can not be completed */ --- 66,73 ---- ! /** * doEndTag writes selection and report content ! * ! * @return int determines how remainder of page is processed * @throws JspExection if processing can not be completed */ *************** *** 79,99 **** HttpServletRequest req = (HttpServletRequest)pageContext.getRequest(); HttpServletResponse res =(HttpServletResponse)pageContext.getResponse(); ! JspWriter writer = pageContext.getOut(); CrossTabDef crosstab = (CrossTabDef)req.getSession().getAttribute(pocOLAPConstants.ATTR_SCHEMA); //Modified 6/16/2004 - TaR /* * This is somewhat screwy - there are three sets of public fields in ! * pocOLAPConstants that all equal the same thing - One set begins with * ACTION, the next with ELEMENT and the last with ATTR * This is so that you can use which ever matches the object ! * you're working with. In this case, we're working with ! * attributes, so we'll use the ATTR one - this may cause * some pain later, but at least it's documented now ;) */ Selector across = (Selector)req.getSession().getAttribute(pocOLAPConstants.ATTR_ACROSSSELECTOR); Selector down = (Selector)req.getSession().getAttribute(pocOLAPConstants.ATTR_DOWNSELECTOR); ! FilterList[] filters = (FilterList[])req.getSession().getAttribute(pocOLAPConstants.ATTR_FILTERS); ! try { writer.write(doReport(crosstab,down,across,filters)); --- 79,99 ---- HttpServletRequest req = (HttpServletRequest)pageContext.getRequest(); HttpServletResponse res =(HttpServletResponse)pageContext.getResponse(); ! JspWriter writer = pageContext.getOut(); CrossTabDef crosstab = (CrossTabDef)req.getSession().getAttribute(pocOLAPConstants.ATTR_SCHEMA); //Modified 6/16/2004 - TaR /* * This is somewhat screwy - there are three sets of public fields in ! * pocOLAPConstants that all equal the same thing - One set begins with * ACTION, the next with ELEMENT and the last with ATTR * This is so that you can use which ever matches the object ! * you're working with. In this case, we're working with ! * attributes, so we'll use the ATTR one - this may cause * some pain later, but at least it's documented now ;) */ Selector across = (Selector)req.getSession().getAttribute(pocOLAPConstants.ATTR_ACROSSSELECTOR); Selector down = (Selector)req.getSession().getAttribute(pocOLAPConstants.ATTR_DOWNSELECTOR); ! FilterList[] filters = (FilterList[])req.getSession().getAttribute(pocOLAPConstants.ATTR_FILTERS); ! try { writer.write(doReport(crosstab,down,across,filters)); *************** *** 103,107 **** throw new JspException(e); } ! logger.debug(errclass+"End function doEndTag()"); return retVal; --- 103,107 ---- throw new JspException(e); } ! logger.debug(errclass+"End function doEndTag()"); return retVal; *************** *** 110,114 **** /** * doReport outputs the data via XTabQueryGenerator. ! * * @param crosstab * @param down --- 110,114 ---- /** * doReport outputs the data via XTabQueryGenerator. ! * * @param crosstab * @param down *************** *** 118,132 **** * @throws SQLException if the database can not be accessed * @throws IOException if content can't be written ! */ protected String doReport( ! CrossTabDef crosstab, ! Selector down, ! Selector across, ! FilterList[] filters) throws SQLException{ StringBuffer retVal = new StringBuffer(); ! String errclass = getClass().getName()+".doReport(CrossTabDef,Selector,Selector,FilterList[]): " ; ! QueryGenerator gen = new QueryGenerator(crosstab); int count=0; --- 118,132 ---- * @throws SQLException if the database can not be accessed * @throws IOException if content can't be written ! */ protected String doReport( ! CrossTabDef crosstab, ! Selector down, ! Selector across, ! FilterList[] filters) throws SQLException{ StringBuffer retVal = new StringBuffer(); ! String errclass = getClass().getName()+".doReport(CrossTabDef,Selector,Selector,FilterList[]): " ; ! QueryGenerator gen = new QueryGenerator(crosstab); int count=0; *************** *** 147,151 **** String query = gen.generateQuery(selectList,filters); if (query!=null && query.length()>0){ ! QueryAgent agent = new QueryAgent(crosstab); DetachedResultSet rs = agent.doMetaQuery(query); --- 147,151 ---- String query = gen.generateQuery(selectList,filters); if (query!=null && query.length()>0){ ! QueryAgent agent = new QueryAgent(crosstab); DetachedResultSet rs = agent.doMetaQuery(query); *************** *** 158,165 **** retVal.append(renderer.renderDynamicGrid(crosstab,sheet,down,across)); HttpServletRequest req = (HttpServletRequest)pageContext.getRequest(); ! req.getSession().setAttribute("SPREADSHEET",sheet); ! } } ! return retVal.toString(); } --- 158,165 ---- retVal.append(renderer.renderDynamicGrid(crosstab,sheet,down,across)); HttpServletRequest req = (HttpServletRequest)pageContext.getRequest(); ! req.getSession().setAttribute(pocOLAPConstants.ATTR_SPREADSHEET,sheet); ! } } ! return retVal.toString(); } *************** *** 169,173 **** /** * getSchema extracts the XTabSchema of the selected report ! * * @param req HttpServletRequest from which to extract the XTabSchema * @return XTabSchema for this session --- 169,173 ---- /** * getSchema extracts the XTabSchema of the selected report ! * * @param req HttpServletRequest from which to extract the XTabSchema * @return XTabSchema for this session *************** *** 176,185 **** return (XTabSchema)req.getSession().getAttribute(pocOLAPConstants.ATTR_SCHEMA); }*/ ! ! /** ! * getAvailableDimensions gets the Dimensions from the XTabSchema and * puts them in a String array. ! * * @param schema XTabSchema for this session * @return String[] of dimension names, or null if no dimensions are found --- 176,185 ---- return (XTabSchema)req.getSession().getAttribute(pocOLAPConstants.ATTR_SCHEMA); }*/ ! ! /** ! * getAvailableDimensions gets the Dimensions from the XTabSchema and * puts them in a String array. ! * * @param schema XTabSchema for this session * @return String[] of dimension names, or null if no dimensions are found *************** *** 188,192 **** String[] retVal = null; Vector temp = new Vector(); ! DimensionItem[] items = schema.getDimensions(); if (items!=null){ --- 188,192 ---- String[] retVal = null; Vector temp = new Vector(); ! DimensionItem[] items = schema.getDimensions(); if (items!=null){ *************** *** 205,209 **** return retVal; }*/ ! /** --- 205,209 ---- return retVal; }*/ ! /** *************** *** 211,242 **** * the group/drilldowns the user has selected, plus an additional * drilldown option (if the user can drilldown further) ! * * @param schema XTabSchema for the session * @param selecteditems Selector of selected dimension/groups * @param direction String matching one of the pocOLAPConstants directional values ! * * @throws IOException if content can't be written ! * @return String html formatted table of ! * */ /* protected String doSelector(XTabSchema schema, Selector selecteditems, String direction){ ! StringBuffer retVal = new StringBuffer(); ! String[] dimensions = getAvailableDimensions(schema); String breakTag = getBreakTag(direction); ! String selectedDim = null; ! //Wrap this in a table retVal.append("\n<table><tr valign=\"top\" ><td valign=\"top\" >"); ! //Do dimensions - first select element if (selecteditems!=null && selecteditems.getItemCount()>0){ ! selectedDim = selecteditems.getSelectionItem(1).getGroupName(); } retVal.append(doDimensions(dimensions,selectedDim,direction)); ! //If a dimension was selected, we need to do the second select element //which will always be a group --- 211,242 ---- * the group/drilldowns the user has selected, plus an additional * drilldown option (if the user can drilldown further) ! * * @param schema XTabSchema for the session * @param selecteditems Selector of selected dimension/groups * @param direction String matching one of the pocOLAPConstants directional values ! * * @throws IOException if content can't be written ! * @return String html formatted table of ! * */ /* protected String doSelector(XTabSchema schema, Selector selecteditems, String direction){ ! StringBuffer retVal = new StringBuffer(); ! String[] dimensions = getAvailableDimensions(schema); String breakTag = getBreakTag(direction); ! String selectedDim = null; ! //Wrap this in a table retVal.append("\n<table><tr valign=\"top\" ><td valign=\"top\" >"); ! //Do dimensions - first select element if (selecteditems!=null && selecteditems.getItemCount()>0){ ! selectedDim = selecteditems.getSelectionItem(1).getGroupName(); } retVal.append(doDimensions(dimensions,selectedDim,direction)); ! //If a dimension was selected, we need to do the second select element //which will always be a group *************** *** 244,248 **** retVal.append(breakTag); retVal.append(doGroups(schema,selecteditems,direction)); ! //If a group was selected, do drilldowns too if (selecteditems.getItemCount()>1){ --- 244,248 ---- retVal.append(breakTag); retVal.append(doGroups(schema,selecteditems,direction)); ! //If a group was selected, do drilldowns too if (selecteditems.getItemCount()>1){ *************** *** 250,299 **** } } ! //close the table retVal.append("\n</td></tr></table>"); ! return retVal.toString(); }*/ ! /** * doDrillDowns creates select lists of tables and fields that should appear * on the grid (report) ! * * @param schema XTabSchema for the session * @param selecteditems Selector representing previously selected dimensions * @param direction String matching on of the pocOLAPConstants directional variables\ * @return String HTML formatted lists of tables and fields ! */ /* protected String doDrillDowns( XTabSchema schema, Selector selecteditems, String direction){ ! StringBuffer retVal = new StringBuffer(); ! //DrillDowns are always element 3 or higher int number = 3; ! //We'll use this before the last option for visual effect String stepDown = "\n</td></tr><tr><td> </td><td>"; ! //Dimension is always first element if (selecteditems!=null && selecteditems.getItemCount()>0){ ! DimensionItem dimension = schema.getDimension(selecteditems.getSelectionItem(1).getGroupName()); ! //Group is always the second element if (selecteditems.getItemCount()>1){ ! GroupItem group = dimension.getGroup(selecteditems.getSelectionItem(2).getGroupName()); ! //Get the drilldown options DrillDownItem[] drilldowns = group.getDrilldowns(); ! //This will be used to extract names from DrillDownItems String[] ddNames = null; ! if (selecteditems.getItemCount()>2){ //At least one drilldown has already been selected --- 250,299 ---- } } ! //close the table retVal.append("\n</td></tr></table>"); ! return retVal.toString(); }*/ ! /** * doDrillDowns creates select lists of tables and fields that should appear * on the grid (report) ! * * @param schema XTabSchema for the session * @param selecteditems Selector representing previously selected dimensions * @param direction String matching on of the pocOLAPConstants directional variables\ * @return String HTML formatted lists of tables and fields ! */ /* protected String doDrillDowns( XTabSchema schema, Selector selecteditems, String direction){ ! StringBuffer retVal = new StringBuffer(); ! //DrillDowns are always element 3 or higher int number = 3; ! //We'll use this before the last option for visual effect String stepDown = "\n</td></tr><tr><td> </td><td>"; ! //Dimension is always first element if (selecteditems!=null && selecteditems.getItemCount()>0){ ! DimensionItem dimension = schema.getDimension(selecteditems.getSelectionItem(1).getGroupName()); ! //Group is always the second element if (selecteditems.getItemCount()>1){ ! GroupItem group = dimension.getGroup(selecteditems.getSelectionItem(2).getGroupName()); ! //Get the drilldown options DrillDownItem[] drilldowns = group.getDrilldowns(); ! //This will be used to extract names from DrillDownItems String[] ddNames = null; ! if (selecteditems.getItemCount()>2){ //At least one drilldown has already been selected *************** *** 301,307 **** //and display it's drilldowns. Keep doing this until //we hit the last selecteditem that do the drilldowns ! //for that group (if any exist). I know that's a lot to //digest - don't worry, I'll walk you through it! ! // _outdated: Since dimension is 0, group is 1, we will loop through // _outdated: selected items starting at 2 and go to the end --- 301,307 ---- //and display it's drilldowns. Keep doing this until //we hit the last selecteditem that do the drilldowns ! //for that group (if any exist). I know that's a lot to //digest - don't worry, I'll walk you through it! ! // _outdated: Since dimension is 0, group is 1, we will loop through // _outdated: selected items starting at 2 and go to the end *************** *** 312,318 **** //Extract drilldown names if (drilldowns!=null){ ! ddNames = getPreviouslyUnusedDrillDowns(selecteditems,drilldowns,x-1); ! if (ddNames!=null){ retVal.append(getBreakTag(direction)); --- 312,318 ---- //Extract drilldown names if (drilldowns!=null){ ! ddNames = getPreviouslyUnusedDrillDowns(selecteditems,drilldowns,x-1); ! if (ddNames!=null){ retVal.append(getBreakTag(direction)); *************** *** 321,334 **** }else{ break; ! } } ! } } //Whatever the last item picked was, we need to get the drilldowns //for it, write the stepDown, then write the element ! //Extract drilldown names, excluding drilldowns that are ! //already picked ! if (drilldowns!=null){ ddNames= getPreviouslyUnusedDrillDowns(selecteditems,drilldowns,selecteditems.getItemCount()); if (ddNames!=null){ --- 321,334 ---- }else{ break; ! } } ! } } //Whatever the last item picked was, we need to get the drilldowns //for it, write the stepDown, then write the element ! //Extract drilldown names, excluding drilldowns that are ! //already picked ! if (drilldowns!=null){ ddNames= getPreviouslyUnusedDrillDowns(selecteditems,drilldowns,selecteditems.getItemCount()); if (ddNames!=null){ *************** *** 342,346 **** return retVal.toString(); }*/ ! /** --- 342,346 ---- return retVal.toString(); }*/ ! /** *************** *** 348,352 **** * for drilling down - eliminates the ability to drilldown into a dimension that has * already been drilled into (endless loop). ! * * @param selecteditems Selector representing previously selected dimensions * @param drilldowns DrillDownItem[] from XTabSchema --- 348,352 ---- * for drilling down - eliminates the ability to drilldown into a dimension that has * already been drilled into (endless loop). ! * * @param selecteditems Selector representing previously selected dimensions * @param drilldowns DrillDownItem[] from XTabSchema *************** *** 355,359 **** */ /*protected String[] getPreviouslyUnusedDrillDowns( ! Selector selecteditems, DrillDownItem[] drilldowns, int currentItem){ --- 355,359 ---- */ /*protected String[] getPreviouslyUnusedDrillDowns( ! Selector selecteditems, DrillDownItem[] drilldowns, int currentItem){ *************** *** 367,371 **** boolean wasFound = false; String checkName = drilldowns[x].getName(); ! //We can safely skip the first selecteditem since it is a //DimensionItem and we are only interested in DrillDownItem //names (which are just names of GroupItems) --- 367,371 ---- boolean wasFound = false; String checkName = drilldowns[x].getName(); ! //We can safely skip the first selecteditem since it is a //DimensionItem and we are only interested in DrillDownItem //names (which are just names of GroupItems) *************** *** 384,388 **** } } ! //Convert the vector to an array if (unused.size()>0){ --- 384,388 ---- } } ! //Convert the vector to an array if (unused.size()>0){ *************** *** 392,396 **** } } ! return retVal; }*/ --- 392,396 ---- } } ! return retVal; }*/ *************** *** 398,421 **** /** * doGroups creates a select list for groups of an XTabSchema ! * * @param schema XTabSchema for the session * @param selecteditems Selector representing currently selected dimensions * @param direction String matching one of the pocOLAPConstants directional variables * @throws IOException if content can't be written ! */ /* protected String doGroups( XTabSchema schema, Selector selecteditems, String direction){ ! StringBuffer retVal = new StringBuffer(); //Groups are always the second element ! int number = 2; //Selected dimension is always first element String selectedDimension = selecteditems.getSelectionItem(1).getGroupName(); ! if (selectedDimension!=null){ DimensionItem dim = schema.getDimension(selectedDimension); ! //Selected group (if exists) is always second element String selectedGroup = null; --- 398,421 ---- /** * doGroups creates a select list for groups of an XTabSchema ! * * @param schema XTabSchema for the session * @param selecteditems Selector representing currently selected dimensions * @param direction String matching one of the pocOLAPConstants directional variables * @throws IOException if content can't be written ! */ /* protected String doGroups( XTabSchema schema, Selector selecteditems, String direction){ ! StringBuffer retVal = new StringBuffer(); //Groups are always the second element ! int number = 2; //Selected dimension is always first element String selectedDimension = selecteditems.getSelectionItem(1).getGroupName(); ! if (selectedDimension!=null){ DimensionItem dim = schema.getDimension(selectedDimension); ! //Selected group (if exists) is always second element String selectedGroup = null; *************** *** 425,429 **** selectedGroup = dim.getDefGroup(); } ! //Get the group names GroupItem[] groups = dim.getGroups(); --- 425,429 ---- selectedGroup = dim.getDefGroup(); } ! //Get the group names GroupItem[] groups = dim.getGroups(); *************** *** 432,436 **** groupNames[x]=groups[x].getName(); } ! //Draw the element retVal.append(XTabMain.drawSelectList(groupNames,direction+number,selectedGroup,false)); --- 432,436 ---- groupNames[x]=groups[x].getName(); } ! //Draw the element retVal.append(XTabMain.drawSelectList(groupNames,direction+number,selectedGroup,false)); *************** *** 438,445 **** return retVal.toString(); } */ ! /** * doDimensions creates a select list for dimensions of an XTabSchema ! * * @param dimensions String[] of dimensions from XTabSchema for the session * @param selected String selected dimension --- 438,445 ---- return retVal.toString(); } */ ! /** * doDimensions creates a select list for dimensions of an XTabSchema ! * * @param dimensions String[] of dimensions from XTabSchema for the session * @param selected String selected dimension *************** *** 451,468 **** String selected, String direction){ ! StringBuffer retVal = new StringBuffer(); ! boolean forceTopLevel = (selected==null); int number = 1; //Dimensions are always the first select list retVal.append(XTabMain.drawSelectList(dimensions,direction+number,selected,forceTopLevel)); ! return retVal.toString(); }*/ ! /** * getBreakTag determines whether a <code><br/></code> tag should * be output ! * * @param direction String matching one of the pocOLAPConstants directional variables * @return String suitable for html output --- 451,468 ---- String selected, String direction){ ! StringBuffer retVal = new StringBuffer(); ! boolean forceTopLevel = (selected==null); int number = 1; //Dimensions are always the first select list retVal.append(XTabMain.drawSelectList(dimensions,direction+number,selected,forceTopLevel)); ! return retVal.toString(); }*/ ! /** * getBreakTag determines whether a <code><br/></code> tag should * be output ! * * @param direction String matching one of the pocOLAPConstants directional variables * @return String suitable for html output *************** *** 475,478 **** return retVal; }*/ ! } --- 475,478 ---- return retVal; }*/ ! } |