Package org.pentaho.reporting.engine.classic.core

Examples of org.pentaho.reporting.engine.classic.core.ReportDataFactoryException


      {
        invocableEngine.invokeFunction("shutdownQuery");
      }
      catch (ScriptException e)
      {
        throw new ReportDataFactoryException("DataFactoryScriptingSupport: Failed to invoke query shutdown method.", e);
      }
      catch (NoSuchMethodException e)
      {
        // ignored ..
        logger.debug("Global script does not contain an 'shutdownQuery' function");
View Full Code Here


        }
        return retval.toArray(new String[retval.size()]);
      }
      catch (ScriptException e)
      {
        throw new ReportDataFactoryException("DataFactoryScriptingSupport: Failed to invoke computeQueryFields method.", e);
      }
      catch (NoSuchMethodException e)
      {
        // ignored ..
        logger.debug("Query script does not contain an 'computeQueryFields' function");
View Full Code Here

      throw new NullPointerException("Query is null."); //$NON-NLS-1$
    }
    final String realQuery = getQuery(query);
    if (realQuery == null)
    {
      throw new ReportDataFactoryException("Query '" + query + "' is not recognized."); //$NON-NLS-1$ //$NON-NLS-2$
    }
    return super.queryData(realQuery, parameters);
  }
View Full Code Here

    final int methodSeparatorIdx = query.indexOf('#');

    if ((methodSeparatorIdx + 1) >= query.length())
    {
      // If we have a method separator, then it cant be at the end of the text.
      throw new ReportDataFactoryException("Malformed query: " + query); //$NON-NLS-1$
    }

    if (methodSeparatorIdx == -1)
    {
      // we have no method. So this query must be a reference to a tablemodel
      // instance.
      final int parameterStartIdx = query.indexOf('(');
      final String[] parameterNames;
      final String constructorName;
      if (parameterStartIdx == -1)
      {
        parameterNames = StaticDataFactory.EMPTY_PARAMS;
        constructorName = query;
      }
      else
      {
        parameterNames = createParameterList(query, parameterStartIdx);
        constructorName = query.substring(0, parameterStartIdx);
      }

      try
      {
        final Constructor c = findDirectConstructor(constructorName, parameterNames.length);

        final Object[] params = new Object[parameterNames.length];
        for (int i = 0; i < parameterNames.length; i++)
        {
          final String name = parameterNames[i];
          params[i] = parameters.get(name);
        }
        return (TableModel) c.newInstance(params);
      }
      catch (Exception e)
      {
        throw new ReportDataFactoryException
            ("Unable to instantiate class for non static call.", e); //$NON-NLS-1$
      }
    }

    return createComplexTableModel
View Full Code Here

        methodParams[i] = parameters.get(name);
      }
      final Object data = m.invoke(o, methodParams);
      if (data == null)
      {
        throw new ReportDataFactoryException("The call did not return a valid tablemodel.");
      }
      return (TableModel) data;
    }
    catch (Exception e)
    {
      throw new ReportDataFactoryException
          ("Unable to instantiate class for non static call."); //$NON-NLS-1$
    }
  }
View Full Code Here

      if (Modifier.isStatic(m.getModifiers()))
      {
        final Object data = m.invoke(null, params);
        if (data == null)
        {
          throw new ReportDataFactoryException("The call did not return a valid tablemodel.");
        }
        return (TableModel) data;
      }

      final ClassLoader classLoader = getClassLoader();
      final Class c = Class.forName(className, false, classLoader);
      final Object o = c.newInstance();
      if (o == null)
      {
        throw new ReportDataFactoryException
            ("Unable to instantiate class for non static call."); //$NON-NLS-1$
      }
      final Object data = m.invoke(o, params);
      if (data == null)
      {
        throw new ReportDataFactoryException("The call did not return a valid tablemodel.");
      }
      return (TableModel) data;
    }
    catch (ReportDataFactoryException rdfe)
    {
      throw rdfe;
    }
    catch (Exception e)
    {
      throw new ReportDataFactoryException
          ("Something went terribly wrong: ", e); //$NON-NLS-1$
    }
  }
View Full Code Here

      throws ReportDataFactoryException
  {
    final int parameterEndIdx = query.lastIndexOf(')');
    if (parameterEndIdx < parameterStartIdx)
    {
      throw new ReportDataFactoryException("Malformed query: " + query); //$NON-NLS-1$
    }
    final String parameterText =
        query.substring(parameterStartIdx + 1, parameterEndIdx);
    final CSVTokenizer tokenizer = new CSVTokenizer(parameterText, ",", "\"", false);
    final int size = tokenizer.countTokens();
View Full Code Here

  {
    final ClassLoader classLoader = getClassLoader();

    if (classLoader == null)
    {
      throw new ReportDataFactoryException("No classloader!"); //$NON-NLS-1$
    }
    try
    {
      final Class c = Class.forName(className, false, classLoader);
      if (Modifier.isAbstract(c.getModifiers()))
      {
        throw new ReportDataFactoryException("Abstract class cannot be handled!"); //$NON-NLS-1$
      }

      final Method[] methods = c.getMethods();
      for (int i = 0; i < methods.length; i++)
      {
        final Method method = methods[i];
        if (Modifier.isPublic(method.getModifiers()) == false)
        {
          continue;
        }
        if (method.getName().equals(methodName) == false)
        {
          continue;
        }
        final Class returnType = method.getReturnType();
        if (TableModel.class.isAssignableFrom(returnType) == false)
        {
          continue;
        }
        if (method.getParameterTypes().length != paramCount)
        {
          continue;
        }
        return method;
      }
    }
    catch (ClassNotFoundException e)
    {
      throw new ReportDataFactoryException("No such Class: " + className, e); //$NON-NLS-1$
    }
    throw new ReportDataFactoryException("No such Method: " + className + '#' + methodName); //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here

      throws ReportDataFactoryException
  {
    final ClassLoader classLoader = getClassLoader();
    if (classLoader == null)
    {
      throw new ReportDataFactoryException("No classloader!"); //$NON-NLS-1$
    }

    try
    {
      final Class c = Class.forName(className, false, classLoader);
      if (TableModel.class.isAssignableFrom(c) == false)
      {
        throw new ReportDataFactoryException
            ("The specified class must be either a TableModel or a ReportData implementation: " + className); //$NON-NLS-1$
      }
      if (Modifier.isAbstract(c.getModifiers()))
      {
        throw new ReportDataFactoryException
            ("The specified class cannot be instantiated: it is abstract:" + className); //$NON-NLS-1$
      }

      final Constructor[] methods = c.getConstructors();
      for (int i = 0; i < methods.length; i++)
      {
        final Constructor method = methods[i];
        if (Modifier.isPublic(method.getModifiers()) == false)
        {
          continue;
        }
        if (method.getParameterTypes().length != paramCount)
        {
          continue;
        }
        return method;
      }
    }
    catch (ClassNotFoundException e)
    {
      throw new ReportDataFactoryException("No such Class", e); //$NON-NLS-1$
    }
    throw new ReportDataFactoryException
        ("There is no constructor in class " + className + //$NON-NLS-1$
            " that accepts " + paramCount + " parameters."); //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here

      throws ReportDataFactoryException
  {
    final ClassLoader classLoader = getClassLoader();
    if (classLoader == null)
    {
      throw new ReportDataFactoryException("No classloader!"); //$NON-NLS-1$
    }

    try
    {
      final Class c = Class.forName(className, false, classLoader);
      if (Modifier.isAbstract(c.getModifiers()))
      {
        throw new ReportDataFactoryException(
            "The specified class cannot be instantiated: it is abstract."); //$NON-NLS-1$
      }

      final Constructor[] methods = c.getConstructors();
      for (int i = 0; i < methods.length; i++)
      {
        final Constructor method = methods[i];
        if (Modifier.isPublic(method.getModifiers()) == false)
        {
          continue;
        }
        if (method.getParameterTypes().length != paramCount)
        {
          continue;
        }
        return method;
      }
    }
    catch (ClassNotFoundException e)
    {
      throw new ReportDataFactoryException("No such Class", e); //$NON-NLS-1$
    }
    throw new ReportDataFactoryException
        ("There is no constructor in class " + className + //$NON-NLS-1$
            " that accepts " + paramCount + " parameters."); //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.ReportDataFactoryException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.