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

Examples of org.pentaho.reporting.engine.classic.core.metadata.ExpressionMetaData


        return 0;
      }

      for (int i = 1; i < allExpressionMetaDatas.size(); i++)
      {
        final ExpressionMetaData data = allExpressionMetaDatas.get(i).getWrappedObject();
        if (data == null)
        {
          return 0;
        }
        final Class testValue = data.getExpressionType();
        if (value.equals(testValue))
        {
          return i;
        }
      }
View Full Code Here


    {
      if (value == null)
      {
        return null;
      }
      final ExpressionMetaData emd = allExpressionMetaDatas.get(value).getWrappedObject();
      if (emd == null)
      {
        return null;
      }
      return emd.getExpressionType();
    }
View Full Code Here

  public static void main(String[] args)
  {
    ClassicEngineBoot.getInstance().start();
    final ExpressionMetaData[] allExpressionMetaDatas = ExpressionRegistry.getInstance().getAllExpressionMetaDatas();
    final ExpressionMetaData data = ExpressionRegistry.getInstance().getExpressionMetaData(ConvertToNumberExpression.class.getName());
    System.out.println(new EditableExpressionMetaData((DefaultExpressionMetaData) data).isValid(Locale.getDefault(), false));
  }
View Full Code Here

    final ExpressionMetaData[] allExpressionMetaDatas = ExpressionRegistry.getInstance().getAllExpressionMetaDatas();
    metaData = new EditableExpressionMetaData[allExpressionMetaDatas.length];
    for (int i = 0; i < allExpressionMetaDatas.length; i++)
    {
      ExpressionMetaData expressionMetaData = allExpressionMetaDatas[i];
      metaData[i] = new EditableExpressionMetaData((DefaultExpressionMetaData) expressionMetaData);
    }
    expressionsTableModel.populate(metaData);
    sortAction.actionPerformed(null);
View Full Code Here

    ClassicEngineBoot.getInstance().start();
    final TreeMap globalAttributes = new TreeMap();
    final ExpressionMetaData[] datas = ExpressionRegistry.getInstance().getAllExpressionMetaDatas();
    for (int i = 0; i < datas.length; i++)
    {
      final ExpressionMetaData data = datas[i];
      if (data instanceof AbstractMetaData == false)
      {
        continue;
      }
      printMetaBundle(data);
View Full Code Here

    ExpressionRegistry expressionRegistry = ExpressionRegistry.getInstance();
    final ExpressionMetaData[] allExpressions = expressionRegistry.getAllExpressionMetaDatas();
    for (int i = 0; i < allExpressions.length; i++)
    {
      final ExpressionMetaData expression = allExpressions[i];
      if (expression == null)
      {
        logger.warn("Null Expression encountered");
        continue;
      }

      missingProperties.clear();

      final Class type = expression.getExpressionType();
      if (type == null)
      {
        logger.warn("Expression class is null");
      }

      logger.debug("Processing " + type);

      final Class resultType = expression.getResultType();
      if (resultType == null)
      {
        logger.warn("Expression '" + expression.getExpressionType() + " is null");
      }

      try
      {
        final BeanInfo beanInfo = expression.getBeanDescriptor();
        if (beanInfo == null)
        {
          logger.warn("Expression '" + expression.getExpressionType() + ": Cannot get BeanDescriptor: Null");
        }
      }
      catch (IntrospectionException e)
      {
        logger.warn("Expression '" + expression.getExpressionType() + ": Cannot get BeanDescriptor", e);
      }

      final Locale locale = Locale.getDefault();
      final String displayName = expression.getDisplayName(locale);
      if (isValid(displayName, expression.getName()) == false)
      {
        logger.warn("Expression '" + expression.getExpressionType() + ": No valid display name");
      }
      if (expression.isDeprecated())
      {
        deprecatedExpressionsCounter += 1;
        final String deprecateMessage = expression.getDeprecationMessage(locale);
        if (isValid(deprecateMessage, "Use a Formula instead") == false)
        {
          logger.warn("Expression '" + expression.getExpressionType() + ": No valid deprecate message");
        }
      }
      final String grouping = expression.getGrouping(locale);
      if (isValid(grouping, "Group") == false)
      {
        logger.warn("Expression '" + expression.getExpressionType() + ": No valid grouping message");
      }

      expressionsByGroup.add(grouping, expression);

      final ExpressionPropertyMetaData[] properties = expression.getPropertyDescriptions();
      for (int j = 0; j < properties.length; j++)
      {
        final ExpressionPropertyMetaData propertyMetaData = properties[j];
        final String name = propertyMetaData.getName();
        if (StringUtils.isEmpty(name))
        {
          logger.warn("Expression '" + expression.getExpressionType() + ": Property without a name");
        }
        final String propertyDisplayName = propertyMetaData.getDisplayName(locale);
        if (isValid(propertyDisplayName, name) == false)
        {
          logger.warn("Expression '" + expression.getExpressionType() + ": Property " + propertyMetaData.getName() + ": No DisplayName");
        }

        final String propertyGrouping = propertyMetaData.getGrouping(locale);
        if (isValid(propertyGrouping, "Group") == false)
        {
          logger.warn("Expression '" + expression.getExpressionType() + ": Property " + propertyMetaData.getName() + ": Grouping is not valid");
        }
        final int groupingOrdinal = propertyMetaData.getGroupingOrdinal(locale);
        if (groupingOrdinal == Integer.MAX_VALUE)
        {
          if (propertyMetaData instanceof DefaultExpressionMetaData)
          {
            final DefaultExpressionPropertyMetaData demd = (DefaultExpressionPropertyMetaData) propertyMetaData;
            missingProperties.add(demd.getKeyPrefix() + "grouping.ordinal=1000");
          }
          logger.warn("Expression '" + expression.getExpressionType() + ": Property " + propertyMetaData.getName() + ": Grouping ordinal is not valid");
        }
        final int ordinal = propertyMetaData.getItemOrdinal(locale);
        if (groupingOrdinal == Integer.MAX_VALUE)
        {
          if (propertyMetaData instanceof DefaultExpressionMetaData)
          {
            final DefaultExpressionPropertyMetaData demd = (DefaultExpressionPropertyMetaData) propertyMetaData;
            missingProperties.add(demd.getKeyPrefix() + "ordinal=1000");
          }
          logger.warn("Expression '" + expression.getExpressionType() + ": Property " + propertyMetaData.getName() + ": Ordinal is not valid");
        }
        final String propertyDescription = propertyMetaData.getDescription(locale);
        if (isValid(propertyDescription, "") == false)
        {
          logger.warn("Expression '" + expression.getExpressionType() + ": Property " + propertyMetaData.getName() + ": Description is not valid");
        }
        final String propertyDeprecated = propertyMetaData.getDeprecationMessage(locale);
        if (isValid(propertyDeprecated, "") == false)
        {
          logger.warn("Expression '" + expression.getExpressionType() + ": Property " + propertyMetaData.getName() + ": Deprecation is not valid");
        }

        final String role = propertyMetaData.getPropertyRole();
        if (isValid(role, "Value") == false)
        {
          logger.warn("Expression '" + expression.getExpressionType() + ": Property " + propertyMetaData.getName() + ": Role is not valid");
        }
        final Class propertyType = propertyMetaData.getPropertyType();
        if (propertyType == null)
        {
          logger.warn("Expression '" + expression.getExpressionType() + ": Property " + propertyMetaData.getName() + ": Property Type is not valid");
        }

        // should not crash!
        final PropertyDescriptor propertyDescriptor = propertyMetaData.getBeanDescriptor();

        if (propertyMetaData.isDeprecated())
        {
          final String deprecateMessage = propertyMetaData.getDeprecationMessage(locale);
          if (isValid(deprecateMessage, "Deprecated") == false)
          {
            logger.warn("Expression '" + expression.getExpressionType() + ": Property " + propertyMetaData.getName() + ": No valid deprecate message");
          }
        }

      }

      try
      {
        final BeanInfo beanInfo = Introspector.getBeanInfo(expression.getExpressionType());
        final PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
        for (int propIdx = 0; propIdx < descriptors.length; propIdx++)
        {
          final PropertyDescriptor descriptor = descriptors[propIdx];
          final String key = descriptor.getName();

          if ("runtime".equals(key))
          {
            continue;
          }
          if ("active".equals(key))
          {
            continue;
          }
          if ("preserve".equals(key))
          {
            continue;
          }

          if (descriptor.getReadMethod() == null || descriptor.getWriteMethod() == null)
          {
            continue;
          }

          if (expression.getPropertyDescription(key) == null)
          {
            logger.warn("Expression '" + expression.getExpressionType() + ": No property definition for " + key);
            missingPropertyDefs.add("    <property name=\""+ key + "\" mandatory=\"false\" preferred=\"false\" value-role=\"Value\" expert=\"false\" hidden=\"false\"/>");
          }
        }

      }
      catch (Throwable e)
      {
        logger.warn("Expression '" + expression.getExpressionType() + ": Cannot get BeanDescriptor", e);
      }

      System.err.flush();
      try
      {
        Thread.sleep(25);
      }
      catch (InterruptedException e)
      {
      }

      for (int x = 0; x < missingProperties.size(); x++)
      {
        final String property = (String) missingProperties.get(x);
        System.out.println(property);
      }

      for (int j = 0; j < missingPropertyDefs.size(); j++)
      {
        final String def = (String) missingPropertyDefs.get(j);
        System.out.println(def);
      }

      if (missingProperties.isEmpty() == false || missingPropertyDefs.isEmpty() == false)
      {
        invalidExpressionsCounter += 1;
        missingProperties.clear();
        missingPropertyDefs.clear();
      }
      System.out.flush();
      try
      {
        Thread.sleep(25);
      }
      catch (InterruptedException e)
      {
      }
    }

    logger.info("Validated " + allExpressions.length + " expressions. Invalid: " +
        invalidExpressionsCounter + " Deprecated: " + deprecatedExpressionsCounter);

    final Object[] keys = expressionsByGroup.keySet().toArray();
    Arrays.sort(keys);
    for (int i = 0; i < keys.length; i++)
    {
      final Object key = keys[i];
      logger.info("Group: '" + key + "' Size: " + expressionsByGroup.getValueCount(key));
      final Object[] objects = expressionsByGroup.toArray(key);
      for (int j = 0; j < objects.length; j++)
      {
        ExpressionMetaData metaData = (ExpressionMetaData) objects[j];
        logger.info("   " + metaData.getExpressionType());

      }
    }
  }
View Full Code Here

      if (registry.isExpressionRegistered(expression.getClass().getName()) == false)
      {
        continue;
      }

      final ExpressionMetaData emd =
          registry.getExpressionMetaData(expression.getClass().getName());
      if (emd.isGlobalLayoutProcessor())
      {
        writeExpression(bundle, state, expression, writer, BundleNamespaces.LAYOUT, "expression");// NON-NLS
      }
    }
  }
View Full Code Here

      if (registry.isExpressionRegistered(expression.getClass().getName()) == false)
      {
        continue;
      }

      final ExpressionMetaData emd =
          registry.getExpressionMetaData(expression.getClass().getName());
      if (emd.isGlobalLayoutProcessor() || emd.isElementLayoutProcessor())
      {
        continue;
      }

      writeExpression(bundle, state, expression, writer, BundleNamespaces.DATADEFINITION, "expression");// NON-NLS
View Full Code Here

    {

      final String expressionId = expression.getClass().getName();
      expressionAttrList.setAttribute(namespaceUri, "class", expressionId);

      final ExpressionMetaData emd;
      if (ExpressionRegistry.getInstance().isExpressionRegistered(expressionId))
      {
        emd = ExpressionRegistry.getInstance().getExpressionMetaData(expressionId);
      }
      else
      {
        emd = null;
      }

      if (emd != null)
      {
        final BeanUtility bu = new BeanUtility(expression);
        final ExpressionPropertyMetaData[] expressionProperties = emd.getPropertyDescriptions();
        boolean propertiesOpen = false;
        for (int i = 0; i < expressionProperties.length; i++)
        {
          final ExpressionPropertyMetaData metaData = expressionProperties[i];
          final String propertyName = metaData.getName();
View Full Code Here

      if (registry.isExpressionRegistered(expression.getClass().getName()) == false)
      {
        continue;
      }

      final ExpressionMetaData emd =
          registry.getExpressionMetaData(expression.getClass().getName());
      if (emd.isElementLayoutProcessor())
      {
        return true;
      }
    }
    return false;
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.metadata.ExpressionMetaData

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.