Search in sources :

Example 41 with IMetaverseNode

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

the class BaseKettleMetaverseComponent method createNodeFromDescriptor.

protected IMetaverseNode createNodeFromDescriptor(IComponentDescriptor descriptor, ILogicalIdGenerator idGenerator) {
    String uuid = UUID.randomUUID().toString();
    IMetaverseNode node = null;
    if (descriptor != null) {
        node = metaverseObjectFactory.createNodeObject(uuid, descriptor.getName(), descriptor.getType());
        if (idGenerator.getLogicalIdPropertyKeys().contains(DictionaryConst.PROPERTY_NAMESPACE) && descriptor.getParentNamespace() != null) {
            node.setProperty(DictionaryConst.PROPERTY_NAMESPACE, descriptor.getNamespace().getNamespaceId());
        }
        node.setLogicalIdGenerator(idGenerator);
    }
    return node;
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode)

Example 42 with IMetaverseNode

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

the class BaseKettleMetaverseComponent method createFileNode.

protected IMetaverseNode createFileNode(String fileName, IComponentDescriptor descriptor, String nodeType) throws MetaverseException {
    String normalized;
    IMetaverseNode fileNode = null;
    if (fileName != null && descriptor != null) {
        normalized = KettleAnalyzerUtil.normalizeFilePath(fileName);
        INamespace ns = descriptor.getNamespace();
        INamespace parentNs = ns.getParentNamespace();
        fileNode = metaverseObjectFactory.createNodeObject(parentNs == null ? ns : parentNs, normalized, nodeType);
        fileNode.setProperty(DictionaryConst.PROPERTY_PATH, normalized);
        fileNode.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_FILE);
    }
    return fileNode;
}
Also used : INamespace(org.pentaho.metaverse.api.INamespace) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode)

Example 43 with IMetaverseNode

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

the class DatabaseConnectionAnalyzer method analyze.

/**
 * Analyzes a database connection for metadata.
 *
 * @param dbMeta the object
 * @see IAnalyzer#analyze(IComponentDescriptor, java.lang.Object)
 */
@Override
public IMetaverseNode analyze(IComponentDescriptor descriptor, DatabaseMeta dbMeta) throws MetaverseAnalyzerException {
    if (dbMeta == null) {
        throw new MetaverseAnalyzerException(Messages.getString("ERROR.DatabaseMeta.IsNull"));
    }
    if (metaverseObjectFactory == null) {
        throw new MetaverseAnalyzerException(Messages.getString("ERROR.MetaverseObjectFactory.IsNull"));
    }
    if (metaverseBuilder == null) {
        throw new MetaverseAnalyzerException(Messages.getString("ERROR.MetaverseBuilder.IsNull"));
    }
    IMetaverseNode node = createNodeFromDescriptor(descriptor);
    node.setType(DictionaryConst.NODE_TYPE_DATASOURCE);
    int accessType = dbMeta.getAccessType();
    node.setProperty("accessType", accessType);
    String accessTypeDesc = dbMeta.getAccessTypeDesc();
    node.setProperty("accessTypeDesc", accessTypeDesc);
    String databaseName = dbMeta.getDatabaseName();
    node.setProperty("databaseName", databaseName);
    node.setProperty("name", dbMeta.getName());
    DatabaseInterface dbInterface = dbMeta.getDatabaseInterface();
    node.setProperty("databaseType", dbInterface != null ? Const.NVL(dbInterface.getPluginName(), "Unknown") : "Unknown");
    String port = dbMeta.getDatabasePortNumberString();
    node.setProperty(DictionaryConst.PROPERTY_PORT, port);
    String host = dbMeta.getHostname();
    node.setProperty(DictionaryConst.PROPERTY_HOST_NAME, host);
    String user = dbMeta.getUsername();
    node.setProperty(DictionaryConst.PROPERTY_USER_NAME, user);
    boolean shared = dbMeta.isShared();
    node.setProperty("shared", shared);
    if (accessTypeDesc != null && accessTypeDesc.equals("JNDI")) {
        node.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DB_JNDI);
    } else {
        node.setLogicalIdGenerator(getLogicalIdGenerator());
    }
    metaverseBuilder.addNode(node);
    return node;
}
Also used : DatabaseInterface(org.pentaho.di.core.database.DatabaseInterface) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode)

Example 44 with IMetaverseNode

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

the class JobEntryAnalyzer method createFieldNode.

protected IMetaverseNode createFieldNode(IComponentDescriptor fieldDescriptor, ValueMetaInterface fieldMeta, String targetStepName, boolean addTheNode) {
    IMetaverseNode newFieldNode = createNodeFromDescriptor(fieldDescriptor);
    newFieldNode.setProperty(DictionaryConst.PROPERTY_KETTLE_TYPE, fieldMeta.getTypeDesc());
    // don't add it to the graph if it is a transient node
    if (targetStepName != null) {
        newFieldNode.setProperty(DictionaryConst.PROPERTY_TARGET_STEP, targetStepName);
        newFieldNode.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_TARGET_AWARE);
        if (addTheNode) {
            getMetaverseBuilder().addNode(newFieldNode);
        }
    }
    return newFieldNode;
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode)

Example 45 with IMetaverseNode

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

the class ConnectionExternalResourceStepAnalyzer method customAnalyze.

@Override
protected void customAnalyze(T meta, IMetaverseNode node) throws MetaverseAnalyzerException {
    super.customAnalyze(meta, node);
    IMetaverseNode connectionNode = getConnectionNode();
    // add a node for the connection itself
    getMetaverseBuilder().addNode(connectionNode);
    // link the connection to the step
    getMetaverseBuilder().addLink(connectionNode, DictionaryConst.LINK_DEPENDENCYOF, node);
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode)

Aggregations

IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)131 Test (org.junit.Test)77 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)30 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)23 MetaverseComponentDescriptor (org.pentaho.metaverse.api.MetaverseComponentDescriptor)16 ValueMeta (org.pentaho.di.core.row.ValueMeta)13 IExternalResourceInfo (org.pentaho.metaverse.api.model.IExternalResourceInfo)12 IAnalysisContext (org.pentaho.metaverse.api.IAnalysisContext)11 MetaverseAnalyzerException (org.pentaho.metaverse.api.MetaverseAnalyzerException)11 Vertex (com.tinkerpop.blueprints.Vertex)10 ArrayList (java.util.ArrayList)10 INamespace (org.pentaho.metaverse.api.INamespace)10 TransMeta (org.pentaho.di.trans.TransMeta)9 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)9 MetaverseTransientNode (org.pentaho.dictionary.MetaverseTransientNode)9 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)8 Namespace (org.pentaho.metaverse.api.Namespace)8 StepField (org.pentaho.metaverse.api.StepField)8 HashMap (java.util.HashMap)7 Matchers.anyString (org.mockito.Matchers.anyString)7