Search in sources :

Example 16 with MetaverseComponentDescriptor

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

the class TextFileOutputStepAnalyzerTest method setUp.

@Before
public void setUp() throws Exception {
    when(mockNamespace.getParentNamespace()).thenReturn(mockNamespace);
    descriptor = new MetaverseComponentDescriptor("test", DictionaryConst.NODE_TYPE_TRANS_STEP, mockNamespace);
    analyzer = spy(new TextFileOutputStepAnalyzer());
    analyzer.setDescriptor(descriptor);
    analyzer.setObjectFactory(MetaverseTestUtils.getMetaverseObjectFactory());
    inputs = new StepNodes();
    inputs.addNode("previousStep", "first", node);
    inputs.addNode("previousStep", "last", node);
    inputs.addNode("previousStep", "age", node);
    inputs.addNode("previousStep", "filename", node);
    doReturn(inputs).when(analyzer).getInputs();
}
Also used : StepNodes(org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor) Before(org.junit.Before)

Example 17 with MetaverseComponentDescriptor

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

the class StepAnalyzer method getStepFieldOriginDescriptor.

protected IComponentDescriptor getStepFieldOriginDescriptor(IComponentDescriptor descriptor, String fieldName) throws MetaverseAnalyzerException {
    if (descriptor == null || stepFields == null) {
        return null;
    }
    ValueMetaInterface vmi = stepFields.searchValueMeta(fieldName);
    String origin = (vmi == null) ? fieldName : vmi.getOrigin();
    // if we can't determine the origin, throw an exception
    if (origin == null && !ArrayUtils.isEmpty(prevStepNames)) {
        throw new MetaverseAnalyzerException(Messages.getString("ERROR.NoOriginForField", fieldName));
    }
    IMetaverseNode tmpOriginNode = metaverseObjectFactory.createNodeObject(UUID.randomUUID().toString(), origin, DictionaryConst.NODE_TYPE_TRANS_STEP);
    tmpOriginNode.setProperty(DictionaryConst.PROPERTY_NAMESPACE, rootNode.getProperty(DictionaryConst.PROPERTY_NAMESPACE));
    INamespace stepFieldNamespace = new Namespace(tmpOriginNode.getLogicalId());
    MetaverseComponentDescriptor d = new MetaverseComponentDescriptor(fieldName, DictionaryConst.NODE_TYPE_TRANS_FIELD, tmpOriginNode, descriptor.getContext());
    return d;
}
Also used : MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) INamespace(org.pentaho.metaverse.api.INamespace) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) INamespace(org.pentaho.metaverse.api.INamespace) Namespace(org.pentaho.metaverse.api.Namespace) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor)

Example 18 with MetaverseComponentDescriptor

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

the class HTTPPostStepAnalyzer method createResourceNode.

@Override
public IMetaverseNode createResourceNode(IExternalResourceInfo resource) throws MetaverseException {
    MetaverseComponentDescriptor componentDescriptor = new MetaverseComponentDescriptor(resource.getName(), getResourceInputNodeType(), descriptor.getNamespace(), descriptor.getContext());
    IMetaverseNode node = createNodeFromDescriptor(componentDescriptor);
    return node;
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor)

Example 19 with MetaverseComponentDescriptor

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

the class RestClientStepAnalyzer method createResourceNode.

@Override
public IMetaverseNode createResourceNode(IExternalResourceInfo resource) throws MetaverseException {
    MetaverseComponentDescriptor componentDescriptor = new MetaverseComponentDescriptor(resource.getName(), getResourceInputNodeType(), descriptor.getNamespace(), descriptor.getContext());
    IMetaverseNode node = createNodeFromDescriptor(componentDescriptor);
    return node;
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor)

Example 20 with MetaverseComponentDescriptor

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

the class TableInputStepAnalyzer method createTableNode.

@Override
protected IMetaverseNode createTableNode(IExternalResourceInfo resource) throws MetaverseAnalyzerException {
    BaseDatabaseResourceInfo resourceInfo = (BaseDatabaseResourceInfo) resource;
    Object obj = resourceInfo.getAttributes().get(DictionaryConst.PROPERTY_QUERY);
    String query = obj == null ? null : obj.toString();
    // create a node for the table
    MetaverseComponentDescriptor componentDescriptor = new MetaverseComponentDescriptor("SQL", DictionaryConst.NODE_TYPE_SQL_QUERY, getConnectionNode(), getDescriptor().getContext());
    // set the namespace to be the id of the connection node.
    IMetaverseNode tableNode = createNodeFromDescriptor(componentDescriptor);
    tableNode.setProperty(DictionaryConst.PROPERTY_NAMESPACE, componentDescriptor.getNamespace().getNamespaceId());
    tableNode.setProperty(DictionaryConst.PROPERTY_QUERY, query);
    tableNode.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DB_QUERY);
    return tableNode;
}
Also used : BaseDatabaseResourceInfo(org.pentaho.metaverse.api.model.BaseDatabaseResourceInfo) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor)

Aggregations

MetaverseComponentDescriptor (org.pentaho.metaverse.api.MetaverseComponentDescriptor)36 Before (org.junit.Before)19 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)16 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)9 MetaverseAnalyzerException (org.pentaho.metaverse.api.MetaverseAnalyzerException)8 IMetaverseObjectFactory (org.pentaho.metaverse.api.IMetaverseObjectFactory)6 KettleException (org.pentaho.di.core.exception.KettleException)5 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)5 INamespace (org.pentaho.metaverse.api.INamespace)5 FileNotFoundException (java.io.FileNotFoundException)4 Matchers.anyString (org.mockito.Matchers.anyString)4 KettleMissingPluginsException (org.pentaho.di.core.exception.KettleMissingPluginsException)4 KettleStepException (org.pentaho.di.core.exception.KettleStepException)4 JobMeta (org.pentaho.di.job.JobMeta)4 Repository (org.pentaho.di.repository.Repository)4 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)4 Namespace (org.pentaho.metaverse.api.Namespace)4 TransMeta (org.pentaho.di.trans.TransMeta)3 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)3 StepMeta (org.pentaho.di.trans.step.StepMeta)3