Search in sources :

Example 1 with PluginRegistry

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

the class KettleDatabaseRepositoryCreationHelper method updateJobEntryTypes.

/**
 * Update the list in R_JOBENTRY_TYPE
 *
 * @param create
 *
 * @exception KettleException
 *              if something went wrong during the update.
 */
public void updateJobEntryTypes(List<String> statements, boolean dryrun, boolean create) throws KettleException {
    synchronized (repository) {
        // We should only do an update if something has changed...
        PluginRegistry registry = PluginRegistry.getInstance();
        List<PluginInterface> jobPlugins = registry.getPlugins(JobEntryPluginType.class);
        for (int i = 0; i < jobPlugins.size(); i++) {
            PluginInterface jobPlugin = jobPlugins.get(i);
            String type_desc = jobPlugin.getIds()[0];
            String type_desc_long = jobPlugin.getName();
            ObjectId id = null;
            if (!create) {
                id = repository.jobEntryDelegate.getJobEntryTypeID(type_desc);
            }
            if (id == null) {
                // Not found, we need to add this one...
                // We need to add this one ...
                id = new LongObjectId(i + 1);
                if (!create) {
                    id = repository.connectionDelegate.getNextJobEntryTypeID();
                }
                RowMetaAndData table = new RowMetaAndData();
                table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_ID_JOBENTRY_TYPE), id);
                table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_CODE), type_desc);
                table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_DESCRIPTION), type_desc_long);
                if (dryrun) {
                    String sql = database.getSQLOutput(null, KettleDatabaseRepository.TABLE_R_JOBENTRY_TYPE, table.getRowMeta(), table.getData(), null);
                    statements.add(sql);
                } else {
                    database.prepareInsert(table.getRowMeta(), null, KettleDatabaseRepository.TABLE_R_JOBENTRY_TYPE);
                    database.setValuesInsert(table);
                    database.insertRow();
                    database.closeInsert();
                }
            }
        }
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 2 with PluginRegistry

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

the class ExecuteJobServlet method openRepository.

@VisibleForTesting
Repository openRepository(String repositoryName, String user, String pass) throws KettleException {
    if (Utils.isEmpty(repositoryName)) {
        return null;
    }
    RepositoriesMeta repositoriesMeta = new RepositoriesMeta();
    repositoriesMeta.readData();
    RepositoryMeta repositoryMeta = repositoriesMeta.findRepository(repositoryName);
    if (repositoryMeta == null) {
        String message = BaseMessages.getString(PKG, "ExecuteJobServlet.Error.UnableToFindRepository", repositoryName);
        throw new KettleRepositoryNotFoundException(message);
    }
    PluginRegistry registry = PluginRegistry.getInstance();
    Repository repository = registry.loadClass(RepositoryPluginType.class, repositoryMeta, Repository.class);
    repository.init(repositoryMeta);
    repository.connect(user, pass);
    return repository;
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) Repository(org.pentaho.di.repository.Repository) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) RepositoriesMeta(org.pentaho.di.repository.RepositoriesMeta) KettleRepositoryNotFoundException(org.pentaho.di.repository.KettleRepositoryNotFoundException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with PluginRegistry

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

the class ExecuteTransServletTest method initMocksForTransExecution.

private Trans initMocksForTransExecution(HttpServletRequest mockHttpServletRequest, HttpServletResponse mockHttpServletResponse) throws Exception {
    RepositoriesMeta repositoriesMeta = mock(RepositoriesMeta.class);
    RepositoryMeta repositoryMeta = mock(RepositoryMeta.class);
    Repository repository = mock(Repository.class);
    PluginRegistry pluginRegistry = mock(PluginRegistry.class);
    RepositoryDirectoryInterface repositoryDirectoryInterface = mock(RepositoryDirectoryInterface.class);
    ObjectId objectId = mock(ObjectId.class);
    TransMeta transMeta = mock(TransMeta.class);
    Trans trans = mock(Trans.class);
    KettleLogStore.init();
    StringWriter out = new StringWriter();
    PrintWriter printWriter = new PrintWriter(out);
    when(mockHttpServletRequest.getParameter("rep")).thenReturn("Repo");
    when(mockHttpServletRequest.getParameter("trans")).thenReturn("Trans");
    when(mockHttpServletRequest.getParameter("user")).thenReturn("user");
    when(mockHttpServletRequest.getParameter("pass")).thenReturn("pass");
    when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
    whenNew(RepositoriesMeta.class).withNoArguments().thenReturn(repositoriesMeta);
    when(repositoriesMeta.findRepository("Repo")).thenReturn(repositoryMeta);
    mockStatic(PluginRegistry.class);
    when(PluginRegistry.getInstance()).thenReturn(pluginRegistry);
    when(pluginRegistry.loadClass(RepositoryPluginType.class, repositoryMeta, Repository.class)).thenReturn(repository);
    when(repository.isConnected()).thenReturn(true);
    when(repository.loadRepositoryDirectoryTree()).thenReturn(repositoryDirectoryInterface);
    when(repositoryDirectoryInterface.findDirectory("/")).thenReturn(repositoryDirectoryInterface);
    when(repository.getTransformationID("Trans", repositoryDirectoryInterface)).thenReturn(objectId);
    when(repository.loadTransformation(objectId, null)).thenReturn(transMeta);
    when(mockHttpServletRequest.getParameterNames()).thenReturn(Collections.enumeration(new ArrayList<>()));
    whenNew(Trans.class).withAnyArguments().thenReturn(trans);
    setInternalState(executeTransServlet, "socketRepository", mock(SocketRepository.class));
    setInternalState(executeTransServlet, "transformationMap", mock(TransformationMap.class));
    return trans;
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) ObjectId(org.pentaho.di.repository.ObjectId) TransMeta(org.pentaho.di.trans.TransMeta) ArrayList(java.util.ArrayList) RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) Repository(org.pentaho.di.repository.Repository) StringWriter(java.io.StringWriter) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) RepositoriesMeta(org.pentaho.di.repository.RepositoriesMeta) Trans(org.pentaho.di.trans.Trans) PrintWriter(java.io.PrintWriter)

Example 4 with PluginRegistry

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

the class KettleClientEnvironment method init.

public static synchronized void init(List<PluginTypeInterface> pluginsToLoad) throws KettleException {
    if (initialized != null) {
        return;
    }
    if (KettleClientEnvironment.instance == null) {
        KettleClientEnvironment.instance = new KettleClientEnvironment();
    }
    createKettleHome();
    // Read the kettle.properties file before anything else
    // 
    EnvUtil.environmentInit();
    // Initialize the logging back-end.
    // 
    KettleLogStore.init();
    // 
    if (!"Y".equalsIgnoreCase(System.getProperty(Const.KETTLE_DISABLE_CONSOLE_LOGGING, "N"))) {
        KettleLogStore.getAppender().addLoggingEventListener(new ConsoleLoggingEventListener());
    }
    KettleLogStore.getAppender().addLoggingEventListener(new Slf4jLoggingEventListener());
    // Load plugins
    // 
    pluginsToLoad.forEach(PluginRegistry::addPluginType);
    PluginRegistry.init();
    List<PluginInterface> logginPlugins = PluginRegistry.getInstance().getPlugins(LoggingPluginType.class);
    initLogginPlugins(logginPlugins);
    String passwordEncoderPluginID = Const.NVL(EnvUtil.getSystemProperty(Const.KETTLE_PASSWORD_ENCODER_PLUGIN), "Kettle");
    Encr.init(passwordEncoderPluginID);
    initialized = new Boolean(true);
}
Also used : Slf4jLoggingEventListener(org.pentaho.di.core.logging.Slf4jLoggingEventListener) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) LoggingPluginInterface(org.pentaho.di.core.logging.LoggingPluginInterface) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ConsoleLoggingEventListener(org.pentaho.di.core.logging.ConsoleLoggingEventListener)

Example 5 with PluginRegistry

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

the class TransPreviewFactory method generatePreviewTransformation.

public static final TransMeta generatePreviewTransformation(VariableSpace parent, StepMetaInterface oneMeta, String oneStepname) {
    PluginRegistry registry = PluginRegistry.getInstance();
    TransMeta previewMeta = new TransMeta(parent);
    // The following operation resets the internal variables!
    // 
    previewMeta.setName(parent == null ? "Preview transformation" : parent.toString());
    // At it to the first step.
    StepMeta one = new StepMeta(registry.getPluginId(StepPluginType.class, oneMeta), oneStepname, oneMeta);
    one.setLocation(50, 50);
    one.setDraw(true);
    previewMeta.addStep(one);
    DummyTransMeta twoMeta = new DummyTransMeta();
    StepMeta two = new StepMeta(registry.getPluginId(StepPluginType.class, twoMeta), "dummy", twoMeta);
    two.setLocation(250, 50);
    two.setDraw(true);
    previewMeta.addStep(two);
    TransHopMeta hop = new TransHopMeta(one, two);
    previewMeta.addTransHop(hop);
    return previewMeta;
}
Also used : StepPluginType(org.pentaho.di.core.plugins.StepPluginType) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)

Aggregations

PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)160 StepMeta (org.pentaho.di.trans.step.StepMeta)104 TransMeta (org.pentaho.di.trans.TransMeta)103 Trans (org.pentaho.di.trans.Trans)84 TransHopMeta (org.pentaho.di.trans.TransHopMeta)78 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)74 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)72 StepInterface (org.pentaho.di.trans.step.StepInterface)70 RowStepCollector (org.pentaho.di.trans.RowStepCollector)68 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)55 InjectorMeta (org.pentaho.di.trans.steps.injector.InjectorMeta)53 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)49 RowProducer (org.pentaho.di.trans.RowProducer)48 Test (org.junit.Test)35 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)26 KettleException (org.pentaho.di.core.exception.KettleException)26 ArrayList (java.util.ArrayList)15 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)13 Before (org.junit.Before)11 HashMap (java.util.HashMap)7