Search in sources :

Example 1 with MetaverseAnalyzerException

use of org.pentaho.metaverse.api.MetaverseAnalyzerException in project pentaho-metaverse by pentaho.

the class StepAnalyzer method getOutputFields.

@Override
public RowMetaInterface getOutputFields(T meta) {
    RowMetaInterface rmi = null;
    try {
        validateState(null, meta);
    } catch (MetaverseAnalyzerException e) {
    // eat it
    }
    if (parentTransMeta != null) {
        try {
            ProgressNullMonitorListener progressMonitor = new ProgressNullMonitorListener();
            rmi = parentTransMeta.getStepFields(parentStepMeta, progressMonitor);
            progressMonitor.done();
        } catch (KettleStepException e) {
            rmi = null;
        }
    }
    return rmi;
}
Also used : KettleStepException(org.pentaho.di.core.exception.KettleStepException) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ProgressNullMonitorListener(org.pentaho.di.core.ProgressNullMonitorListener)

Example 2 with MetaverseAnalyzerException

use of org.pentaho.metaverse.api.MetaverseAnalyzerException in project pentaho-metaverse by pentaho.

the class StepAnalyzer method getInputFields.

@Override
public Map<String, RowMetaInterface> getInputFields(T meta) {
    Map<String, RowMetaInterface> rowMeta = null;
    try {
        validateState(null, meta);
    } catch (MetaverseAnalyzerException e) {
    // eat it
    }
    if (parentTransMeta != null) {
        try {
            rowMeta = new HashMap<String, RowMetaInterface>();
            ProgressNullMonitorListener progressMonitor = new ProgressNullMonitorListener();
            prevStepNames = parentTransMeta.getPrevStepNames(parentStepMeta);
            RowMetaInterface rmi = parentTransMeta.getPrevStepFields(parentStepMeta, progressMonitor);
            progressMonitor.done();
            if (!ArrayUtils.isEmpty(prevStepNames)) {
                rowMeta.put(prevStepNames[0], rmi);
            }
        } catch (KettleStepException e) {
            rowMeta = null;
        }
    }
    return rowMeta;
}
Also used : KettleStepException(org.pentaho.di.core.exception.KettleStepException) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ProgressNullMonitorListener(org.pentaho.di.core.ProgressNullMonitorListener)

Example 3 with MetaverseAnalyzerException

use of org.pentaho.metaverse.api.MetaverseAnalyzerException in project pentaho-metaverse by pentaho.

the class StepAnalyzerTest method testGetInputFieldsWithException.

@Test
public void testGetInputFieldsWithException() {
    analyzer = new StepAnalyzer() {

        @Override
        public void validateState(IComponentDescriptor descriptor, BaseStepMeta object) throws MetaverseAnalyzerException {
            throw new MetaverseAnalyzerException("expected exception");
        }

        @Override
        public Set<Class<? extends BaseStepMeta>> getSupportedSteps() {
            return null;
        }

        @Override
        protected Set getUsedFields(BaseStepMeta meta) {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        protected void customAnalyze(BaseStepMeta meta, IMetaverseNode rootNode) throws MetaverseAnalyzerException {
        // TODO Auto-generated method stub
        }
    };
    assertNull(analyzer.getInputFields(null));
}
Also used : IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) HashSet(java.util.HashSet) Set(java.util.Set) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Test(org.junit.Test)

Example 4 with MetaverseAnalyzerException

use of org.pentaho.metaverse.api.MetaverseAnalyzerException in project pentaho-metaverse by pentaho.

the class DatabaseConnectionAnalyzerTest method testAnalyze.

@Test
public void testAnalyze() {
    when(builder.addNode(any(IMetaverseNode.class))).thenAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            Object[] args = invocation.getArguments();
            // add the logicalId to the node like it does in the real builder
            IMetaverseNode node = (IMetaverseNode) args[0];
            node.setProperty(DictionaryConst.PROPERTY_LOGICAL_ID, node.getLogicalId());
            return builder;
        }
    });
    try {
        IMetaverseNode node = dbConnectionAnalyzer.analyze(mockDescriptor, databaseMeta);
        builder.addNode(node);
        assertNotNull(node);
        assertEquals(14, node.getPropertyKeys().size());
    } catch (MetaverseAnalyzerException e) {
        fail("analyze() should not throw an exception!");
    }
}
Also used : MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Test(org.junit.Test)

Example 5 with MetaverseAnalyzerException

use of org.pentaho.metaverse.api.MetaverseAnalyzerException in project pentaho-metaverse by pentaho.

the class MergeJoinStepAnalyzer method getInputFields.

@Override
public Map<String, RowMetaInterface> getInputFields(MergeJoinMeta meta) {
    Map<String, RowMetaInterface> rowMeta = null;
    try {
        validateState(null, meta);
    } catch (MetaverseAnalyzerException e) {
    // eat it
    }
    if (parentTransMeta != null) {
        rowMeta = new HashMap<>();
        try {
            StepMeta stepMeta1 = meta.getStepIOMeta().getInfoStreams().get(0).getStepMeta();
            ProgressNullMonitorListener progress = new ProgressNullMonitorListener();
            leftStepFields = parentTransMeta.getStepFields(stepMeta1, progress);
            progress.done();
            progress = new ProgressNullMonitorListener();
            StepMeta stepMeta2 = meta.getStepIOMeta().getInfoStreams().get(1).getStepMeta();
            rightStepFields = parentTransMeta.getStepFields(stepMeta2, progress);
            progress.done();
            rowMeta.put(stepMeta1.getName(), leftStepFields);
            rowMeta.put(stepMeta2.getName(), rightStepFields);
        } catch (Throwable t) {
        // eat it
        }
    }
    return rowMeta;
}
Also used : MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ProgressNullMonitorListener(org.pentaho.di.core.ProgressNullMonitorListener) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta)

Aggregations

MetaverseAnalyzerException (org.pentaho.metaverse.api.MetaverseAnalyzerException)23 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)13 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)9 MetaverseComponentDescriptor (org.pentaho.metaverse.api.MetaverseComponentDescriptor)9 KettleException (org.pentaho.di.core.exception.KettleException)7 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)6 TransMeta (org.pentaho.di.trans.TransMeta)6 JobMeta (org.pentaho.di.job.JobMeta)5 INamespace (org.pentaho.metaverse.api.INamespace)5 Namespace (org.pentaho.metaverse.api.Namespace)5 FileNotFoundException (java.io.FileNotFoundException)4 KettleMissingPluginsException (org.pentaho.di.core.exception.KettleMissingPluginsException)4 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)4 Repository (org.pentaho.di.repository.Repository)4 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)4 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)4 HashSet (java.util.HashSet)3 ProgressNullMonitorListener (org.pentaho.di.core.ProgressNullMonitorListener)3 KettleStepException (org.pentaho.di.core.exception.KettleStepException)3 IDocument (org.pentaho.metaverse.api.IDocument)3