Java 类net.sf.jasperreports.engine.query.QueryExecuterFactory 实例源码

项目:jasperreports    文件:JRFillDataset.java   
/**
 * Creates the data source from a connection.
 * 
 * @return the data source to be used
 * @throws JRException
 */
private JRDataSource createQueryDatasource() throws JRException
{
    if (query == null)
    {
        return null;
    }

    try
    {
        if (log.isDebugEnabled())
        {
            log.debug("Fill " + filler.fillerId + ": Creating " + query.getLanguage() + " query executer");
        }

        QueryExecuterFactory queryExecuterFactory = JRQueryExecuterUtils.getInstance(getJasperReportsContext()).getExecuterFactory(query.getLanguage());
        queryExecuter = queryExecuterFactory.createQueryExecuter(getJasperReportsContext(), this, parametersMap);
        filler.fillContext.setRunningQueryExecuter(queryExecuter);

        return queryExecuter.createDatasource();
    }
    finally
    {
        filler.fillContext.clearRunningQueryExecuter();
    }
}
项目:PDFReporter-Studio    文件:SyncDatasetRunParameters.java   
public static Object[] getBuiltInParameters(JasperReportsConfiguration jConf, String mLang) throws JRException {
    JRQueryExecuterUtils qeUtils = JRQueryExecuterUtils.getInstance(jConf);
    QueryExecuterFactory qef = qeUtils.getExecuterFactory(mLang);
    if (qef != null) {
        Object[] prms = qef.getBuiltinParameters();
        if (bipMap.containsKey(mLang)) {
            Object[] params = bipMap.get(mLang);
            if (prms == null || prms.length == 0)
                return params;

            Object[] tmp = new Object[prms.length + params.length];
            System.arraycopy(prms, 0, tmp, 0, prms.length);
            System.arraycopy(params, 0, tmp, prms.length, params.length);
            return tmp;
        }
        return prms;
    }
    return null;
}
项目:jasperreports    文件:PropertiesMetadataUtil.java   
protected String queryExecuterQualification(String queryLanguage) throws JRException
{
    QueryExecuterFactory queryExecuterFactory = JRQueryExecuterUtils.getInstance(context).getExecuterFactory(queryLanguage);
    if (!(queryExecuterFactory instanceof Designated))
    {
        return null;
    }
    String queryExecuterName = ((Designated) queryExecuterFactory).getDesignation();
    return queryExecuterName;
}
项目:ESJasperAdapter    文件:ESQueryExecuterFactoryBundle.java   
public QueryExecuterFactory getQueryExecuterFactory(String language)
        throws JRException {
                       logger.debug("Begin asked for a factory for: " +language);
    if (ESDataSource.QUERY_LANGUAGE.equals(language)) {
        logger.debug("Returning a ESQueryExecuterFactory");
        return (QueryExecuterFactory) cache
                .getCachedInstance(ESQueryExecuterFactory.class
                        .getName());
    }
    return null;
}
项目:PDFReporter-Studio    文件:JrxQueryExecuterFactoryBundle.java   
public QueryExecuterFactory getQueryExecuterFactory(String language)
        throws JRException {
    if (language
            .equalsIgnoreCase(PlSqlQueryExecuterFactory.QUERY_LANGUAGE_PLSQL))
        return cache.getCachedInstance(PlSqlQueryExecuterFactory.class
                .getName());
    if (language
            .equalsIgnoreCase(JRXPathQueryExecuterFactory.QUERY_LANGUAGE))
        return cache.getCachedInstance(JRXPathQueryExecuterFactory.class
                .getName());

    return null;
}
项目:PDFReporter-Studio    文件:EmptyQueryExecuterFactoryBundle.java   
protected void init(ExtensionsRegistry extensionsRegistry) {
    ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
    Object cl = jasperReportsContext.getValue(AbstractClasspathAwareDataAdapterService.CURRENT_CLASS_LOADER);
    if (cl != null && cl instanceof ClassLoader)
        Thread.currentThread().setContextClassLoader((ClassLoader) cl);
    try {
        oldExtensionsRegistry = extensionsRegistry;
        Set<String> langs = new HashSet<String>();
        mqef = new HashMap<String, QueryExecuterFactory>();
        List<JRQueryExecuterFactoryBundle> bundles = ExtensionsEnvironment.getExtensionsRegistry().getExtensions(JRQueryExecuterFactoryBundle.class);
        for (JRQueryExecuterFactoryBundle bundle : bundles) {
            if (!bundle.getClass().equals(this.getClass())) {
                if (bundle instanceof DefaultQueryExecuterFactoryBundle)
                    bundle = DefaultQueryExecuterFactoryBundle.getInstance(jasperReportsContext);

                String[] l = bundle.getLanguages();
                for (String lang : l) {
                    langs.add(lang);
                    if (!mqef.containsKey(lang))
                        try {
                            mqef.put(lang, bundle.getQueryExecuterFactory(lang));
                        } catch (JRException e) {
                            e.printStackTrace();
                        }
                }
            }
        }
        languages = langs.toArray(new String[langs.size()]);
    } finally {
        Thread.currentThread().setContextClassLoader(originalClassLoader);
    }
}
项目:jasperreports    文件:JRVerifier.java   
/**
 *
 */
private void verifyQuery(JRDesignDataset dataset)
{
    JRQuery query = dataset.getQuery();
    if (query != null)
    {
        String language = query.getLanguage();
        QueryExecuterFactory queryExecuterFactory = null;
        if (language == null || language.length() == 0)
        {
            addBrokenRule("Query language not set.", query);
        }
        else
        {
            try
            {
                queryExecuterFactory = JRQueryExecuterUtils.getInstance(jasperReportsContext).getExecuterFactory(query.getLanguage());
            }
            catch (JRException e1)
            {
                addBrokenRule("Query executer factory for " + language + " cannot be created.", query);
            }
        }


        JRQueryChunk[] chunks = query.getChunks();
        if (chunks != null && chunks.length > 0)
        {
            Map<String, JRParameter> parametersMap = dataset.getParametersMap();

            for(int j = 0; j < chunks.length; j++)
            {
                JRQueryChunk queryChunk = chunks[j];
                switch (queryChunk.getType())
                {
                    case JRQueryChunk.TYPE_PARAMETER :
                    {
                        JRParameter parameter = parametersMap.get(queryChunk.getText());
                        if ( parameter == null )
                        {
                            addBrokenRule("Query parameter not found : " + queryChunk.getText(), query);
                        }
                        else if (queryExecuterFactory != null)
                        {
                            String parameterType = null;
                            try
                            {
                                parameterType = parameter.getValueClassName();
                            }
                            catch (JRRuntimeException e)
                            {
                                // ignore, already added when the parameter got verified
                            }
                            if (parameterType != null && !queryExecuterFactory.supportsQueryParameterType(parameterType))
                            {
                                addBrokenRule("Parameter type not supported in query : " + queryChunk.getText() + " class " + parameterType, query);
                            }
                        }

                        break;
                    }
                    case JRQueryChunk.TYPE_PARAMETER_CLAUSE :
                    {
                        if (!parametersMap.containsKey(queryChunk.getText()))
                        {
                            addBrokenRule("Query parameter not found : " + queryChunk.getText(), query);
                        }
                        break;
                    }
                    case JRQueryChunk.TYPE_TEXT :
                    default :
                    {
                    }
                }
            }
        }
    }
}
项目:PDFReporter-Studio    文件:HBaseQueryExecuterFactoryBundle.java   
public QueryExecuterFactory getQueryExecuterFactory(String language) throws JRException {
    if (HBaseDataSource.QUERY_LANGUAGE.equals(language))
        return (QueryExecuterFactory) cache.getCachedInstance(HBaseQueryExecuterFactory.class.getName());
    return null;
}
项目:ireport-fork    文件:IRQueryExecuterFactoryBundle.java   
/**
 * 
 */
public QueryExecuterFactory getQueryExecuterFactory(String language)
        throws JRException {
    List<?> bundles = ExtensionsEnvironment.getExtensionsRegistry()
            .getExtensions(JRQueryExecuterFactoryBundle.class);
    for (Iterator<?> it = bundles.iterator(); it.hasNext();) {
        JRQueryExecuterFactoryBundle bundle = (JRQueryExecuterFactoryBundle) it
                .next();
        if (!bundle.getClass().equals(this.getClass())) {
            QueryExecuterFactory factory = bundle
                    .getQueryExecuterFactory(language);
            if (factory != null) {
                return factory;
            }
        }
    }

               // we have not found anything... let's see if iReport knows about it...
               //QueryExecuterDef
               List<QueryExecuterDef> qes = IReportManager.getInstance().getQueryExecuters();

               for (QueryExecuterDef qe : qes)
               {
                   if (qe.getLanguage().equals(language))
                   {
                       try {
                           return (QueryExecuterFactory)cache.getCachedInstance(qe.getClassName()); //QueryExecuterFactory)IReportManager.getJRExtensionsClassLoader().loadClass(qe.getClassName()).newInstance();
                       } catch (JRException ex) {
                           if (log.isWarnEnabled())
                               log.warn("Unable to instance the create a QueryExecuterFactory for the language  " + language + ": " + ex.getMessage());

                           System.out.println("Unable to instance the create a QueryExecuterFactory for the language  " + language + ": " + ex.getMessage());
                           System.out.flush();
                       }
                   }
               }

    if (log.isWarnEnabled())
        log.warn("No query executer factory class registered for "
                + language + " queries.");

    return (QueryExecuterFactory) cache
            .getCachedInstance(IRQueryExecuterFactory.class.getName());
}