Search in sources :

Example 21 with Repository

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;
}
Also used : Repository(org.pentaho.di.repository.Repository)

Example 22 with Repository

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);
}
Also used : Repository(org.pentaho.di.repository.Repository) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 23 with Repository

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);
}
Also used : Repository(org.pentaho.di.repository.Repository) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 24 with Repository

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));
}
Also used : Repository(org.pentaho.di.repository.Repository) JobMeta(org.pentaho.di.job.JobMeta) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) VariableSpace(org.pentaho.di.core.variables.VariableSpace) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 25 with Repository

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));
}
Also used : Repository(org.pentaho.di.repository.Repository) JobMeta(org.pentaho.di.job.JobMeta) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) VariableSpace(org.pentaho.di.core.variables.VariableSpace) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Repository (org.pentaho.di.repository.Repository)194 Test (org.junit.Test)110 KettleException (org.pentaho.di.core.exception.KettleException)66 TransMeta (org.pentaho.di.trans.TransMeta)48 ObjectId (org.pentaho.di.repository.ObjectId)36 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)31 IMetaStore (org.pentaho.metastore.api.IMetaStore)29 JobMeta (org.pentaho.di.job.JobMeta)27 StringObjectId (org.pentaho.di.repository.StringObjectId)26 RepositoryMeta (org.pentaho.di.repository.RepositoryMeta)24 ArrayList (java.util.ArrayList)20 StepMeta (org.pentaho.di.trans.step.StepMeta)20 VariableSpace (org.pentaho.di.core.variables.VariableSpace)18 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)18 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)17 PrintWriter (java.io.PrintWriter)15 Variables (org.pentaho.di.core.variables.Variables)15 IOException (java.io.IOException)14 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)14 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)13