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

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


    if (ExpressionRegistry.getInstance().isExpressionRegistered(expression.getClass().getName()) == false)
    {
      return false;
    }

    final ExpressionMetaData metaData =
        ExpressionRegistry.getInstance().getExpressionMetaData(expression.getClass().getName());
    if (resultType.isAssignableFrom(metaData.getResultType()))
    {
      return true;
    }
    return 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

    propertyChangeSupport.firePropertyChange(PRIMARY_DATA_SOURCE_PROPERTY, oldExpression, primaryDataSource);

    if (primaryDataSource != null)
    {
      final ExpressionMetaData data =
          ExpressionRegistry.getInstance().getExpressionMetaData(primaryDataSource.getClass().getName());
      primaryDataSourcesModel.setSelectedItem(data);
    }
    else
    {
View Full Code Here

    this.secondaryDataSource = secondaryDataSource;
    propertyChangeSupport.firePropertyChange(SECONDARY_DATA_SOURCE_PROPERTY, oldExpression, secondaryDataSource);

    if (secondaryDataSource != null)
    {
      final ExpressionMetaData data =
          ExpressionRegistry.getInstance().getExpressionMetaData(secondaryDataSource.getClass().getName());
      secondaryDataSourcesModel.setSelectedItem(data);
    }
    else
    {
View Full Code Here

    final ExpressionMetaData[] allExpressionMetaDatas = ExpressionRegistry.getInstance().getAllExpressionMetaDatas();
    Arrays.sort(allExpressionMetaDatas, new GroupedMetaDataComparator());
    for (int i = 0; i < allExpressionMetaDatas.length; i++)
    {
      final ExpressionMetaData data = allExpressionMetaDatas[i];
      if (data.isHidden())
      {
        continue;
      }
      if (WorkspaceSettings.getInstance().isShowExpertItems() == false && data.isExpert())
      {
        continue;
      }
      if (WorkspaceSettings.getInstance().isShowDeprecatedItems() == false && data.isDeprecated())
      {
        continue;
      }
      if (StructureFunction.class.isAssignableFrom(data.getExpressionType()))
      {
        continue;
      }

      if (resultType.isAssignableFrom(data.getResultType()))
      {
        model.addElement(data);
      }
    }
View Full Code Here

      // ignored
    }

    public void contentsChanged(final ListDataEvent e)
    {
      final ExpressionMetaData o = (ExpressionMetaData) getPrimaryDataSourcesModel().getSelectedItem();
      if (o == null)
      {
        setPrimaryDataSource(null);
        return;
      }
      final Expression primaryDataSourceExpression = getPrimaryDataSource();
      if (primaryDataSourceExpression != null && primaryDataSourceExpression.getClass().equals(o.getExpressionType()))
      {
        // no need to change anything ..
        return;
      }

      try
      {
        final Expression expression = (Expression) o.getExpressionType().newInstance();
        if (primaryDataSourceExpression != null)
        {
          propagateExpressionSettings(primaryDataSourceExpression, expression);
        }
View Full Code Here

    }

    public void contentsChanged(final ListDataEvent e)
    {

      final ExpressionMetaData o = (ExpressionMetaData) getSecondaryDataSourcesModel().getSelectedItem();
      if (o == null)
      {
        setSecondaryDataSource(null);
        return;
      }

      final Expression secondaryDataSourceExpression = getSecondaryDataSource();
      if (secondaryDataSourceExpression != null && secondaryDataSourceExpression.getClass().equals(o.getExpressionType()))
      {
        // no need to change anything ..
        return;
      }

      try
      {
        final Expression expression = (Expression) o.getExpressionType().newInstance();
        if (secondaryDataSourceExpression != null)
        {
          propagateExpressionSettings(secondaryDataSourceExpression, expression);
        }
        setSecondaryDataSource(expression.getInstance());
View Full Code Here

      // ignored
    }

    public void contentsChanged(final ListDataEvent e)
    {
      final ExpressionMetaData o = (ExpressionMetaData) getChartExpressionsModel().getSelectedItem();
      if (o == null)
      {
        setChartExpression(null);
        return;
      }

      final Expression chartExpression = getChartExpression();
      if (chartExpression != null && chartExpression.getClass().equals(o.getExpressionType()))
      {
        // no need to change anything ..
        return;
      }

      try
      {
        final Expression primaryDSExpression = getPrimaryDataSource();
        final Expression secondaryDSExpression = getSecondaryDataSource();

        final Expression newChartExpression = (Expression) o.getExpressionType().newInstance();
        propagateExpressionSettings(chartExpression, newChartExpression);
        setChartExpression(newChartExpression);

        final ExpressionMetaData thePrimaryModel = (ExpressionMetaData) getPrimaryDataSourcesModel().getSelectedItem();
        if (thePrimaryModel != null && primaryDSExpression != null)
        {
          if (thePrimaryModel.getExpressionType().equals(primaryDSExpression.getClass()))
          {
            setPrimaryDataSource(primaryDSExpression);
          }
          else
          {
            final Expression newPrimaryDataSource = (Expression) thePrimaryModel.getExpressionType().newInstance();
            propagateExpressionSettings(primaryDSExpression, newPrimaryDataSource);
            setPrimaryDataSource(newPrimaryDataSource);
          }
        }

        final ExpressionMetaData theSecondaryModel = (ExpressionMetaData) getSecondaryDataSourcesModel().getSelectedItem();
        if (theSecondaryModel != null && secondaryDSExpression != null)
        {
          if (theSecondaryModel.getExpressionType().equals(secondaryDSExpression.getClass()))
          {
            setSecondaryDataSource(secondaryDSExpression);
          }
          else
          {
            final Expression newSecondaryDataSource = (Expression) theSecondaryModel.getExpressionType().newInstance();
            propagateExpressionSettings(secondaryDSExpression, newSecondaryDataSource);
            setSecondaryDataSource(newSecondaryDataSource);
          }
        }
      }
View Full Code Here

    ClassicEngineBoot.getInstance().start();
    final ExpressionMetaData[] datas = ExpressionRegistry.getInstance().getAllExpressionMetaDatas();
    Arrays.sort(datas, GroupedMetaDataComparator.ENGLISH);
    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

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.