Examples of AttributeMetaData


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

    final Iterator iterator = globalAttributes.entrySet().iterator();
    while (iterator.hasNext())
    {
      final Map.Entry o = (Map.Entry) iterator.next();

      final AttributeMetaData attribute = (AttributeMetaData) o.getValue();
      final AbstractMetaData aamd = (AbstractMetaData) attribute;
      final String akeyPrefix = aamd.getKeyPrefix();
      final String abundle = aamd.getBundleLocation();
      final String aname = attribute.getName();

      System.out.println(akeyPrefix + aname + ".display-name=" + aname);
      System.out.println(akeyPrefix + aname + ".grouping=" + filter(aamd.getGrouping(Locale.ENGLISH), "Group"));
      System.out.println(akeyPrefix + aname + ".description=" + filter(aamd.getDescription(Locale.ENGLISH), ""));
      System.out.println(akeyPrefix + aname + ".deprecated=" + filter(aamd.getDeprecationMessage(Locale.ENGLISH), ""));
View Full Code Here

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

    final AttributeMetaData[] attributes = data.getAttributeDescriptions();

    for (int j = 0; j < attributes.length; j++)
    {
      final AttributeMetaData attribute = attributes[j];
      final AbstractMetaData aamd = (AbstractMetaData) attribute;
      final String akeyPrefix = aamd.getKeyPrefix();
      final String abundle = aamd.getBundleLocation();
      final String aname = attribute.getName();
      if (abundle.equals(GLOBAL_BUNDLE) && akeyPrefix.startsWith("attribute."))
      {
        globalAttributes.put (aname, attribute);
        continue;
      }
View Full Code Here

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

                                 final String namespace,
                                 final String name,
                                 final String attributeValue,
                                 final ReportAttributeMap attributes) throws ParseException
  {
    final AttributeMetaData attributeMetaData = metaData.getAttributeDescription(namespace, name);
    if (attributeMetaData == null || attributeValue == null)
    {
      element.setAttribute(namespace, name, attributeValue);
      return;
    }

    if (attributeMetaData.isTransient())
    {
      return;
    }

    if ("Resource".equals(attributeMetaData.getValueRole()))
    {
      try
      {
        final Object type = attributes.getAttribute(AttributeNames.Core.NAMESPACE, "resource-type");
        if ("url".equals(type))
        {
          element.setAttribute(namespace, name, new URL(attributeValue));
          return;
        }
        if ("file".equals(type))
        {
          element.setAttribute(namespace, name, new File(attributeValue));
          return;
        }
        if ("local-ref".equals(type))
        {
          element.setAttribute(namespace, name, attributeValue);
          return;
        }
        if ("resource-key".equals(type))
        {
          final ResourceManager resourceManager = getRootHandler().getResourceManager();
          final ResourceKey key = getRootHandler().getContext();
          final ResourceKey parent = key.getParent();
          final ResourceKey valueKey = resourceManager.deserialize(parent, attributeValue);

          // make local ..
          final ResourceKey resourceKey = localizeKey(resourceManager, valueKey);
          element.setAttribute(namespace, name, resourceKey);
          return;
        }
        element.setAttribute(namespace, name, attributeValue);
        return;
      }
      catch (MalformedURLException e)
      {
        throw new ParseException("Failed to parse URL value", e);
      }
      catch (ResourceKeyCreationException e)
      {
        throw new ParseException("Failed to parse resource-key value", e);
      }
    }

    final Class type = attributeMetaData.getTargetType();
    if (String.class.equals(type))
    {
      element.setAttribute(namespace, name, attributeValue);
    }
    else
    {
      try
      {
        final PropertyEditor propertyEditor = attributeMetaData.getEditor();
        if (propertyEditor != null)
        {
          propertyEditor.setAsText(attributeValue);
          element.setAttribute(namespace, name, propertyEditor.getValue());
        }
View Full Code Here

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

        if (value == null)
        {
          continue;
        }

        final AttributeMetaData attrMeta = type.getMetaData().getAttributeDescription(namespace, name);
        if (attrMeta == null)
        {
          // if you want to use attributes in this output target, declare the attribute's metadata first.
          continue;
        }

        final AttributeList attList = new AttributeList();
        if (value instanceof String)
        {
          final String s = (String) value;
          if (StringUtils.isEmpty(s))
          {
            continue;
          }

          if (xmlWriter.isNamespaceDefined(namespace) == false &&
              attList.isNamespaceUriDefined(namespace) == false)
          {
            attList.addNamespaceDeclaration("autoGenNs", namespace);
          }

          // preserve strings, but discard anything else. Until a attribute has a definition, we cannot
          // hope to understand the attribute's value. String-attributes can be expressed in XML easily,
          // and string is also how all unknown attributes are stored by the parser.
          attList.setAttribute(namespace, name, String.valueOf(value));
          this.xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "attribute", attList, XmlWriter.CLOSE);
          continue;
        }

        if (xmlWriter.isNamespaceDefined(namespace) == false &&
            attList.isNamespaceUriDefined(namespace) == false)
        {
          attList.addNamespaceDeclaration("autoGenNs", namespace);
        }

        try
        {
          final PropertyEditor propertyEditor = attrMeta.getEditor();
          final String textValue;
          if (propertyEditor != null)
          {
            propertyEditor.setValue(value);
            textValue = propertyEditor.getAsText();
          }
          else
          {
            textValue = ConverterRegistry.toAttributeValue(value);

          }
          if (StringUtils.isEmpty(textValue) == false)
          {
            attList.setAttribute(namespace, name, textValue);
            this.xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "attribute", attList, XmlWriter.CLOSE);
          }
          else
          {
            XmlDocumentWriter.logger.warn(
                "Attribute '" + namespace + '|' + name + "' is not convertible to a text - returned null");
          }
        }
        catch (BeanException e)
        {
          if (attrMeta.isTransient() == false)
          {
            XmlDocumentWriter.logger.warn(
                "Attribute '" + namespace + '|' + name + "' is not convertible with the bean-methods");
          }
          else
View Full Code Here

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

      // Process the attributes if they are a resource key
      final ElementMetaData metaData = element.getMetaData();
      final AttributeMetaData[] attributeDescriptions = metaData.getAttributeDescriptions();
      for (int j = 0; j < attributeDescriptions.length; j++)
      {
        final AttributeMetaData attributeDescription = attributeDescriptions[j];
        if ("Resource".equals(attributeDescription.getValueRole()) == false)
        {
          continue;
        }

        final Object attribute = element.getAttribute(attributeDescription.getNameSpace(), attributeDescription.getName());
        if (attribute instanceof ResourceKey == false)
        {
          continue;
        }

        final ResourceKey resourceKey = (ResourceKey) attribute;
        final ResourceKey replacementKey = processResourceKeyAttribute(documentBundle, report, resourceKey);
        if (replacementKey != null)
        {
          element.setAttribute(attributeDescription.getNameSpace(), attributeDescription.getName(), replacementKey);
        }
      }
    }
  }
View Full Code Here

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

        if (value == null)
        {
          continue;
        }

        final AttributeMetaData attrMeta = type.getMetaData().getAttributeDescription(namespace, name);
        if (attrMeta == null)
        {
          // if you want to use attributes in this output target, declare the attribute's metadata first.
          continue;
        }

        final AttributeList attList = new AttributeList();
        if (value instanceof String)
        {
          final String s = (String) value;
          if (StringUtils.isEmpty(s))
          {
            continue;
          }

          if (xmlWriter.isNamespaceDefined(namespace) == false &&
              attList.isNamespaceUriDefined(namespace) == false)
          {
            attList.addNamespaceDeclaration("autoGenNs", namespace);
          }

          // preserve strings, but discard anything else. Until a attribute has a definition, we cannot
          // hope to understand the attribute's value. String-attributes can be expressed in XML easily,
          // and string is also how all unknown attributes are stored by the parser.
          attList.setAttribute(namespace, name, s);
          this.xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "attribute", attList, XmlWriter.CLOSE);
          continue;
        }

        if (xmlWriter.isNamespaceDefined(namespace) == false &&
            attList.isNamespaceUriDefined(namespace) == false)
        {
          attList.addNamespaceDeclaration("autoGenNs", namespace);
        }

        try
        {
          final PropertyEditor propertyEditor = attrMeta.getEditor();
          final String textValue;
          if (propertyEditor != null)
          {
            propertyEditor.setValue(value);
            textValue = propertyEditor.getAsText();
          }
          else
          {
            textValue = ConverterRegistry.toAttributeValue(value);

          }
          if (StringUtils.isEmpty(textValue) == false)
          {
            attList.setAttribute(namespace, name, textValue);
            this.xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "attribute", attList, XmlWriter.CLOSE);
          }
          else
          {
            XmlDocumentWriter.logger.debug(
                "Attribute '" + namespace + '|' + name + "' is not convertible to a text - returned null");
          }
        }
        catch (BeanException e)
        {
          if (attrMeta.isTransient() == false)
          {
            XmlDocumentWriter.logger.warn(
                "Attribute '" + namespace + '|' + name + "' is not convertible with the bean-methods");
          }
          else
View Full Code Here

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


      final AttributeMetaData[] attributeMetaDatas = metaData.getAttributeDescriptions();
      for (int j = 0; j < attributeMetaDatas.length; j++)
      {
        final AttributeMetaData propertyMetaData = attributeMetaDatas[j];
        final String propertyDisplayName = propertyMetaData.getDisplayName(locale);
        if (isValid(propertyDisplayName, propertyMetaData.getName()) == false)
        {
          logger.warn("ElementType '" + typeName + ": Attr " + propertyMetaData.getName() + ": No DisplayName");
        }

        final String propertyGrouping = propertyMetaData.getGrouping(locale);
        if (isValid(propertyGrouping, "Group") == false)
        {
          logger.warn("ElementType '" + typeName + ": Attr " + propertyMetaData.getName() + ": Grouping is not valid");
        }
        if (propertyMetaData.isDeprecated())
        {
          final String deprecateMessage = propertyMetaData.getDeprecationMessage(locale);
          if (isValid(deprecateMessage, "Deprecated") == false)
          {
            logger.warn(
                "ElementType '" + typeName + ": Attr " + propertyMetaData.getName() + ": No valid deprecate message");
          }
        }
      }

      System.err.flush();
View Full Code Here

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

      {
        final Map.Entry entry = (Map.Entry) it.next();
        final Object value = entry.getValue();

        final String name = (String) entry.getKey();
        final AttributeMetaData data = metaData.getAttributeDescription(namespace, name);
        if (data == null)
        {
          if (logger.isDebugEnabled())
          {
            logger.debug(getElementTypeName() + ": Attribute " + namespace + "|" + name + " is not listed in the metadata.");
          }
        }
        if (value instanceof Cloneable)
        {
          e.attributes.setAttribute(namespace, name, ObjectUtilities.clone(value));
        }
        else if (data == null || data.isComputed() == false || data.isDesignTimeValue())
        {
          e.attributes.setAttribute(namespace, name, value);
        }
        else
        {
View Full Code Here

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

      for (int j = 0; j < names.length; j++)
      {
        final String name = names[j];
        final Object attribute = attributes.getAttribute(nameSpace, name);

        final AttributeMetaData data = getMetaData().getAttributeDescription(nameSpace, name);
        if (data != null && (data.isTransient() == false))
        {
          if (attribute instanceof ResourceKey)
          {
            final ResourceKey key = (ResourceKey) attribute;
            final ResourceKey parent = key.getParent();
            if (AttributeNames.Core.NAMESPACE.equals(nameSpace) &&
                (AttributeNames.Core.CONTENT_BASE.equals(name) || AttributeNames.Core.SOURCE.equals(name)))
            {
              if (parent != null)
              {
                // unwrap the content base attribute. After deserialization, the report assumes the bundle-location
                // as content base, as the bundle will be gone.
                if (isKeySerializable(parent))
                {
                  stream.writeByte(0);
                  SerializerHelper.getInstance().writeObject(parent, stream);
                }
                else
                {
                  stream.writeByte(1);
                }
              }
              else
              {
                // great, the report was never part of a bundle. That makes life easier and the key should be
                // safely serializable too.

                if (isKeySerializable(key))
                {
                  stream.writeByte(0);
                  SerializerHelper.getInstance().writeObject(key, stream);
                }
                else
                {
                  stream.writeByte(1);
                }
              }
            }
            else
            {
              if ("Resource".equals(data.getValueRole()) || parent != null)
              {
                stream.writeByte(0);
                // todo: Convert into a byte-array key;
                try
                {
View Full Code Here

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

        if (ex == null)
        {
          continue;
        }

        final AttributeMetaData attribute = metaData.getAttributeDescription(namespace, name);
        if (attribute != null && attribute.isDesignTimeValue())
        {
          continue;
        }

        retval = true;
        ex.setRuntime(getRuntime());
        try
        {
          final Object value = evaluate(ex);
          if (attribute == null)
          {
            // Not a declared attribute, but maybe one of the output-handlers can work on this one.
            e.setAttribute(namespace, name, value);
          }
          else
          {
            final Class type = attribute.getTargetType();
            if (value == null || type.isAssignableFrom(value.getClass()))
            {
              e.setAttribute(namespace, name, value);
            }
            else if (value instanceof ErrorValue)
            {
              e.setAttribute(namespace, name, null);
            }
            else
            {

              final PropertyEditor propertyEditor = attribute.getEditor();
              if (propertyEditor != null)
              {
                propertyEditor.setAsText(String.valueOf(value));
                e.setAttribute(namespace, name, propertyEditor.getValue());
              }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.