Examples of AttributeMetaData


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

    final ElementType type = element.getElementType();
    final ElementMetaData data = type.getMetaData();
    final AttributeMetaData[] datas = data.getAttributeDescriptions();
    for (int i = 0; i < datas.length; i++)
    {
      final AttributeMetaData attributeMetaData = datas[i];
      if (attributeMetaData.isTransient())
      {
        continue;
      }
      if (isFiltered(attributeMetaData))
      {
        continue;
      }

      final Object attValue = element.getAttribute(attributeMetaData.getNameSpace(), attributeMetaData.getName());
      if (attValue == null)
      {
        continue;
      }
      final ResourceReference[] referencedResources = attributeMetaData.getReferencedResources
          (element, state.getMasterReport().getResourceManager(), attValue);
      for (int j = 0; j < referencedResources.length; j++)
      {
        final ResourceReference reference = referencedResources[j];
        if (reference.isLinked())
View Full Code Here

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

        if (value == null)
        {
          continue;
        }

        final AttributeMetaData attrMeta = metaData.getAttributeDescription(namespace, name);
        if (attrMeta == null)
        {
          if (value instanceof String)
          {
            ensureNamespaceDefined(writer, attList, 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));
          }
          continue;
        }

        if (attrMeta.isTransient())
        {
          continue;
        }
        if (isFiltered(attrMeta))
        {
          continue;
        }
        if (attrMeta.isBulk())
        {
          continue;
        }

        ensureNamespaceDefined(writer, attList, namespace);
        try
        {
          final PropertyEditor propertyEditor = attrMeta.getEditor();
          if (propertyEditor != null)
          {
            propertyEditor.setValue(value);
            attList.setAttribute(namespace, name, propertyEditor.getAsText());
          }
View Full Code Here

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

        if (value == null)
        {
          continue;
        }

        final AttributeMetaData attrMeta = metaData.getAttributeDescription(namespace, name);
        if (attrMeta == null)
        {
          continue;
        }

        if (attrMeta.isTransient())
        {
          continue;
        }
        if (isFiltered(attrMeta))
        {
          continue;
        }
        if (attrMeta.isBulk() == false)
        {
          continue;
        }

        if ("Resource".equals(attrMeta.getValueRole()))
        {
          final AttributeList attList = new AttributeList();
          if (attList.isNamespaceUriDefined(namespace) == false &&
              writer.isNamespaceDefined(namespace) == false)
          {
            attList.addNamespaceDeclaration("autoGenNS", namespace);
          }

          if (value instanceof URL)
          {
            attList.setAttribute(AttributeNames.Core.NAMESPACE, "resource-type", "url");
            writer.writeTag(namespace, attrMeta.getName(), attList, XmlWriter.OPEN);
            writer.writeTextNormalized(String.valueOf(value), true);
            writer.writeCloseTag();
          }
          else if (value instanceof ResourceKey)
          {
            try
            {
              final ResourceKey key = (ResourceKey) value;
              final ResourceManager resourceManager = bundle.getResourceManager();
              final ResourceKey bundleKey = bundle.getBundleKey().getParent();
              final String serializedKey = resourceManager.serialize(bundleKey, key);
              attList.setAttribute(AttributeNames.Core.NAMESPACE, "resource-type", "resource-key");
              writer.writeTag(namespace, attrMeta.getName(), attList, XmlWriter.OPEN);
              writer.writeTextNormalized(serializedKey, true);
              writer.writeCloseTag();
            }
            catch (ResourceException re)
            {
              logger.error("Could not serialize the ResourceKey: " + re.getMessage(), re);
              throw new IOException("Could not serialize the ResourceKey: ", re);
            }
          }
          else if (value instanceof File)
          {
            attList.setAttribute(AttributeNames.Core.NAMESPACE, "resource-type", "file");
            writer.writeTag(namespace, attrMeta.getName(), attList, XmlWriter.OPEN);
            writer.writeTextNormalized(String.valueOf(value), true);
            writer.writeCloseTag();
          }
          else if (value instanceof String)
          {
            attList.setAttribute(AttributeNames.Core.NAMESPACE, "resource-type", "local-ref");
            writer.writeTag(namespace, attrMeta.getName(), attList, XmlWriter.OPEN);
            writer.writeTextNormalized(String.valueOf(value), true);
            writer.writeCloseTag();
          }
          else
          {
            logger.warn("Unknown value-type in resource-attribute " + namespace + ":" + name);
          }

          continue;
        }

        if ("Expression".equals(attrMeta.getValueRole()) && value instanceof Expression)
        {
          // write attribute-expressions.
          final AttributeList attList = new AttributeList();
          attList.setAttribute(BundleNamespaces.LAYOUT, "attribute-namespace", namespace);
          attList.setAttribute(BundleNamespaces.LAYOUT, "attribute-name", name);
          ExpressionWriterUtility.writeExpressionCore
              (bundle, state, (Expression) value, writer, BundleNamespaces.LAYOUT, "expression", attList);
          continue;
        }

        try
        {
          final PropertyEditor propertyEditor = attrMeta.getEditor();
          if (propertyEditor != null)
          {

            propertyEditor.setValue(value);
            final String text = propertyEditor.getAsText();

            final AttributeList attList = new AttributeList();
            if (attList.isNamespaceUriDefined(namespace) == false &&
                writer.isNamespaceDefined(namespace) == false)
            {
              attList.addNamespaceDeclaration("autoGenNS", namespace);
            }
            writer.writeTag(namespace, attrMeta.getName(), attList, XmlWriter.OPEN);
            writer.writeTextNormalized(text, true);
            writer.writeCloseTag();
          }
          else
          {
            final String attrValue = ConverterRegistry.toAttributeValue(value);
            final AttributeList attList = new AttributeList();
            if (attList.isNamespaceUriDefined(namespace) == false &&
                writer.isNamespaceDefined(namespace) == false)
            {
              attList.addNamespaceDeclaration("autoGenNS", namespace);
            }
            writer.writeTag(namespace, attrMeta.getName(), attList, XmlWriter.OPEN);
            writer.writeTextNormalized(attrValue, true);
            writer.writeCloseTag();
          }

        }
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

    final String typeName = metaData.getName();

    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(), missingProperties) == false)
      {
        logger.warn("ElementType '" + typeName + ": Attr " + propertyMetaData.getName() + ": No DisplayName");
      }

      final String propertyGrouping = propertyMetaData.getGrouping(locale);
      if (isValid(propertyGrouping, "common", missingProperties) == 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", missingProperties) == false)
        {
          logger.warn(
              "ElementType '" + typeName + ": Attr " + propertyMetaData.getName() + ": No valid deprecate message");
        }
      }
    }
  }
View Full Code Here

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

  public void testRegisterAttribute ()
  {
    final ElementMetaData metaData =
        ElementTypeRegistry.getInstance().getElementType(LabelType.INSTANCE.getMetaData().getName());
    final AttributeMetaData attrMeta = metaData.getAttributeDescription("namespace", "Name");
    assertNull(attrMeta);

    final AttributeRegistry attributeRegistry =
        ElementTypeRegistry.getInstance().getAttributeRegistry(LabelType.INSTANCE);

    final DefaultAttributeMetaData m = new DefaultAttributeMetaData
        ("namespace", "Name", BUNDLE_LOCATION, "prefix",
            String.class, false, ClassicEngineBoot.computeCurrentVersionId());
    attributeRegistry.putAttributeDescription(m);

    final AttributeMetaData attributeDescription = metaData.getAttributeDescription("namespace", "Name");
    assertEquals("prefix", attributeDescription.getKeyPrefix());
    assertEquals(BUNDLE_LOCATION, attributeDescription.getBundleLocation());
  }
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) == false)
        {
          logger.warn("ElementType '" + typeName + ": Attr " + propertyMetaData.getName() + ": No DisplayName");
        }

        final String propertyGrouping = propertyMetaData.getGrouping(locale);
        if (isValid(propertyGrouping) == false)
        {
          logger.warn("ElementType '" + typeName + ": Attr " + propertyMetaData.getName() + ": Grouping is not valid");
        }
        if (propertyMetaData.isDeprecated())
        {
          final String deprecateMessage = propertyMetaData.getDeprecationMessage(locale);
          if (isValid(deprecateMessage) == 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

      System.out.println();

      final AttributeMetaData[] attributeDescriptions = type.getAttributeDescriptions();
      for (int j = 0; j < attributeDescriptions.length; j++)
      {
        final AttributeMetaData attribute = attributeDescriptions[j];
        final String attrNs = ElementTypeRegistry.getInstance().getNamespacePrefix(attribute.getNameSpace());
        final String attrPrefix;
        if (attribute instanceof AbstractMetaData)
        {
          final AbstractMetaData metaData = (AbstractMetaData) attribute;
          final String prefixMetadata = metaData.getKeyPrefix();
          if (StringUtils.isEmpty(prefixMetadata))
          {
            attrPrefix = "";
          }
          else
          {
            attrPrefix = prefixMetadata + attribute.getName() + ".";
          }
        }
        else
        {
          attrPrefix = "element." + type.getName() + ".attribute." + attrNs + "." + attribute.getName();
        }
        attributes.put(attrPrefix, new AttributeCarrier(attrPrefix, attribute));
      }
    }

    System.out.println ("# Attribute definitions");
    final AttributeCarrier[] attributeMetadata = attributes.values().toArray(new AttributeCarrier[attributes.size()]);
    Arrays.sort(attributeMetadata);
    for (int i = 0; i < attributeMetadata.length; i++)
    {
      final AttributeCarrier carrier = attributeMetadata[i];
      final AttributeMetaData attribute = carrier.metaData;
      final String attrNs = ElementTypeRegistry.getInstance().getNamespacePrefix(attribute.getNameSpace());
      final String attrPrefix = carrier.prefix;
      printMetadata(attribute, attrPrefix, "display-name", attribute.getName());
      printMetadata(attribute, attrPrefix, "grouping", attrNs);
      printMetadata(attribute, attrPrefix, "grouping.ordinal", "0");
      printMetadata(attribute, attrPrefix, "ordinal", "0");
      printMetadata(attribute, attrPrefix, "description", "");
      printMetadata(attribute, attrPrefix, "deprecated", "");
View Full Code Here

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

    final HashMap<String, Object> values = new HashMap<String, Object>();
    final ElementMetaData metaData = e.getElementType().getMetaData();
    final AttributeMetaData[] attributeDescriptions = metaData.getAttributeDescriptions();
    for (int i = 0; i < attributeDescriptions.length; i++)
    {
      final AttributeMetaData attributeDescription = attributeDescriptions[i];
      final Object attribute = e.getAttribute(attributeDescription.getNameSpace(), attributeDescription.getName());
      if (attribute == null)
      {
        continue;
      }

      final String[] referencedFields = attributeDescription.getReferencedFields(e, attribute);
      for (int j = 0; j < referencedFields.length; j++)
      {
        final String field = referencedFields[j];
        final Object value = currentDataRow.get(field);
        values.put(field, value);
View Full Code Here

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

    }
  }

  public Object getValueAt(final int rowIndex, final int columnIndex)
  {
    final AttributeMetaData metaData = getMetaData(rowIndex);
    if (metaData == null)
    {
      return getGroupings(rowIndex);
    }
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.