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();
}
}
}
}
}
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;
}
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;
}
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);
}
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;
}
Aggregations