Examples of AttributeMetaData


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

    }

    // This is an attribute change event ... see if it is one we are concerned about
    final AttributeChange attributeChange = (AttributeChange) event.getParameter();
    final ReportElement reportElement = (ReportElement) event.getElement();
    final AttributeMetaData attributeDescription = reportElement.getMetaData().getAttributeDescription(attributeChange.getNamespace(), attributeChange.getName());
    if (attributeDescription == null ||
        AttributeMetaData.VALUEROLE_RESOURCE.equals(attributeDescription.getValueRole()) == false)
    {
      return;
    }

    // See if we need to load the resource's value into the resource key
View Full Code Here

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

                                 final String nameSpace,
                                 final String name,
                                 final Object value)
  {
    final ElementMetaData metaData = type.getMetaData();
    final AttributeMetaData attributeDescription = metaData.getAttributeDescription(nameSpace, name);
    if (attributeDescription == null)
    {
      return;
    }

    final String valueRole = attributeDescription.getValueRole();
    final Class valueType = attributeDescription.getTargetType();
    final PropertyEditor propertyEditor = attributeDescription.getEditor();
    final GroupedName groupedName = new GroupedName(attributeDescription);
    final GroupingHeader groupingHeader = createGroupingHeader(attributeDescription);
    backend.add(new CrosstabOption(groupingHeader, type, groupedName, valueType, valueRole, propertyEditor, value));

    fireTableRowsInserted(backend.size() - 1, backend.size() - 1);
View Full Code Here

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

    {
      setEnabled(false);
      return;
    }
    final Element e = (Element) o;
    final AttributeMetaData data = e.getElementType().getMetaData().getAttributeDescription
            (AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE);
    if (data == null)
    {
      setEnabled(false);
      return;
    }
    setEnabled("Resource".equals(data.getValueRole())); // NON-NLS
  }
View Full Code Here

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

    if (o instanceof Element == false)
    {
      return;
    }
    final Element element = (Element) o;
    final AttributeMetaData data = element.getElementType().getMetaData().getAttributeDescription
            (AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE);
    if (data == null)
    {
      return;
    }
    if("Resource".equals(data.getValueRole()) == false) // NON-NLS
    {
      return;
    }

    final CustomPropertyEditorDialog editorDialog;
View Full Code Here

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

  }

  private AttributeMetaData selectMetaData(final ReportElement element)
  {
    final ElementMetaData elementMetaData = element.getMetaData();
    final AttributeMetaData fieldData =
            elementMetaData.getAttributeDescription(AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD);
    if (fieldData != null)
    {
      return fieldData;
    }
View Full Code Here

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

      final ElementMetaData data = visualElement.getMetaData();
      final AttributeMetaData[] datas = data.getAttributeDescriptions();
      for (int j = 0; j < datas.length; j++)
      {
        final AttributeMetaData metaData = datas[j];
        final AttributeMetaData attributeMetaData =
            targetMetaData.getAttributeDescription(metaData.getNameSpace(), metaData.getName());
        if (attributeMetaData == null)
        {
          visualElement.setAttribute(metaData.getNameSpace(), metaData.getName(), null);
          visualElement.setAttributeExpression(metaData.getNameSpace(), metaData.getName(), null);
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)
            {
              if (failOnErrors)
              {
                throw new InvalidReportStateException(String.format
                    ("Failed to evaluate attribute-expression for attribute %s:%s on element [%s]", // NON-NLS
                        namespace, name,
                        FunctionUtilities.computeElementLocation(e)));
              }
              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

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

        {
          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 (textValue != null)
          {
            if ("".equals(textValue) == false)
            {
              attList.setAttribute(namespace, name, textValue);
              this.xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "attribute", attList, XmlWriter.CLOSE);
            }
          }
          else
          {
            if (value instanceof ResourceKey)
            {
              final ResourceKey reskey = (ResourceKey) value;
              final String identifierAsString = reskey.getIdentifierAsString();
              attList.setAttribute(namespace, name, "resource-key:" + reskey.getSchema() + ":" + identifierAsString);
              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: " + value);
            }
          }
        }
        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

  private void setAttributeValue(final ReportElement element,
                                 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 (isFiltered(attributeMetaData)) {
      return;
    }

    if (ElementMetaData.VALUEROLE_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());
        } else {
          final ConverterRegistry instance = ConverterRegistry.getInstance();
View Full Code Here

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

            value instanceof ResourceKey)
        {
          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 (textValue != null)
          {
            if ("".equals(textValue) == false)
            {
              attList.setAttribute(namespace, name, textValue);
              this.xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "attribute", attList, XmlWriter.CLOSE);
            }
          }
          else
          {
            if (value instanceof ResourceKey)
            {
              final ResourceKey reskey = (ResourceKey) value;
              final String identifierAsString = reskey.getIdentifierAsString();
              attList.setAttribute(namespace, name, "resource-key:" + reskey.getSchema() + ":" + identifierAsString);
              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: " + value);
            }
          }
        }
        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
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.