Search in sources :

Example 1 with KettleAttribute

use of org.pentaho.di.core.KettleAttribute in project pentaho-kettle by pentaho.

the class BaseStepMeta method loadStepAttributes.

/**
 * Load step attributes.
 *
 * @throws KettleException
 *           the kettle exception
 */
protected void loadStepAttributes() throws KettleException {
    try (InputStream inputStream = getClass().getResourceAsStream(STEP_ATTRIBUTES_FILE)) {
        if (inputStream != null) {
            Document document = XMLHandler.loadXMLFile(inputStream);
            Node attrsNode = XMLHandler.getSubNode(document, "attributes");
            List<Node> nodes = XMLHandler.getNodes(attrsNode, "attribute");
            attributes = new ArrayList<KettleAttributeInterface>();
            for (Node node : nodes) {
                String key = XMLHandler.getTagAttribute(node, "id");
                String xmlCode = XMLHandler.getTagValue(node, "xmlcode");
                String repCode = XMLHandler.getTagValue(node, "repcode");
                String description = XMLHandler.getTagValue(node, "description");
                String tooltip = XMLHandler.getTagValue(node, "tooltip");
                int valueType = ValueMetaFactory.getIdForValueMeta(XMLHandler.getTagValue(node, "valuetype"));
                String parentId = XMLHandler.getTagValue(node, "parentid");
                KettleAttribute attribute = new KettleAttribute(key, xmlCode, repCode, description, tooltip, valueType, findParent(attributes, parentId));
                attributes.add(attribute);
            }
        }
    } catch (Exception e) {
        throw new KettleException("Unable to load file " + STEP_ATTRIBUTES_FILE, e);
    }
}
Also used : KettleAttributeInterface(org.pentaho.di.core.KettleAttributeInterface) KettleException(org.pentaho.di.core.exception.KettleException) InputStream(java.io.InputStream) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document) KettleAttribute(org.pentaho.di.core.KettleAttribute) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleStepException(org.pentaho.di.core.exception.KettleStepException)

Aggregations

InputStream (java.io.InputStream)1 KettleAttribute (org.pentaho.di.core.KettleAttribute)1 KettleAttributeInterface (org.pentaho.di.core.KettleAttributeInterface)1 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)1 KettleException (org.pentaho.di.core.exception.KettleException)1 KettleStepException (org.pentaho.di.core.exception.KettleStepException)1 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)1 Document (org.w3c.dom.Document)1 Node (org.w3c.dom.Node)1