Search in sources :

Example 36 with KettlePluginException

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

the class ValueMetaFactoryTest method testCreateValueMeta.

@Test
public void testCreateValueMeta() throws KettlePluginException {
    ValueMetaInterface testObject;
    try {
        testObject = ValueMetaFactory.createValueMeta(Integer.MIN_VALUE);
        fail();
    } catch (KettlePluginException expected) {
    // Do nothing, Integer.MIN_VALUE is not a valid option
    }
    try {
        testObject = ValueMetaFactory.createValueMeta(null, Integer.MIN_VALUE);
        fail();
    } catch (KettlePluginException expected) {
    // Do nothing, Integer.MIN_VALUE is not a valid option
    }
    try {
        testObject = ValueMetaFactory.createValueMeta(null, Integer.MIN_VALUE, 10, 10);
        fail();
    } catch (KettlePluginException expected) {
    // Do nothing, Integer.MIN_VALUE is not a valid option
    }
    testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_NONE);
    assertTrue(testObject instanceof ValueMetaNone);
    assertEquals(null, testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testNone", ValueMetaInterface.TYPE_NONE);
    assertTrue(testObject instanceof ValueMetaNone);
    assertEquals("testNone", testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testNone", ValueMetaInterface.TYPE_NONE, 10, 20);
    assertTrue(testObject instanceof ValueMetaNone);
    assertEquals("testNone", testObject.getName());
    assertEquals(10, testObject.getLength());
    assertEquals(20, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_NUMBER);
    assertTrue(testObject instanceof ValueMetaNumber);
    assertEquals(null, testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testNumber", ValueMetaInterface.TYPE_NUMBER);
    assertTrue(testObject instanceof ValueMetaNumber);
    assertEquals("testNumber", testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testNumber", ValueMetaInterface.TYPE_NUMBER, 10, 20);
    assertTrue(testObject instanceof ValueMetaNumber);
    assertEquals("testNumber", testObject.getName());
    assertEquals(10, testObject.getLength());
    assertEquals(20, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_STRING);
    assertTrue(testObject instanceof ValueMetaString);
    assertEquals(null, testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testString", ValueMetaInterface.TYPE_STRING);
    assertTrue(testObject instanceof ValueMetaString);
    assertEquals("testString", testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testString", ValueMetaInterface.TYPE_STRING, 1000, 50);
    assertTrue(testObject instanceof ValueMetaString);
    assertEquals("testString", testObject.getName());
    assertEquals(1000, testObject.getLength());
    // Special case for String
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_DATE);
    assertTrue(testObject instanceof ValueMetaDate);
    assertEquals(null, testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testDate", ValueMetaInterface.TYPE_DATE);
    assertTrue(testObject instanceof ValueMetaDate);
    assertEquals("testDate", testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testDate", ValueMetaInterface.TYPE_DATE, 10, 20);
    assertTrue(testObject instanceof ValueMetaDate);
    assertEquals("testDate", testObject.getName());
    assertEquals(10, testObject.getLength());
    assertEquals(20, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_BOOLEAN);
    assertTrue(testObject instanceof ValueMetaBoolean);
    assertEquals(null, testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testBoolean", ValueMetaInterface.TYPE_BOOLEAN);
    assertTrue(testObject instanceof ValueMetaBoolean);
    assertEquals("testBoolean", testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testBoolean", ValueMetaInterface.TYPE_BOOLEAN, 10, 20);
    assertTrue(testObject instanceof ValueMetaBoolean);
    assertEquals("testBoolean", testObject.getName());
    assertEquals(10, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_INTEGER);
    assertTrue(testObject instanceof ValueMetaInteger);
    assertEquals(null, testObject.getName());
    assertEquals(-1, testObject.getLength());
    // Special case for Integer
    assertEquals(0, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testInteger", ValueMetaInterface.TYPE_INTEGER);
    assertTrue(testObject instanceof ValueMetaInteger);
    assertEquals("testInteger", testObject.getName());
    assertEquals(-1, testObject.getLength());
    // Special case for Integer
    assertEquals(0, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testInteger", ValueMetaInterface.TYPE_INTEGER, 10, 20);
    assertTrue(testObject instanceof ValueMetaInteger);
    assertEquals("testInteger", testObject.getName());
    assertEquals(10, testObject.getLength());
    // Special case for Integer
    assertEquals(0, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_BIGNUMBER);
    assertTrue(testObject instanceof ValueMetaBigNumber);
    assertEquals(null, testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testBigNumber", ValueMetaInterface.TYPE_BIGNUMBER);
    assertTrue(testObject instanceof ValueMetaBigNumber);
    assertEquals("testBigNumber", testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testBigNumber", ValueMetaInterface.TYPE_BIGNUMBER, 10, 20);
    assertTrue(testObject instanceof ValueMetaBigNumber);
    assertEquals("testBigNumber", testObject.getName());
    assertEquals(10, testObject.getLength());
    assertEquals(20, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_SERIALIZABLE);
    assertTrue(testObject instanceof ValueMetaSerializable);
    assertEquals(null, testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testSerializable", ValueMetaInterface.TYPE_SERIALIZABLE);
    assertTrue(testObject instanceof ValueMetaSerializable);
    assertEquals("testSerializable", testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testSerializable", ValueMetaInterface.TYPE_SERIALIZABLE, 10, 20);
    assertTrue(testObject instanceof ValueMetaSerializable);
    assertEquals("testSerializable", testObject.getName());
    assertEquals(10, testObject.getLength());
    assertEquals(20, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_BINARY);
    assertTrue(testObject instanceof ValueMetaBinary);
    assertEquals(null, testObject.getName());
    assertEquals(-1, testObject.getLength());
    // Special case for Binary
    assertEquals(0, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testBinary", ValueMetaInterface.TYPE_BINARY);
    assertTrue(testObject instanceof ValueMetaBinary);
    assertEquals("testBinary", testObject.getName());
    assertEquals(-1, testObject.getLength());
    // Special case for Binary
    assertEquals(0, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testBinary", ValueMetaInterface.TYPE_BINARY, 10, 20);
    assertTrue(testObject instanceof ValueMetaBinary);
    assertEquals("testBinary", testObject.getName());
    assertEquals(10, testObject.getLength());
    // Special case for Binary
    assertEquals(0, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_TIMESTAMP);
    assertTrue(testObject instanceof ValueMetaTimestamp);
    assertEquals(null, testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testTimestamp", ValueMetaInterface.TYPE_TIMESTAMP);
    assertTrue(testObject instanceof ValueMetaTimestamp);
    assertEquals("testTimestamp", testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testTimestamp", ValueMetaInterface.TYPE_TIMESTAMP, 10, 20);
    assertTrue(testObject instanceof ValueMetaTimestamp);
    assertEquals("testTimestamp", testObject.getName());
    assertEquals(10, testObject.getLength());
    assertEquals(20, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_INET);
    assertTrue(testObject instanceof ValueMetaInternetAddress);
    assertEquals(null, testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testInternetAddress", ValueMetaInterface.TYPE_INET);
    assertTrue(testObject instanceof ValueMetaInternetAddress);
    assertEquals("testInternetAddress", testObject.getName());
    assertEquals(-1, testObject.getLength());
    assertEquals(-1, testObject.getPrecision());
    testObject = ValueMetaFactory.createValueMeta("testInternetAddress", ValueMetaInterface.TYPE_INET, 10, 20);
    assertTrue(testObject instanceof ValueMetaInternetAddress);
    assertEquals("testInternetAddress", testObject.getName());
    assertEquals(10, testObject.getLength());
    assertEquals(20, testObject.getPrecision());
}
Also used : KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 37 with KettlePluginException

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

the class CartePluginType method registerXmlPlugins.

protected void registerXmlPlugins() throws KettlePluginException {
    for (PluginFolderInterface folder : pluginFolders) {
        if (folder.isPluginXmlFolder()) {
            List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder());
            for (FileObject file : pluginXmlFiles) {
                try {
                    Document document = XMLHandler.loadXMLFile(file);
                    Node pluginNode = XMLHandler.getSubNode(document, "plugin");
                    if (pluginNode != null) {
                        registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()), this.getClass(), false, file.getParent().getURL());
                    }
                } catch (Exception e) {
                    // We want to report this plugin.xml error, perhaps an XML typo or
                    // something like that...
                    // 
                    log.logError("Error found while reading step plugin.xml file: " + file.getName().toString(), e);
                }
            }
        }
    }
}
Also used : Node(org.w3c.dom.Node) FileObject(org.apache.commons.vfs2.FileObject) Document(org.w3c.dom.Document) KettlePluginException(org.pentaho.di.core.exception.KettlePluginException)

Example 38 with KettlePluginException

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

the class RepositoryPluginType method registerXmlPlugins.

protected void registerXmlPlugins() throws KettlePluginException {
    for (PluginFolderInterface folder : pluginFolders) {
        if (folder.isPluginXmlFolder()) {
            List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder());
            for (FileObject file : pluginXmlFiles) {
                try {
                    Document document = XMLHandler.loadXMLFile(file);
                    Node pluginNode = XMLHandler.getSubNode(document, "plugin");
                    registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()), this.getClass(), false, file.getParent().getURL());
                } catch (Exception e) {
                    // We want to report this plugin.xml error, perhaps an XML typo or something like that...
                    // 
                    log.logError("Error found while reading repository plugin.xml file: " + file.getName().toString(), e);
                }
            }
        }
    }
}
Also used : Node(org.w3c.dom.Node) FileObject(org.apache.commons.vfs2.FileObject) Document(org.w3c.dom.Document) KettlePluginException(org.pentaho.di.core.exception.KettlePluginException)

Example 39 with KettlePluginException

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

the class StepPluginType method registerXmlPlugins.

protected void registerXmlPlugins() throws KettlePluginException {
    for (PluginFolderInterface folder : pluginFolders) {
        if (folder.isPluginXmlFolder()) {
            List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder());
            for (FileObject file : pluginXmlFiles) {
                try {
                    Document document = XMLHandler.loadXMLFile(file);
                    Node pluginNode = XMLHandler.getSubNode(document, "plugin");
                    if (pluginNode != null) {
                        registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()), this.getClass(), false, file.getParent().getURL());
                    }
                } catch (Exception e) {
                    // We want to report this plugin.xml error, perhaps an XML typo or something like that...
                    // 
                    log.logError("Error found while reading step plugin.xml file: " + file.getName().toString(), e);
                }
            }
        }
    }
}
Also used : Node(org.w3c.dom.Node) FileObject(org.apache.commons.vfs2.FileObject) Document(org.w3c.dom.Document) KettlePluginException(org.pentaho.di.core.exception.KettlePluginException)

Example 40 with KettlePluginException

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

the class LogTablePluginType method registerXmlPlugins.

protected void registerXmlPlugins() throws KettlePluginException {
    for (PluginFolderInterface folder : pluginFolders) {
        if (folder.isPluginXmlFolder()) {
            List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder());
            for (FileObject file : pluginXmlFiles) {
                try {
                    Document document = XMLHandler.loadXMLFile(file);
                    Node pluginNode = XMLHandler.getSubNode(document, "plugin");
                    if (pluginNode != null) {
                        registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()), this.getClass(), false, file.getParent().getURL());
                    }
                } catch (Exception e) {
                    // We want to report this plugin.xml error, perhaps an XML typo or something like that...
                    // 
                    log.logError("Error found while reading logging plugin.xml file: " + file.getName().toString(), e);
                }
            }
        }
    }
}
Also used : PluginFolderInterface(org.pentaho.di.core.plugins.PluginFolderInterface) Node(org.w3c.dom.Node) FileObject(org.apache.commons.vfs2.FileObject) Document(org.w3c.dom.Document) KettlePluginException(org.pentaho.di.core.exception.KettlePluginException)

Aggregations

KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)47 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)23 FileObject (org.apache.commons.vfs2.FileObject)12 Node (org.w3c.dom.Node)11 RowMeta (org.pentaho.di.core.row.RowMeta)10 ValueMetaNone (org.pentaho.di.core.row.value.ValueMetaNone)10 Document (org.w3c.dom.Document)10 ArrayList (java.util.ArrayList)9 KettleStepException (org.pentaho.di.core.exception.KettleStepException)9 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)9 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)9 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)7 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)6 Map (java.util.Map)4 KettleException (org.pentaho.di.core.exception.KettleException)4 PluginFolderInterface (org.pentaho.di.core.plugins.PluginFolderInterface)4 IOException (java.io.IOException)3 Annotation (java.lang.annotation.Annotation)3 URLClassLoader (java.net.URLClassLoader)3 HashMap (java.util.HashMap)3