querytag.java
来自「数据仓库展示程序」· Java 代码 · 共 87 行
JAVA
87 行
/*
// $Id: //open/mondrian/src/main/mondrian/web/taglib/QueryTag.java#4 $
// 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-2005 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.BodyTagSupport;
/**
* 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(), pageContext.getServletContext(), 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
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?