Package org.pentaho.reporting.libraries.xmlns.common

Examples of org.pentaho.reporting.libraries.xmlns.common.AttributeList


    if (element == null)
    {
      throw new NullPointerException();
    }

    final AttributeList attList = createMainAttributes(element, xmlWriter);
    xmlWriter.writeTag(BundleNamespaces.LAYOUT, "details-footer", attList, XmlWriterSupport.OPEN);
    writeElementBody(bundle, state, element, xmlWriter);
    writeChildElements(bundle, state, xmlWriter, (Band) element);
    xmlWriter.writeCloseTag();
View Full Code Here


      tags.addTagDefinition(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "attribute", true);

      final XmlWriter w = new XmlWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"), tags);
      w.writeXmlDeclaration("UTF-8");

      final AttributeList rootList = new AttributeList();
      rootList.addNamespaceDeclaration("", DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE);
      w.writeTag(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "drilldown-profiles", rootList, XmlWriter.OPEN);

      final Object[] objects = drillDownProfiles.toArray();
      for (int i = 0; i < objects.length; i++)
      {
        final DrillDownProfile object = (DrillDownProfile) objects[i];

        final AttributeList profileAttrs = new AttributeList();
        profileAttrs.setAttribute(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "name", object.getName());
        profileAttrs.setAttribute(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "class", object.getLinkCustomizerType().getName());
        profileAttrs.setAttribute(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "bundle-name", object.getBundleLocation());
        profileAttrs.setAttribute(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "expert", String.valueOf(object.isExpert()));
        profileAttrs.setAttribute(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "hidden", String.valueOf(object.isHidden()));
        profileAttrs.setAttribute(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "deprecated", String.valueOf(object.isDeprecated()));
        profileAttrs.setAttribute(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "preferred", String.valueOf(object.isPreferred()));

        w.writeTag(DrillDownModule.DRILLDOWN_PROFILE_NAMESPACE, "drilldown-profile", profileAttrs, XmlWriter.OPEN);

        final String[] attrNames = object.getAttributes();
        for (int j = 0; j < attrNames.length; j++)
View Full Code Here

    final DefaultTagDescription dtd = new DefaultTagDescription();
    dtd.addDefaultDefinition(META_NAMESPACE, false);

    final XmlWriter writer = new XmlWriter(new PrintWriter(System.out), dtd);

    final AttributeList attrList = new AttributeList();
    attrList.addNamespaceDeclaration("", META_NAMESPACE);
    writer.writeTag(META_NAMESPACE, "meta-data", attrList, XmlWriter.OPEN);

    for (int i = 0; i < classes.length; i++)
    {
      final Class aClass = classes[i];

      if (OutputFunction.class.isAssignableFrom(aClass))
      {
        // Output functions will not be recognized.
        continue;
      }
      if (aClass.getName().indexOf('$') >= 0)
      {
        // Inner-Classes will not be recognized.
        continue;
      }

      final AttributeList expressionAttrList = new AttributeList();
      expressionAttrList.setAttribute(META_NAMESPACE, "class", aClass.getName());
      expressionAttrList.setAttribute(META_NAMESPACE, "bundle-name", "org.pentaho.reporting.engine.classic.core.metadata.messages");
      expressionAttrList.setAttribute(META_NAMESPACE, "result", "java.lang.Object");
      expressionAttrList.setAttribute(META_NAMESPACE, "expert", "false");
      expressionAttrList.setAttribute(META_NAMESPACE, "hidden", "false");
      expressionAttrList.setAttribute(META_NAMESPACE, "preferred", "false");
      writer.writeTag(META_NAMESPACE, "expression", expressionAttrList, XmlWriter.OPEN);

      final BeanInfo beanInfo = Introspector.getBeanInfo(aClass);
      final PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
      for (int j = 0; j < descriptors.length; j++)
      {
        final PropertyDescriptor descriptor = descriptors[j];
        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;
        }

        final AttributeList propAttrList = new AttributeList();
        propAttrList.setAttribute(META_NAMESPACE, "name", descriptor.getName());
        if ("name".equals(key))
        {
          propAttrList.setAttribute(META_NAMESPACE, "mandatory", "true");
          propAttrList.setAttribute(META_NAMESPACE, "preferred", "true");
          propAttrList.setAttribute(META_NAMESPACE, "value-role", "Name");
          propAttrList.setAttribute(META_NAMESPACE, "expert", "false");
        }
        else
        {
          propAttrList.setAttribute(META_NAMESPACE, "mandatory", "false");
          propAttrList.setAttribute(META_NAMESPACE, "preferred", "false");
          propAttrList.setAttribute(META_NAMESPACE, "value-role", "Value");
          if ("dependencyLevel".equals(key))
          {
            propAttrList.setAttribute(META_NAMESPACE, "expert", "true");
          }
          else
          {
            propAttrList.setAttribute(META_NAMESPACE, "expert", "false");
          }
        }
        propAttrList.setAttribute(META_NAMESPACE, "hidden", "false");
        writer.writeTag(META_NAMESPACE, "property", propAttrList, XmlWriter.CLOSE);

      }

      writer.writeCloseTag();
View Full Code Here

    if (expressionTag == null)
    {
      throw new NullPointerException();
    }

    final AttributeList expressionAttrList = new AttributeList();
    if (expression.getName() != null)
    {
      expressionAttrList.setAttribute(namespaceUri, "name", expression.getName());
    }

    if (expression.getDependencyLevel() > 0)
    {
      expressionAttrList.setAttribute(namespaceUri, "deplevel",// NON-NLS
          String.valueOf(expression.getDependencyLevel()));
    }

    writeExpressionCore(bundle, state, expression, writer, namespaceUri, expressionTag, expressionAttrList);
  }
View Full Code Here

    if (expressionTag == null)
    {
      throw new NullPointerException();
    }

    final AttributeList expressionAttrList = new AttributeList();
    expressionAttrList.setAttribute(namespaceUri, "style-key", styleKey.getName());// NON-NLS

    writeExpressionCore(bundle, state, expression, writer, namespaceUri, expressionTag, expressionAttrList);
  }
View Full Code Here

    final Object property = beanUtility.getProperty(propertyName);
    final Class propertyType = beanUtility.getPropertyType(propertyName);
    final String value = beanUtility.getPropertyAsString(propertyName);
    if (value != null && property != null)
    {
      final AttributeList attList = new AttributeList();
      attList.setAttribute(namespaceUri, "name", propertyName);
      if (BeanUtility.isSameType(propertyType, property.getClass()) == false)
      {
        attList.setAttribute(namespaceUri, "class", property.getClass().getName());
      }
      writer.writeTag(namespaceUri, "property", attList, XmlWriterSupport.OPEN);
      writer.writeTextNormalized(value, false);
      writer.writeCloseTag();
    }
View Full Code Here

    final DefaultTagDescription tagDescription =
        new DefaultTagDescription(ClassicEngineBoot.getInstance().getGlobalConfig(), BundleXmlModule.TAG_DEF_PREFIX);
    final XmlWriter writer = new XmlWriter(new OutputStreamWriter(outputStream, "UTF-8"), tagDescription, "  ", "\n");
    writer.writeXmlDeclaration("UTF-8");

    final AttributeList rootAttributes = new AttributeList();
    rootAttributes.addNamespaceDeclaration("", BundleNamespaces.DATADEFINITION);

    writer.writeTag(BundleNamespaces.DATADEFINITION, "data-definition", rootAttributes, XmlWriterSupport.OPEN);// NON-NLS

    // write parameters
    writeParameterDefinitions(contentState, writer);
    // write data-source
    final AbstractReportDefinition report = contentState.getReport();

    final String query = report.getQuery();
    final int queryLimit = report.getQueryLimit();
    final AttributeList dataSourceAtts = new AttributeList();
    if (query != null)
    {
      dataSourceAtts.setAttribute(BundleNamespaces.DATADEFINITION, "report-query", query);// NON-NLS
      dataSourceAtts.setAttribute(BundleNamespaces.DATADEFINITION, "limit", String.valueOf(queryLimit));// NON-NLS
    }
    if (report instanceof MasterReport)
    {
      final MasterReport masterReport = (MasterReport) report;
      final String dataSourceDefFile = writeDataFactory(bundle, contentState, masterReport.getDataFactory());
      final String relativePath = IOUtils.getInstance().createRelativePath(dataSourceDefFile,
          contentState.getFileName());
      dataSourceAtts.setAttribute(BundleNamespaces.DATADEFINITION, "ref", relativePath);// NON-NLS
    }
    else if (report instanceof SubReport)
    {
      final SubReport subreport = (SubReport) report;
      if (subreport.getDataFactory() != null)
      {
        final String dataSourceDefFile = writeDataFactory(bundle, contentState, subreport.getDataFactory());
        final String relativePath = IOUtils.getInstance().createRelativePath(dataSourceDefFile,
            contentState.getFileName());
        dataSourceAtts.setAttribute(BundleNamespaces.DATADEFINITION, "ref", relativePath);// NON-NLS
      }
    }
    writer.writeTag(BundleNamespaces.DATADEFINITION, "data-source", dataSourceAtts, XmlWriterSupport.CLOSE);// NON-NLS

    // write expressions
View Full Code Here

      final SubReport subReport = (SubReport) report;
      final ParameterMapping[] inputMappings = subReport.getInputMappings();
      for (int i = 0; i < inputMappings.length; i++)
      {
        final ParameterMapping mapping = inputMappings[i];
        final AttributeList attList = new AttributeList();
        attList.setAttribute(BundleNamespaces.DATADEFINITION, "name", mapping.getName());// NON-NLS
        attList.setAttribute(BundleNamespaces.DATADEFINITION, "alias", mapping.getAlias());// NON-NLS
        writer.writeTag(BundleNamespaces.DATADEFINITION, "input-parameter", attList, XmlWriterSupport.CLOSE);// NON-NLS
      }

      final ParameterMapping[] exportMappings = subReport.getExportMappings();
      for (int i = 0; i < exportMappings.length; i++)
      {
        final ParameterMapping mapping = exportMappings[i];
        final AttributeList attList = new AttributeList();
        attList.setAttribute(BundleNamespaces.DATADEFINITION, "name", mapping.getName());// NON-NLS
        attList.setAttribute(BundleNamespaces.DATADEFINITION, "alias", mapping.getAlias());// NON-NLS
        writer.writeTag(BundleNamespaces.DATADEFINITION, "export-parameter", attList, XmlWriterSupport.CLOSE);// NON-NLS
      }
      writer.writeCloseTag();
      return;
    }

    if (report instanceof MasterReport)
    {
      final MasterReport masterReport = (MasterReport) report;
      final ReportParameterDefinition definition = masterReport.getParameterDefinition();
      final ReportParameterValidator reportParameterValidator = definition.getValidator();

      final AttributeList attList = new AttributeList();
      if (DefaultReportParameterValidator.class.equals(reportParameterValidator.getClass()) == false)
      {
        attList.setAttribute(BundleNamespaces.DATADEFINITION, "validator",// NON-NLS
            reportParameterValidator.getClass().getName());
      }
      writer.writeTag(BundleNamespaces.DATADEFINITION, "parameter-definition", attList, XmlWriterSupport.OPEN);// NON-NLS

      writeMasterReportParameters(writer, definition);
View Full Code Here

    if (StringUtils.isEmpty(plainParameter.getName()))
    {
      throw new BundleWriterException("Cannot write a unnamed parameter entry.");
    }

    final AttributeList paramAttrs = new AttributeList();
    paramAttrs.setAttribute(BundleNamespaces.DATADEFINITION, "name", plainParameter.getName());// NON-NLS
    paramAttrs.setAttribute(BundleNamespaces.DATADEFINITION, "mandatory", String.valueOf(plainParameter.isMandatory()));// NON-NLS
    paramAttrs.setAttribute(BundleNamespaces.DATADEFINITION, "type", plainParameter.getValueType().getName());// NON-NLS

    final Object defaultValue = plainParameter.getDefaultValue();
    if (defaultValue != null)
    {
      try
      {
        final String valAsString = ConverterRegistry.toAttributeValue(defaultValue);
        if (StringUtils.isEmpty(valAsString) == false)
        {
          paramAttrs.setAttribute(BundleNamespaces.DATADEFINITION, "default-value", valAsString);// NON-NLS
        }
      }
      catch (BeanException e)
      {
        throw new BundleWriterException("Unable to convert parameter " +
            "default-value to string for parameter '" + plainParameter.getName() + '\'');
      }
    }

    final String[] namespaces = plainParameter.getParameterAttributeNamespaces();
    if (namespaces.length == 0)
    {
      writer.writeTag(BundleNamespaces.DATADEFINITION, "plain-parameter", paramAttrs, XmlWriterSupport.CLOSE);// NON-NLS
    }
    else
    {
      writer.writeTag(BundleNamespaces.DATADEFINITION, "plain-parameter", paramAttrs, XmlWriterSupport.OPEN);// NON-NLS
      for (int j = 0; j < namespaces.length; j++)
      {
        final String namespace = namespaces[j];
        final String[] names = plainParameter.getParameterAttributeNames(namespace);
        for (int k = 0; k < names.length; k++)
        {
          final String name = names[k];
          final String value = plainParameter.getParameterAttribute(namespace, name);
          if (StringUtils.isEmpty(value))
          {
            continue;
          }
          final AttributeList attrsAttr = new AttributeList();
          attrsAttr.setAttribute(BundleNamespaces.DATADEFINITION, "namespace", namespace);// NON-NLS
          attrsAttr.setAttribute(BundleNamespaces.DATADEFINITION, "name", name);// NON-NLS
          writer.writeTag(BundleNamespaces.DATADEFINITION, "attribute", attrsAttr, XmlWriterSupport.OPEN);// NON-NLS
          writer.writeTextNormalized(value, false);
          writer.writeCloseTag();
        }
      }
View Full Code Here

    if (StringUtils.isEmpty(parameter.getName()))
    {
      throw new BundleWriterException("Cannot write a unnamed parameter entry.");
    }

    final AttributeList paramAttrs = new AttributeList();
    paramAttrs.setAttribute(BundleNamespaces.DATADEFINITION, "name", parameter.getName());
    paramAttrs.setAttribute(BundleNamespaces.DATADEFINITION, "allow-multi-selection", // NON-NLS
        String.valueOf(parameter.isAllowMultiSelection()));
    paramAttrs.setAttribute(BundleNamespaces.DATADEFINITION, "strict-values", // NON-NLS
        String.valueOf(parameter.isStrictValueCheck()));
    paramAttrs.setAttribute(BundleNamespaces.DATADEFINITION, "mandatory", String.valueOf(parameter.isMandatory()));// NON-NLS
    paramAttrs.setAttribute(BundleNamespaces.DATADEFINITION, "type", parameter.getValueType().getName());// NON-NLS
    if (StringUtils.isEmpty(parameter.getQueryName()) == false)
    {
      paramAttrs.setAttribute(BundleNamespaces.DATADEFINITION, "query", parameter.getQueryName());// NON-NLS
    }
    if (StringUtils.isEmpty(parameter.getKeyColumn()) == false)
    {
      paramAttrs.setAttribute(BundleNamespaces.DATADEFINITION, "key-column", parameter.getKeyColumn());// NON-NLS
    }
    if (StringUtils.isEmpty(parameter.getTextColumn()) == false)
    {
      paramAttrs.setAttribute(BundleNamespaces.DATADEFINITION, "value-column", parameter.getTextColumn());// NON-NLS
    }

    final Object defaultValue = parameter.getDefaultValue();
    if (defaultValue != null)
    {
      try
      {
        final String valAsString = ConverterRegistry.toAttributeValue(defaultValue);
        if (StringUtils.isEmpty(valAsString) == false)
        {
          paramAttrs.setAttribute(BundleNamespaces.DATADEFINITION, "default-value", valAsString);// NON-NLS
        }
      }
      catch (BeanException e)
      {
        throw new BundleWriterException("Unable to convert parameter " +
            "default-value to string for parameter '" + parameter.getName() + '\'');
      }
    }
    final String[] namespaces = parameter.getParameterAttributeNamespaces();
    if (namespaces.length == 0)
    {
      writer.writeTag(BundleNamespaces.DATADEFINITION, "list-parameter", paramAttrs, XmlWriterSupport.CLOSE);// NON-NLS
    }
    else
    {
      writer.writeTag(BundleNamespaces.DATADEFINITION, "list-parameter", paramAttrs, XmlWriterSupport.OPEN);// NON-NLS
      for (int j = 0; j < namespaces.length; j++)
      {
        final String namespace = namespaces[j];
        final String[] names = parameter.getParameterAttributeNames(namespace);
        for (int k = 0; k < names.length; k++)
        {
          final String name = names[k];
          final String value = parameter.getParameterAttribute(namespace, name);
          if (StringUtils.isEmpty(value))
          {
            continue;
          }

          final AttributeList attrsAttr = new AttributeList();
          attrsAttr.setAttribute(BundleNamespaces.DATADEFINITION, "namespace", namespace); // NON-NLS
          attrsAttr.setAttribute(BundleNamespaces.DATADEFINITION, "name", name); // NON-NLS
          writer.writeTag(BundleNamespaces.DATADEFINITION, "attribute", attrsAttr, XmlWriterSupport.OPEN);// NON-NLS
          writer.writeTextNormalized(value, false);
          writer.writeCloseTag();
        }
      }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.libraries.xmlns.common.AttributeList

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.