/* // $Id: //guest/paul_dymecki/mondrian/src/main/mondrian/web/taglib/QueryTag.java#1 $ // This software is subject to the terms of the Common Public License // Agreement, available at the following URL: // http://www.opensource.org/licenses/cpl.html. // (C) Copyright 2002 Kana Software, Inc. and others. // All Rights Reserved. // You must accept the terms of that agreement to use this software. // // Andreas Voss, 22 March, 2002 */ package mondrian.web.taglib; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.*; import mondrian.olap.Result; /** * A <code>QueryTag</code> creates a {@link ResultCache} object and initializes * it with the MDX query. Example:<blockquote> * * <pre><query name="query1" resultCache="true"> * select * {[Measures].[Unit Sales], [Measures].[Store Cost]} on columns, * CrossJoin( * { [Promotion Media].[All Promotion Media].[Radio], * [Promotion Media].[All Promotion Media].[TV], * [Promotion Media].[All Promotion Media].[Sunday Paper], * [Promotion Media].[All Promotion Media].[Street Handout] }, * [Product].[All Products].[Drink].children) on rows * from Sales * where ([Time].[1997]) * </query></pre> * * </blockquote> * * Attributes are * {@link #setName name}, * {@link #setResultCache resultCache}. **/ public class QueryTag extends BodyTagSupport { public QueryTag() { } public int doAfterBody() throws JspException { try { ApplResources ar = ApplResources.getInstance(pageContext.getServletContext()); ResultCache rc = ResultCache.getInstance(pageContext.getSession(), name); // if this is the first call, we have to parse the mdx query if (!resultCache || rc.getQuery() == null) { String mdx = getBodyContent().getString(); rc.parse(mdx); } return SKIP_BODY; } catch (Exception e) { e.printStackTrace(); throw new JspException(e); } } /** Sets string attribute <code>name</code>, which identifies this query * within its page. The {@link TransformTag#setQuery <transform * query>} attribute uses this. **/ public void setName(String newName) { name = newName; } public String getName() { return name; } /** Sets boolean attribute <code>resultCache</code>; if true, the query is * parsed, executed, and converted to an XML document at most once. This * improves performance and consistency, but the results may become out of * date. We also need a way to prevent the cache using too much memory. **/ public void setResultCache(boolean newResultCache) { resultCache = newResultCache; } public boolean isResultCache() { return resultCache; } private String name; private boolean resultCache; } // End QueryTag.java
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 1820 | Paul Robert Dymecki | mondrian: Integrate latest from //guest/julian_hyde | ||
//guest/julian_hyde/mondrian/src/main/mondrian/web/taglib/QueryTag.java | |||||
#2 | 1622 | Julian Hyde | mondrian: Javadoc. | ||
#1 | 1603 | Julian Hyde |
mondrian: Add Andreas' taglib; Rename 'mondrian.rolap.Util.assert' to 'assertTrue', because 'assert' is a keyword in jdk 1.4; Fix 'NON EMPTY'; JUnit framework for tests; Add Oracle dataset. |