Java 类net.sf.jasperreports.engine.JRValueParameter 实例源码

项目:jasperreports    文件:JRJpaQueryExecuter.java   
/**
 * 
 */
public JRJpaQueryExecuter(
    JasperReportsContext jasperReportsContext, 
    JRDataset dataset, 
    Map<String,? extends JRValueParameter> parameters
    ) 
{
    super(jasperReportsContext, dataset, parameters);

    em = (EntityManager)getParameterValue(JRJpaQueryExecuterFactory.PARAMETER_JPA_ENTITY_MANAGER);
    reportMaxCount = (Integer)getParameterValue(JRParameter.REPORT_MAX_COUNT);

    if (em == null) {
        log.warn("The supplied javax.persistence.EntityManager object is null.");
    }

    parseQuery();
}
项目:jasperreports    文件:JaxenXPathQueryExecuter.java   
/**
 * 
 */
public JaxenXPathQueryExecuter(
    JasperReportsContext jasperReportsContext,
    JRDataset dataset, 
    Map<String,? extends JRValueParameter> parametersMap
    )
{
    super(jasperReportsContext, dataset, parametersMap);

    document = (Document) getParameterValue(JaxenXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT);
    documentBuilderFactory = (DocumentBuilderFactory) getParameterValue(
            JaxenXPathQueryExecuterFactory.PARAMETER_DOCUMENT_BUILDER_FACTORY, true);
    namespacesMap = (Map<String, String>) getParameterValue(
            JaxenXPathQueryExecuterFactory.PARAMETER_XML_NAMESPACE_MAP, true);

    if (document == null)
    {
        log.warn("The supplied org.w3c.dom.Document object is null.");
    }

    parseQuery();
}
项目:jasperreports    文件:XalanXPathQueryExecuter.java   
/**
 * 
 */
public XalanXPathQueryExecuter(
    JasperReportsContext jasperReportsContext, 
    JRDataset dataset, 
    Map<String,? extends JRValueParameter> parametersMap
    )
{
    super(jasperReportsContext, dataset, parametersMap);

    document = (Document) getParameterValue(XalanXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT);
    documentBuilderFactory = (DocumentBuilderFactory) getParameterValue(
            XalanXPathQueryExecuterFactory.PARAMETER_DOCUMENT_BUILDER_FACTORY, true);
    namespacesMap = (Map<String, String>) getParameterValue(
            XalanXPathQueryExecuterFactory.PARAMETER_XML_NAMESPACE_MAP, true);

    if (document == null)
    {
        log.warn("The supplied org.w3c.dom.Document object is null.");
    }

    parseQuery();
}
项目:jasperreports    文件:JRHibernateQueryExecuter.java   
/**
 * 
 */
public JRHibernateQueryExecuter(
    JasperReportsContext jasperReportsContext, 
    JRDataset dataset, Map<String, ? extends JRValueParameter> parameters
    )
{
    super(jasperReportsContext, dataset, parameters);

    session = (Session) getParameterValue(JRHibernateQueryExecuterFactory.PARAMETER_HIBERNATE_SESSION);
    reportMaxCount = (Integer) getParameterValue(JRParameter.REPORT_MAX_COUNT);
    isClearCache = getPropertiesUtil().getBooleanProperty(dataset, 
            JRHibernateQueryExecuterFactory.PROPERTY_HIBERNATE_CLEAR_CACHE,
            false);

    if (session == null)
    {
        log.warn("The supplied org.hibernate.Session object is null.");
    }

    parseQuery();
}
项目:jasperreports    文件:JRHibernateQueryExecuter.java   
/**
 * Binds values for all the query parameters.
 */
protected void setParameters()
{
    List<String> parameterNames = getCollectedParameterNames();

    if (!parameterNames.isEmpty())
    {
        Set<String> namesSet = new HashSet<String>();

        for (Iterator<String> iter = parameterNames.iterator(); iter.hasNext();)
        {
            String parameterName = iter.next();
            if (namesSet.add(parameterName))
            {
                JRValueParameter parameter = getValueParameter(parameterName);
                setParameter(parameter);
            }
        }
    }
}
项目:jasperreports    文件:DateRangeSQLBetweenClause.java   
@Override
protected ClauseFunctionParameterHandler createParameterHandler(JRQueryClauseContext queryContext, 
        String clauseId, String parameterName, boolean left)
{
    JRValueParameter valueParameter = queryContext.getValueParameter(parameterName);
    Object value = valueParameter.getValue();
    if (Date.class.isAssignableFrom(valueParameter.getValueClass()) || value instanceof Date)
    {
        // treat as regular parameter
        return new DefaultClauseFunctionParameterHandler(queryContext, parameterName, value);
    }

    if (value != null && !(value instanceof DateRange))
    {
        throw 
            new JRRuntimeException(
                EXCEPTION_MESSAGE_KEY_UNSUPPORTED_PARAMETER_TYPE,
                new Object[]{parameterName, clauseId, value.getClass().getName()});
    }

    boolean useRangeStart = left ? isLeftClosed(clauseId) : !isRightClosed(clauseId);
    return new DateRangeParameterHandler(queryContext, parameterName, 
            (DateRange) value, useRangeStart);
}
项目:jasperreports    文件:JRMondrianQueryExecuter.java   
/**
 * 
 */
public JRMondrianQueryExecuter(
    JasperReportsContext jasperReportsContext, 
    JRDataset dataset, 
    Map<String,? extends JRValueParameter> parametersMap
    )
{
    super(jasperReportsContext, dataset, parametersMap);

    connection = (Connection) getParameterValue(JRMondrianQueryExecuterFactory.PARAMETER_MONDRIAN_CONNECTION);

    if (connection == null)
    {
        log.warn("The supplied mondrian.olap.Connection object is null.");
    }

    parseQuery();
}
项目:PDFReporter-Studio    文件:XmlaFieldsProvider.java   
@Override
public List<JRDesignField> getFields(DataAdapterService con, JasperReportsConfiguration jConfig, JRDataset jDataset) throws JRException, UnsupportedOperationException {

    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("REPORT_PARAMETERS_MAP", new HashMap<String, Object>());
    try {
        //Here there is the password of the connection
        con.contributeParameters(parameters);
    } catch (JRException e) {
        e.printStackTrace();
    }
    ParameterUtil.setParameters(jConfig, jDataset, parameters);
    parameters.put(JRParameter.REPORT_MAX_COUNT, 2);
    Map<String,? extends JRValueParameter> tmpMap  = ParameterUtil.convertMap(parameters, jDataset);

    JRXmlaQueryExecuter qe = new JRXmlaQueryExecuter(jConfig, jDataset, tmpMap);
    JROlapResult result = qe.getResult();
    return OlapFieldsProviderSupport.getFieldsFromResult(result);
}
项目:PDFReporter-Studio    文件:MondrianFieldsProvider.java   
@Override
public List<JRDesignField> getFields(DataAdapterService con, JasperReportsConfiguration jConfig, JRDataset jDataset) throws JRException, UnsupportedOperationException {
    Map<String, Object> parameters = new HashMap<String, Object>();
    con.contributeParameters(parameters);

    ParameterUtil.setParameters(jConfig, jDataset, parameters);
    parameters.put(JRParameter.REPORT_MAX_COUNT, 0);

    // JasperReports query executer instances require
    // REPORT_PARAMETERS_MAP parameter to be defined and not null
    Map<String, JRValueParameter> tmpMap = ParameterUtil.convertMap(parameters, jDataset);
    tmpMap.put(JRParameter.REPORT_PARAMETERS_MAP, new SimpleValueParameter(new HashMap<String, JRValueParameter>()));

    JRMondrianQueryExecuter qe = new JRMondrianQueryExecuter(jConfig, jDataset, tmpMap);
    qe.createDatasource();

    JRMondrianResult result = new JRMondrianResult(qe.getResult());
    return OlapFieldsProviderSupport.getFieldsFromResult(result);
}
项目:ireport-fork    文件:SQLFieldsProvider.java   
public static Map<String, JRValueParameter> convertMap(JRDataset dataset, Map<String, ?> inmap) {
        Map<String, JRValueParameter> outmap = new HashMap<String, JRValueParameter>();
        for (String key : inmap.keySet())
        {
                SimpleValueParameter svp = new SimpleValueParameter(inmap.get(key));

                // Let's set the correct class name for this parameter...
                for (JRParameter p : dataset.getParameters() )
                {
                    if (p.getName() != null && p.getName().equals(key))
                    {
                        svp.setValueClassName( p.getValueClassName());
                        break;
                    }
                }
                outmap.put(key, svp);
        }
        return outmap;
}
项目:jasperreports    文件:ParameterTypeSelectorClauseFunction.java   
protected Class<?> determineParameterType(JRClauseTokens clauseTokens,
        JRQueryClauseContext queryContext, int parameterPosition)
{
    String parameterName = clauseTokens.getToken(parameterPosition);
    if (parameterName == null)
    {
        throw 
            new JRRuntimeException(
                EXCEPTION_MESSAGE_KEY_QUERY_PARAMETER_TYPE_SELECTOR_CLAUSE_IMPLEMENTATION_NOT_FOUND,
                new Object[]{parameterPosition, clauseTokens.getClauseId()});
    }

    // the method throws an exception if it doesn't find the parameter, 
    // so we don't have to handle that case here
    JRValueParameter parameter = queryContext.getValueParameter(parameterName);

    Class<?> parameterType;
    Object parameterValue = parameter.getValue();
    if (parameterValue == null)
    {
        // if we don't have a value, use the declared type
        parameterType = parameter.getValueClass();
    }
    else
    {
        // use the actual value
        parameterType = parameterValue.getClass();
    }

    if (log.isDebugEnabled())
    {
        log.debug("query clause parameter " + parameterName 
                + " at position " + parameterPosition 
                + " has type " + parameterType.getName());
    }

    return parameterType;
}
项目:jasperreports    文件:JsonQueryExecuter.java   
/**
 * 
 */
public JsonQueryExecuter(
    JasperReportsContext jasperReportsContext,
    JRDataset dataset, 
    Map<String, ? extends JRValueParameter> parametersMap
    )
{
    super(jasperReportsContext, dataset, parametersMap);
}
项目:jasperreports    文件:JRXlsxQueryExecuterFactory.java   
@Override
public JRQueryExecuter createQueryExecuter(
    JasperReportsContext jasperReportsContext,
    JRDataset dataset, 
    Map<String,? extends JRValueParameter> parameters
    ) throws JRException 
{
    return new JRXlsxQueryExecuter(jasperReportsContext, dataset, parameters);
}
项目:jasperreports    文件:JRXPathQueryExecuterFactory.java   
@Override
public JRQueryExecuter createQueryExecuter(
    JasperReportsContext jasperReportsContext, 
    JRDataset dataset, 
    Map<String,? extends JRValueParameter> parameters
    ) throws JRException
{
    return new JRXPathQueryExecuter(jasperReportsContext, dataset, parameters);
}
项目:jasperreports    文件:JRJpaQueryExecuterFactory.java   
@Override
public JRQueryExecuter createQueryExecuter(
    JasperReportsContext jasperReportsContext,
    JRDataset dataset, 
    Map<String,? extends JRValueParameter> parameters
    ) throws JRException 
{
    return new JRJpaQueryExecuter(jasperReportsContext, dataset, parameters);
}
项目:jasperreports    文件:JRAbstractQueryExecuter.java   
/**
 * 
 */
protected JRAbstractQueryExecuter(
    JasperReportsContext jasperReportsContext, 
    JRDataset dataset, 
    Map<String, ? extends JRValueParameter> parametersMap
    )
{
    this.jasperReportsContext = jasperReportsContext;
    this.propertiesUtil = JRPropertiesUtil.getInstance(jasperReportsContext);
    this.dataset = dataset;
    this.parametersMap = parametersMap;

    queryString = "";
    queryParameters = new ArrayList<QueryParameterEntry>();
}
项目:jasperreports    文件:JRAbstractQueryExecuter.java   
/**
 * 
 */
protected boolean parameterHasValue(String parameter)
{
    JRValueParameter reportParametersMap = getValueParameter(JRParameter.REPORT_PARAMETERS_MAP, false);
    @SuppressWarnings("unchecked")
    Map<String,Object> parametersMap = (Map<String,Object>)reportParametersMap.getValue();  
    return parametersMap.containsKey(parameter);
}
项目:jasperreports    文件:JRAbstractQueryExecuter.java   
/**
 * Return a value parameter from the parameters map.
 * 
 * @param parameterName the parameter name
 * @param ignoreMissing if <code>true</code>, the method will return null for non existing parameters;
 *      otherwise, an exception will be thrown if the parameter does not exist
 * @return the parameter
 */
protected JRValueParameter getValueParameter(String parameterName, boolean ignoreMissing)
{
    JRValueParameter parameter = parametersMap.get(parameterName);

    if (parameter == null && !ignoreMissing)
    {
        throw 
            new JRRuntimeException(
                EXCEPTION_MESSAGE_KEY_PARAMETER_NOT_FOUND,
                new Object[]{parameterName});
    }

    return parameter;
}
项目:jasperreports    文件:JsonQueryExecuterFactory.java   
@Override
public JRQueryExecuter createQueryExecuter(
    JasperReportsContext jasperReportsContext,
    JRDataset dataset, 
    Map<String, ? extends JRValueParameter> parameters
    ) throws JRException
{
    return new JsonQueryExecuter(jasperReportsContext, dataset, parameters);
}
项目:jasperreports    文件:JRXPathQueryExecuter.java   
/**
 * 
 */
public JRXPathQueryExecuter(
    JasperReportsContext jasperReportsContext,
    JRDataset dataset, 
    Map<String,? extends JRValueParameter> parametersMap
    )
{
    super(jasperReportsContext, dataset, parametersMap);

    parseQuery();
}
项目:jasperreports    文件:ExcelQueryExecuter.java   
/**
 * 
 */
protected ExcelQueryExecuter(
    JasperReportsContext jasperReportsContext, 
    JRDataset dataset, 
    Map<String,? extends JRValueParameter> parametersMap
    ) 
{
    super(jasperReportsContext, dataset, parametersMap);
}
项目:jasperreports    文件:JRAbstractQueryExecuterFactory.java   
@Override
public JRQueryExecuter createQueryExecuter(
    JasperReportsContext jasperReportsContext,
    JRDataset dataset, 
    Map<String, ? extends JRValueParameter> parameters
    ) throws JRException 
{
    return createQueryExecuter(dataset, parameters);
}
项目:jasperreports    文件:JRJdbcQueryExecuter.java   
protected void setStatementParameter(int parameterIndex, String parameterName) throws SQLException
{
    JRValueParameter parameter = getValueParameter(parameterName);
    Class<?> clazz = parameter.getValueClass();
    Object parameterValue = parameter.getValue();

    if (log.isDebugEnabled())
    {
        log.debug("Parameter #" + parameterIndex + " (" + parameterName + " of type " + clazz.getName() + "): " + parameterValue);
    }

    setStatementParameter(parameterIndex, clazz, parameterValue, parameter);
}
项目:jasperreports    文件:JRCsvQueryExecuterFactory.java   
@Override
public JRQueryExecuter createQueryExecuter(
    JasperReportsContext jasperReportsContext,
    JRDataset dataset, 
    Map<String, ? extends JRValueParameter> parameters
    ) throws JRException 
{
    return new JRCsvQueryExecuter(jasperReportsContext, dataset, parameters);
}
项目:jasperreports    文件:XlsQueryExecuter.java   
/**
 * 
 */
protected XlsQueryExecuter(
    JasperReportsContext jasperReportsContext, 
    JRDataset dataset, 
    Map<String,? extends JRValueParameter> parametersMap
    ) 
{
    super(jasperReportsContext, dataset, parametersMap);
}
项目:jasperreports    文件:JaxenXPathQueryExecuterFactory.java   
@Override
public JRQueryExecuter createQueryExecuter(
    JasperReportsContext jasperReportsContext, 
    JRDataset dataset, 
    Map<String,? extends JRValueParameter> parameters
    ) throws JRException
{
    return new JaxenXPathQueryExecuter(jasperReportsContext, dataset, parameters);
}
项目:jasperreports    文件:JsonQLQueryExecuterFactory.java   
@Override
public JRQueryExecuter createQueryExecuter(
    JasperReportsContext jasperReportsContext,
    JRDataset dataset, 
    Map<String, ? extends JRValueParameter> parameters
    ) throws JRException
{
    return new JsonQLQueryExecuter(jasperReportsContext, dataset, parameters);
}
项目:jasperreports    文件:AbstractQueryExecuterFactory.java   
/**
 * @deprecated Replaced by {@link #createQueryExecuter(JasperReportsContext, JRDataset, Map)}.
 */
@Override
public final JRQueryExecuter createQueryExecuter(
    JRDataset dataset, 
    Map<String, ? extends JRValueParameter> parameters
    ) throws JRException 
{
    return createQueryExecuter(DefaultJasperReportsContext.getInstance(), dataset, parameters);
}
项目:jasperreports    文件:ExcelQueryExecuterFactory.java   
@Override
public JRQueryExecuter createQueryExecuter(
    JasperReportsContext jasperReportsContext,
    JRDataset dataset, 
    Map<String,? extends JRValueParameter> parameters
    ) throws JRException 
{
    return new ExcelQueryExecuter(jasperReportsContext, dataset, parameters);
}
项目:jasperreports    文件:JRHibernateQueryExecuterFactory.java   
@Override
public JRQueryExecuter createQueryExecuter(
    JasperReportsContext jasperReportsContext, 
    JRDataset dataset, 
    Map<String, ? extends JRValueParameter> parameters
    ) throws JRException
{
    return new JRHibernateQueryExecuter(jasperReportsContext, dataset, parameters);
}
项目:jasperreports    文件:JRJdbcQueryExecuterFactory.java   
@Override
public JRQueryExecuter createQueryExecuter(
    JasperReportsContext jasperReportsContext,
    JRDataset dataset, 
    Map<String,? extends JRValueParameter> parameters
    ) throws JRException
{
    return new JRJdbcQueryExecuter(jasperReportsContext, dataset, parameters);
}
项目:jasperreports    文件:XalanXPathQueryExecuterFactory.java   
@Override
public JRQueryExecuter createQueryExecuter(
    JasperReportsContext jasperReportsContext, 
    JRDataset dataset, 
    Map<String,? extends JRValueParameter> parameters
    ) throws JRException
{
    return new XalanXPathQueryExecuter(jasperReportsContext, dataset, parameters);
}
项目:jasperreports    文件:JRCsvQueryExecuter.java   
/**
 * 
 */
protected JRCsvQueryExecuter(
    JasperReportsContext jasperReportsContext,
    JRDataset dataset, 
    Map<String, ? extends JRValueParameter> parametersMap
    ) 
{
    super(jasperReportsContext, dataset, parametersMap);
}
项目:jasperreports    文件:AbstractJsonQueryExecuter.java   
/**
 *
 */
public AbstractJsonQueryExecuter(
    JasperReportsContext jasperReportsContext,
    JRDataset dataset, 
    Map<String, ? extends JRValueParameter> parametersMap
    )
{
    super(jasperReportsContext, dataset, parametersMap);
    parseQuery();
}
项目:jasperreports    文件:XlsQueryExecuterFactory.java   
@Override
public JRQueryExecuter createQueryExecuter(
    JasperReportsContext jasperReportsContext, 
    JRDataset dataset, 
    Map<String,? extends JRValueParameter> parameters
    ) throws JRException 
{
    return new XlsQueryExecuter(jasperReportsContext, dataset, parameters);
}
项目:jasperreports    文件:JRXlsxQueryExecuter.java   
/**
 * 
 */
protected JRXlsxQueryExecuter(
    JasperReportsContext jasperReportsContext, 
    JRDataset dataset, 
    Map<String,? extends JRValueParameter> parametersMap
    ) 
{
    super(jasperReportsContext, dataset, parametersMap);
}
项目:jasperreports    文件:AbstractXlsQueryExecuter.java   
/**
 * 
 */
protected AbstractXlsQueryExecuter(
    JasperReportsContext jasperReportsContext, 
    JRDataset dataset, 
    Map<String,? extends JRValueParameter> parametersMap
    ) 
{
    super(jasperReportsContext, dataset, parametersMap);
}
项目:jasperreports    文件:JsonQLQueryExecuter.java   
/**
 *
 */
public JsonQLQueryExecuter(
    JasperReportsContext jasperReportsContext,
    JRDataset dataset, 
    Map<String, ? extends JRValueParameter> parametersMap
    )
{
    super(jasperReportsContext, dataset, parametersMap);
}
项目:jasperreports    文件:JRHibernateQueryExecuter.java   
/**
 * Binds a parameter value to a query parameter.
 * 
 * @param parameter the report parameter
 */
protected void setParameter(JRValueParameter parameter)
{
    String hqlParamName = getHqlParameterName(parameter.getName());
    Class<?> clazz = parameter.getValueClass();
    Object parameterValue = parameter.getValue();

    if (log.isDebugEnabled())
    {
        log.debug("Parameter " + hqlParamName + " of type " + clazz.getName() + ": " + parameterValue);
    }

    Type type = hibernateTypeMap.get(clazz);

    if (type != null)
    {
        query.setParameter(hqlParamName, parameterValue, type);
    }
    else if (Collection.class.isAssignableFrom(clazz))
    {
        query.setParameterList(hqlParamName, (Collection<?>) parameterValue);
    }
    else
    {
        if (session.getSessionFactory().getClassMetadata(clazz) != null) //param type is a hibernate mapped entity
        {
            query.setEntity(hqlParamName, parameterValue);
        }
        else //let hibernate try to guess the type
        {
            query.setParameter(hqlParamName, parameterValue);
        }
    }
}
项目:jasperreports    文件:JRQueryExecuterUtils.java   
@Override
public JRQueryExecuter createQueryExecuter(
    JasperReportsContext jasperReportsContext, 
    JRDataset dataset,
    Map<String, ? extends JRValueParameter> parameters
    ) throws JRException 
{
    return factory.createQueryExecuter(dataset, parameters);
}