use of org.pentaho.di.repository.Repository in project pentaho-kettle by pentaho.
the class AbstractBaseCommandExecutor method establishRepositoryConnection.
public Repository establishRepositoryConnection(RepositoryMeta repositoryMeta, final String username, final String password, final RepositoryOperation... operations) throws KettleException {
Repository rep = PluginRegistry.getInstance().loadClass(RepositoryPluginType.class, repositoryMeta, Repository.class);
rep.init(repositoryMeta);
rep.getLog().setLogLevel(getLog().getLogLevel());
rep.connect(username != null ? username : null, password != null ? password : null);
if (operations != null) {
// throws KettleSecurityException if username does does have permission for given operations
rep.getSecurityProvider().validateAction(operations);
}
return rep;
}
use of org.pentaho.di.repository.Repository in project pentaho-kettle by pentaho.
the class JobEntryJobTest method testConnectedLoad_RepByRef_Guess.
/**
* When connected to the repository and {@link JobEntryJob} references a child job by {@link ObjectId},
* guess {@link ObjectLocationSpecificationMethod} as {@code REPOSITORY_BY_REFERENCE}.
* Load the job from the repository using the specified {@link ObjectId}.
*/
@Test
public void testConnectedLoad_RepByRef_Guess() throws Exception {
Repository myrepo = mock(Repository.class);
doReturn(true).when(myrepo).isConnected();
doReturn(null).when(myrepo).getJobEntryAttributeString(any(ObjectId.class), anyString());
doReturn(JOB_ENTRY_JOB_OBJECT_ID.toString()).when(myrepo).getJobEntryAttributeString(JOB_ENTRY_JOB_OBJECT_ID, "job_object_id");
JobEntryJob jej = getJej();
jej.loadRep(myrepo, store, JOB_ENTRY_JOB_OBJECT_ID, databases, servers);
jej.getJobMeta(myrepo, store, space);
assertEquals(ObjectLocationSpecificationMethod.REPOSITORY_BY_REFERENCE, jej.getSpecificationMethod());
verify(myrepo, times(1)).loadJob(JOB_ENTRY_JOB_OBJECT_ID, null);
}
use of org.pentaho.di.repository.Repository in project pentaho-kettle by pentaho.
the class JobEntryJobTest method testConnectedLoad_RepByRef.
/**
* When connected to the repository and {@link JobEntryJob} references a child job by {@link ObjectId},
* keep {@link ObjectLocationSpecificationMethod} as {@code REPOSITORY_BY_REFERENCE}.
* Load the job from the repository using the specified {@link ObjectId}.
*/
@Test
public void testConnectedLoad_RepByRef() throws Exception {
Repository myrepo = mock(Repository.class);
doReturn(true).when(myrepo).isConnected();
doReturn(null).when(myrepo).getJobEntryAttributeString(any(ObjectId.class), anyString());
doReturn("rep_ref").when(myrepo).getJobEntryAttributeString(JOB_ENTRY_JOB_OBJECT_ID, "specification_method");
doReturn(JOB_ENTRY_JOB_OBJECT_ID.toString()).when(myrepo).getJobEntryAttributeString(JOB_ENTRY_JOB_OBJECT_ID, "job_object_id");
JobEntryJob jej = getJej();
jej.loadRep(myrepo, store, JOB_ENTRY_JOB_OBJECT_ID, databases, servers);
jej.getJobMeta(myrepo, store, space);
assertEquals(ObjectLocationSpecificationMethod.REPOSITORY_BY_REFERENCE, jej.getSpecificationMethod());
verify(myrepo, times(1)).loadJob(JOB_ENTRY_JOB_OBJECT_ID, null);
}
use of org.pentaho.di.repository.Repository in project pentaho-kettle by pentaho.
the class JobEntryJobTest method testConnectedLoad_RepByName_HDFS.
/**
* When connected to the repository and {@link JobEntryJob} references a child job by name,
* keep {@link ObjectLocationSpecificationMethod} as {@code REPOSITORY_BY_NAME}.
* Load the job from the repository using the specified job name and directory.
*/
@Test
public void testConnectedLoad_RepByName_HDFS() throws Exception {
Repository myrepo = mock(Repository.class);
doReturn(true).when(myrepo).isConnected();
doReturn(null).when(myrepo).getJobEntryAttributeString(any(ObjectId.class), anyString());
doReturn("rep_name").when(myrepo).getJobEntryAttributeString(JOB_ENTRY_JOB_OBJECT_ID, "specification_method");
doReturn("job").when(myrepo).getJobEntryAttributeString(JOB_ENTRY_JOB_OBJECT_ID, "name");
doReturn("${hdfs}").when(myrepo).getJobEntryAttributeString(JOB_ENTRY_JOB_OBJECT_ID, "dir_path");
JobEntryJob jej = getJej();
jej.loadRep(myrepo, store, JOB_ENTRY_JOB_OBJECT_ID, databases, servers);
jej.getJobMeta(myrepo, store, space);
assertEquals(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, jej.getSpecificationMethod());
verifyNew(JobMeta.class).withArguments(any(VariableSpace.class), eq("hdfs://server/path/job.kjb"), eq(myrepo), eq(store), eq(null));
}
use of org.pentaho.di.repository.Repository in project pentaho-kettle by pentaho.
the class JobEntryJobTest method testConnectedLoad_Filename_Guess.
/**
* When connected to the repository and {@link JobEntryJob} references a child job by file path,
* guess {@link ObjectLocationSpecificationMethod} as {@code FILENAME}.
* Load the job from the repository using the specified file path.
*/
@Test
public void testConnectedLoad_Filename_Guess() throws Exception {
Repository myrepo = mock(Repository.class);
doReturn(true).when(myrepo).isConnected();
doReturn(null).when(myrepo).getJobEntryAttributeString(any(ObjectId.class), anyString());
doReturn(JOB_ENTRY_FILE_PATH).when(myrepo).getJobEntryAttributeString(JOB_ENTRY_JOB_OBJECT_ID, "file_name");
JobEntryJob jej = getJej();
jej.loadRep(myrepo, store, JOB_ENTRY_JOB_OBJECT_ID, databases, servers);
jej.getJobMeta(myrepo, store, space);
assertEquals(ObjectLocationSpecificationMethod.FILENAME, jej.getSpecificationMethod());
verifyNew(JobMeta.class).withArguments(any(VariableSpace.class), eq(JOB_ENTRY_FILE_PATH), eq(myrepo), eq(store), eq(null));
}
Aggregations